From: Tomas V.V.Cox Date: Tue, 31 Jul 2001 13:36:54 +0000 (+0000) Subject: package() now returns the full path of the generated package also improved X-Git-Tag: PRE_ENGINE2_SPLIT~161 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c1af4d64508361f4f1ee5eb10eff02b804d3478;p=php 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) --- 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