diff options
author | Tomas V.V.Cox <cox@php.net> | 2001-07-18 23:13:56 +0000 |
---|---|---|
committer | Tomas V.V.Cox <cox@php.net> | 2001-07-18 23:13:56 +0000 |
commit | 96389283178625cff07b1786a3eff32239274394 (patch) | |
tree | 620dacc6157fa3a2003d691105d90e9c5ad49003 /pear | |
parent | 9576ab24dd1e21ef674f8d6b95de5055b3f8e1f9 (diff) | |
download | php-git-96389283178625cff07b1786a3eff32239274394.tar.gz |
- Only decompress package once
- Allow relative directory package calls (for ex:
pear install packs/Pear_DB-1.1.tgz)
Diffstat (limited to 'pear')
-rw-r--r-- | pear/PEAR/Installer.php | 63 |
1 files changed, 27 insertions, 36 deletions
diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 4779700340..742e7328d4 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -29,7 +29,6 @@ require_once "PEAR/Common.php"; * - 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 @@ class PEAR_Installer extends PEAR_Common 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 @@ class PEAR_Installer extends PEAR_Common 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; |