diff options
author | Tomas V.V.Cox <cox@php.net> | 2001-07-31 13:36:54 +0000 |
---|---|---|
committer | Tomas V.V.Cox <cox@php.net> | 2001-07-31 13:36:54 +0000 |
commit | 2c1af4d64508361f4f1ee5eb10eff02b804d3478 (patch) | |
tree | a7913f85038f62ee8a924c2e495d27f8ea228ccf | |
parent | ae92dc7139eb735b1d7bda61d03b1c6f59f373cd (diff) | |
download | php-git-2c1af4d64508361f4f1ee5eb10eff02b804d3478.tar.gz |
package() now returns the full path of the generated package also improved
windows support (if php getcwd() returns also the drive letter, please test it)
-rw-r--r-- | pear/PEAR/Packager.php | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/pear/PEAR/Packager.php b/pear/PEAR/Packager.php index 2a56fb73a6..b790ac956f 100644 --- a/pear/PEAR/Packager.php +++ b/pear/PEAR/Packager.php @@ -121,16 +121,14 @@ class PEAR_Packager extends PEAR_Common return $pkginfo; } // TMP DIR ------------------------------------------------- - $pwd = getcwd(); - $new_pwd = dirname($pkgfile); - // We allow calls like "pear package /home/cox/mypack/package.xml" - if ($new_pwd != '.') { - chdir($new_pwd); - $new_pwd = getcwd(); - $orig_pwd = $pwd; - $pwd = $new_pwd; - $pkgfile = basename($pkgfile); + $orig_pwd = getcwd(); + // We allow calls like "pear package /home/user/mypack/package.xml" + if (!@chdir(dirname($pkgfile))) { + return $this->raiseError('Couldn\'t chdir to package.xml dir', + null, PEAR_ERROR_TRIGGER, E_USER_ERROR); } + $pwd = getcwd(); + $pkgfile = basename($pkgfile); $pkgver = $pkginfo['package'] . '-' . $pkginfo['version']; // don't want strange characters $pkgver = ereg_replace ('[^a-zA-Z0-9._-]', '_', $pkgver); @@ -172,15 +170,15 @@ class PEAR_Packager extends PEAR_Common // TAR the Package ------------------------------------------- chdir(dirname($this->tmpdir)); + $dest_package = $orig_pwd . DIRECTORY_SEPARATOR . "${pkgver}.tgz"; // XXX FIXME Windows and non-GNU tar - $pwd = (isset($orig_pwd)) ? $orig_pwd : $pwd; - $cmd = "tar -cvzf $pwd/${pkgver}.tgz $pkgver"; + $cmd = "tar -cvzf $dest_package $pkgver"; + $this->log(2, "+ launched cmd: $cmd"); // XXX TODO: add an extra param where to leave the package? $this->log(1, `$cmd`); - $this->log(1, "Package $pwd/${pkgver}.tgz done"); - if (isset($orig_pwd)) { - chdir($orig_pwd); - } + $this->log(1, "Package $dest_package done"); + chdir($orig_pwd); + return $dest_package; } /* XXXX REMOVEME: this is the old code |