cvs: php4 /pear/PEAR Installer.php
| From: | Thomas V.V.Cox | Date: | Wed, 18 Jul 2001 23:13:57 +0000 |
| Subject: | cvs: php4 /pear/PEAR Installer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-298@lists.php.net to get a copy of this message | ||
cox Wed Jul 18 19:13:57 2001 EDT
Modified files:
/php4/pear/PEAR Installer.php
Log:
- Only decompress package once
- Allow relative directory package calls (for ex:
pear install packs/Pear_DB-1.1.tgz)
Index: php4/pear/PEAR/Installer.php
diff -u php4/pear/PEAR/Installer.php:1.13 php4/pear/PEAR/Installer.php:1.14
--- php4/pear/PEAR/Installer.php:1.13 Wed Jul 18 13:29:09 2001
+++ php4/pear/PEAR/Installer.php Wed Jul 18 19:13:56 2001
@@ -17,7 +17,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Installer.php,v 1.13 2001/07/18 17:29:09 cox Exp $
+// $Id: Installer.php,v 1.14 2001/07/18 23:13:56 cox Exp $
require_once "PEAR/Common.php";
@@ -29,7 +29,6 @@
* - move the package db handler methods to its own class.
* - install also the package.xml?
* - remove unneeded code
- * - only decrompress pack once
*
* @since PHP 4.0.2
* @author Stig Bakken <ssb@fast.no>
@@ -252,53 +251,44 @@
fclose($wp);
$this->log(1, '...done: ' . number_format($bytes, 0, '',
',') . ' bytes');
}
- // Test for package.xml -------------------------------------------
- // XXX FIXME only decompress once
- $fp = popen("gzip -dc $pkgfile | tar -tf -", 'r');
- if (!$fp) {
- return $this->raiseError("Unable to examine $pkgfile (gzip or tar
failed)");
- }
- while ($line = fgets($fp, 4096)) {
- $line = rtrim($line);
- if (preg_match('!^[^/]+/package.xml$!', $line)) {
- if (isset($descfile)) {
- return $this->raiseError("Invalid package: multiple package.xml files
at depth one!");
- }
- $descfile = $line;
- }
- }
- pclose($fp);
- if (!$descfile) {
- return $this->raiseError("Invalid package: no package.xml file found!");
- }
// Decompress pack in tmp dir -------------------------------------
+
+ // To allow relative package file calls
+ if (!chdir(dirname($pkgfile))) {
+ return $this->raiseError('Unable to chdir to pakage directory');
+ }
+ $pkgfile = getcwd() . DIRECTORY_SEPARATOR . basename($pkgfile);
+
// XXX FIXME Windows
- $this->tmpdir = tempnam("/tmp", "pear");
+ $this->tmpdir = tempnam('/tmp', 'pear');
unlink($this->tmpdir);
if (!mkdir($this->tmpdir, 0755)) {
return $this->raiseError("Unable to create temporary directory
$this->tmpdir.");
} else {
- $this->log(2, '...tmp dir created at ' . $this->tmpdir);
+ $this->log(2, '+ tmp dir created at ' . $this->tmpdir);
}
$this->addTempFile($this->tmpdir);
-
-
- // XXX FIXME Windows should check for drive
- if (substr($pkgfile, 0, 1) == DIRECTORY_SEPARATOR) {
- $pkgfilepath = $pkgfile;
- } else {
- $pkgfilepath = $this->pwd . DIRECTORY_SEPARATOR . $pkgfile;
- }
-
if (!chdir($this->tmpdir)) {
return $this->raiseError("Unable to chdir to $this->tmpdir.");
}
// XXX FIXME Windows
- system("gzip -dc $pkgfilepath | tar -xf -");
- $this->log(2, "launched command: gzip -dc $pkgfilepath | tar -xf -");
- if (!is_file($descfile)) {
- $this->log(2, "No desc file found: $descfile");
+ $fp = popen("gzip -dc $pkgfile | tar -xvf -", 'r');
+ $this->log(2, "+ launched command: gzip -dc $pkgfile | tar -xvf -");
+ if (!is_resource($fp)) {
+ return $this->raiseError("Unable to examine $pkgfile (gzip or tar
failed)");
+ }
+ while ($line = fgets($fp, 4096)) {
+ $line = rtrim($line);
+ if (preg_match('!^[^/]+/package.xml$!', $line)) {
+ if (isset($descfile)) {
+ return $this->raiseError("Invalid package: multiple package.xml files
at depth one!");
+ }
+ $descfile = $line;
+ }
+ }
+ pclose($fp);
+ if (!isset($descfile) || !is_file($descfile)) {
return $this->raiseError("No package.xml file after extracting the
archive.");
}
@@ -313,9 +303,10 @@
return $this->raiseError("No script destination directory found\n",
null, PEAR_ERROR_DIE);
}
+ $tmp_path = dirname($descfile);
foreach ($pkginfo['filelist'] as $fname => $atts) {
$dest_dir = $this->phpdir . DIRECTORY_SEPARATOR . dirname($fname);
- $fname = dirname($descfile) . DIRECTORY_SEPARATOR . $fname;
+ $fname = $tmp_path . DIRECTORY_SEPARATOR . $fname;
$this->_copyFile($fname, $dest_dir, $atts);
}
return true;