44 function package($pkgfile =
null, $compress =
true, $pkg2 =
null)
47 if (empty($pkgfile)) {
48 $pkgfile =
'package.xml';
57 if (is_array($pf->getUserInfo())) {
58 foreach ($pf->getUserInfo() as $error) {
59 $this->
log(0,
'Error: ' . $error[
'message']);
63 $this->
log(0, $pf->getMessage());
64 return $this->raiseError(
"Cannot package, errors in package file");
67 foreach ($pf->getValidationWarnings() as $warning) {
68 $this->
log(1,
'Warning: ' . $warning[
'message']);
73 $this->
log(0,
'Attempting to process the second package file');
78 if (is_array($pf2->getUserInfo())) {
79 foreach ($pf2->getUserInfo() as $error) {
80 $this->
log(0,
'Error: ' . $error[
'message']);
83 $this->
log(0, $pf2->getMessage());
84 return $this->raiseError(
"Cannot package, errors in second package file");
87 foreach ($pf2->getValidationWarnings() as $warning) {
88 $this->
log(1,
'Warning: ' . $warning[
'message']);
91 if ($pf2->getPackagexmlVersion() ==
'2.0' ||
92 $pf2->getPackagexmlVersion() ==
'2.1'
101 if ($main->getPackagexmlVersion() !=
'2.0' &&
102 $main->getPackagexmlVersion() !=
'2.1') {
103 return PEAR::raiseError(
'Error: cannot package two package.xml version 1.0, can ' .
104 'only package together a package.xml 1.0 and package.xml 2.0');
107 if ($other->getPackagexmlVersion() !=
'1.0') {
108 return PEAR::raiseError(
'Error: cannot package two package.xml version 2.0, can ' .
109 'only package together a package.xml 1.0 and package.xml 2.0');
113 $main->setLogger($this);
115 foreach ($main->getValidationWarnings() as $warning) {
116 $this->
log(0,
'Error: ' . $warning[
'message']);
118 return $this->raiseError(
"Cannot package, errors in package");
121 foreach ($main->getValidationWarnings() as $warning) {
122 $this->
log(1,
'Warning: ' . $warning[
'message']);
126 $other->setLogger($this);
129 foreach ($other->getValidationWarnings() as $warning) {
130 $this->
log(0,
'Error: ' . $warning[
'message']);
133 foreach ($main->getValidationWarnings() as $warning) {
134 $this->
log(0,
'Error: ' . $warning[
'message']);
138 return $this->raiseError(
'The two package.xml files are not equivalent!');
141 return $this->raiseError(
"Cannot package, errors in package");
144 foreach ($other->getValidationWarnings() as $warning) {
145 $this->
log(1,
'Warning: ' . $warning[
'message']);
148 $gen = &$main->getDefaultGenerator();
149 $tgzfile = $gen->toTgz2($this, $other, $compress);
154 $dest_package = basename($tgzfile);
155 $pkgdir = dirname($pkgfile);
158 $this->
log(1,
"Package $dest_package done");
159 if (file_exists(
"$pkgdir/CVS/Root")) {
160 $cvsversion = preg_replace(
'/[^a-z0-9]/i',
'_', $pf->getVersion());
161 $cvstag =
"RELEASE_$cvsversion";
162 $this->
log(1,
'Tag the released code with "pear cvstag ' .
163 $main->getPackageFile() .
'"');
164 $this->
log(1,
"(or set the CVS tag $cvstag by hand)");
165 } elseif (file_exists(
"$pkgdir/.svn")) {
166 $svnversion = preg_replace(
'/[^a-z0-9]/i',
'.', $pf->getVersion());
167 $svntag = $pf->getName() .
"-$svnversion";
168 $this->
log(1,
'Tag the released code with "pear svntag ' .
169 $main->getPackageFile() .
'"');
170 $this->
log(1,
"(or set the SVN tag $svntag by hand)");
173 $gen = &$pf->getDefaultGenerator();
174 $tgzfile = $gen->toTgz($this, $compress);
176 $this->
log(0, $tgzfile->getMessage());
177 return $this->raiseError(
"Cannot package, errors in package");
180 $dest_package = basename($tgzfile);
181 $pkgdir = dirname($pkgfile);
184 $this->
log(1,
"Package $dest_package done");
185 if (file_exists(
"$pkgdir/CVS/Root")) {
186 $cvsversion = preg_replace(
'/[^a-z0-9]/i',
'_', $pf->getVersion());
187 $cvstag =
"RELEASE_$cvsversion";
188 $this->
log(1,
"Tag the released code with `pear cvstag $pkgfile'");
189 $this->
log(1,
"(or set the CVS tag $cvstag by hand)");
190 } elseif (file_exists(
"$pkgdir/.svn")) {
191 $svnversion = preg_replace(
'/[^a-z0-9]/i',
'.', $pf->getVersion());
192 $svntag = $pf->getName() .
"-$svnversion";
193 $this->
log(1,
"Tag the released code with `pear svntag $pkgfile'");
194 $this->
log(1,
"(or set the SVN tag $svntag by hand)");
198 return $dest_package;