cvs: php4 /pear/PEAR Packager.php
| From: | Stig Bakken | Date: | Mon, 29 Apr 2002 06:38:20 +0000 |
| Subject: | cvs: php4 /pear/PEAR Packager.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3621@lists.php.net to get a copy of this message | ||
ssb Mon Apr 29 02:38:20 2002 EDT
Modified files:
/php4/pear/PEAR Packager.php
Log:
* slight cleanup
Index: php4/pear/PEAR/Packager.php
diff -u php4/pear/PEAR/Packager.php:1.40 php4/pear/PEAR/Packager.php:1.41
--- php4/pear/PEAR/Packager.php:1.40 Mon Apr 29 02:29:07 2002
+++ php4/pear/PEAR/Packager.php Mon Apr 29 02:38:07 2002
@@ -17,7 +17,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Packager.php,v 1.40 2002/04/29 06:29:07 ssb Exp $
+// $Id: Packager.php,v 1.41 2002/04/29 06:38:07 ssb Exp $
require_once 'PEAR/Common.php';
@@ -32,13 +32,6 @@
*/
class PEAR_Packager extends PEAR_Common
{
- // {{{ properties
-
- /** debug mode (integer) */
- var $debug = 0;
-
- // }}}
-
// {{{ constructor
function PEAR_Packager()
@@ -60,7 +53,6 @@
function package($pkgfile = null, $compress = true)
{
- $this->orig_pwd = getcwd();
if (empty($pkgfile)) {
$pkgfile = 'package.xml';
}
@@ -68,19 +60,17 @@
if (PEAR::isError($pkginfo)) {
return $this->raiseError($pkginfo);
}
- // XXX This needs to be checked in infoFromDescriptionFile
- // or at least a helper method to do the proper checks
if (empty($pkginfo['version'])) {
return $this->raiseError("No version info found in $pkgfile");
}
// TMP DIR -------------------------------------------------
// We allow calls like "pear package /home/user/mypack/package.xml"
+ $oldcwd = getcwd();
if (!@chdir(dirname($pkgfile))) {
return $this->raiseError('Could not chdir to '.dirname($pkgfile));
}
- $pwd = getcwd();
$pkgfile = basename($pkgfile);
- if (isset($pkginfo['release_state']) &&
$pkginfo['release_state'] == 'snapshot' &&
empty($pkginfo['version'])) {
+ if (@$pkginfo['release_state'] == 'snapshot' &&
empty($pkginfo['version'])) {
$pkginfo['version'] = date('Ymd');
}
// don't want strange characters
@@ -95,7 +85,7 @@
// Copy files -----------------------------------------------
foreach ($pkginfo['filelist'] as $fname => $atts) {
if (!file_exists($fname)) {
- chdir($this->orig_pwd);
+ chdir($oldcwd);
return $this->raiseError("File $fname does not exist");
} else {
$filelist[$i++] = $fname;
@@ -108,14 +98,14 @@
}
$new_xml = $this->xmlFromInfo($pkginfo);
if (PEAR::isError($new_xml)) {
- chdir($this->orig_pwd);
+ chdir($oldcwd);
return $this->raiseError($new_xml);
}
$tmpdir = $this->mkTempDir(getcwd());
$newpkgfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml';
$np = @fopen($newpkgfile, "w");
if (!$np) {
- chdir($this->orig_pwd);
+ chdir($oldcwd);
return $this->raiseError("PEAR_Packager: unable to rewrite $pkgfile");
}
fwrite($np, $new_xml);
@@ -123,21 +113,21 @@
// TAR the Package -------------------------------------------
$ext = $compress ? '.tgz' : '.tar';
- $dest_package = $this->orig_pwd . DIRECTORY_SEPARATOR . $pkgver . $ext;
+ $dest_package = $oldcwd . DIRECTORY_SEPARATOR . $pkgver . $ext;
$tar =& new Archive_Tar($dest_package, $compress);
$tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
// ----- Creates with the package.xml file
$ok = $tar->createModify($newpkgfile, '', $tmpdir);
if (PEAR::isError($ok)) {
- chdir($this->orig_pwd);
+ chdir($oldcwd);
return $this->raiseError($ok);
} elseif (!$ok) {
- chdir($this->orig_pwd);
+ chdir($oldcwd);
return $this->raiseError('PEAR_Packager: tarball creation failed');
}
// ----- Add the content of the package
if (!$tar->addModify($filelist, $pkgver)) {
- chdir($this->orig_pwd);
+ chdir($oldcwd);
return $this->raiseError('PEAR_Packager: tarball creation failed');
}
$this->log(1, "Package $dest_package done");
@@ -147,7 +137,7 @@
$this->log(1, "Tag the released code with `pear cvstag $pkgfile'");
$this->log(1, "(or set the CVS tag $cvstag by hand)");
}
- chdir($this->orig_pwd);
+ chdir($oldcwd);
return $dest_package;
}