diff options
author | Tomas V.V.Cox <cox@php.net> | 2001-10-07 20:16:41 +0000 |
---|---|---|
committer | Tomas V.V.Cox <cox@php.net> | 2001-10-07 20:16:41 +0000 |
commit | 5b0e54088260814b416d5196fd20c226f17f4799 (patch) | |
tree | 8542c3faa3d0d73dd87d5bd0f56b11e0a6d01be7 | |
parent | b46e7d76b40395ddf68b6c71408555884f520b02 (diff) | |
download | php-git-5b0e54088260814b416d5196fd20c226f17f4799.tar.gz |
work on Windows support (use Tar class and System class)
-rw-r--r-- | pear/PEAR/Installer.php | 37 | ||||
-rw-r--r-- | pear/PEAR/Packager.php | 4 |
2 files changed, 18 insertions, 23 deletions
diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 01ff470cd3..3e70b13c86 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -20,14 +20,15 @@ // // $Id$ -require_once "PEAR/Common.php"; +require_once 'PEAR/Common.php'; /** * Administration class used to install PEAR packages and maintain the * installed package database. * * TODO: - * - maintain file perms (look at umask or fileperms+chmod), ideas are welcome + * - finish and test Windows support + * - kill FIXME's * * @since PHP 4.0.2 * @author Stig Bakken <ssb@fast.no> @@ -81,7 +82,7 @@ class PEAR_Installer extends PEAR_Common { chdir($this->pwd); if ($this->tmpdir && is_dir($this->tmpdir)) { - system("rm -rf $this->tmpdir"); // XXX FIXME Windows + System::rm("-rf $this->tmpdir"); } $this->tmpdir = null; $this->_PEAR_Common(); @@ -156,26 +157,20 @@ class PEAR_Installer extends PEAR_Common $this->log(2, '+ tmp dir created at ' . $this->tmpdir); } $this->addTempFile($this->tmpdir); - if (!chdir($this->tmpdir)) { - return $this->raiseError("Unable to chdir to $this->tmpdir."); - } - // XXX FIXME Windows - $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)"); + + $tar = new Archive_Tar($pkgfile, true); + if (!$tar->extract($this->tmpdir)) { + return $this->raiseError("Unable to unpack $pkgfile"); } - 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; - } + $file = basename($pkgfile); + // Assume the decompressed dir name + if (($pos = strrpos($file, '.')) === false) { + return $this->raiseError('package doesn\'t follow the package name convention'); } - pclose($fp); - if (!isset($descfile) || !is_file($descfile)) { + $pkgdir = substr($file, 0, $pos); + $descfile = $this->tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml'; + + if (!is_file($descfile)) { return $this->raiseError("No package.xml file after extracting the archive."); } diff --git a/pear/PEAR/Packager.php b/pear/PEAR/Packager.php index 6a4f10c6e8..acc116898b 100644 --- a/pear/PEAR/Packager.php +++ b/pear/PEAR/Packager.php @@ -27,7 +27,7 @@ require_once 'PEAR/Common.php'; * * TODO: * - add an extra param the dir where to place the created package - * - preserve file permissions (solve umask in copy problem) + * - finish and test Windows support * * @since PHP 4.0.2 * @author Stig Bakken <ssb@fast.no> @@ -104,7 +104,7 @@ class PEAR_Packager extends PEAR_Common $file = array_shift($this->_tempfiles)) { if (is_dir($file)) { - system("rm -rf $file"); // XXX FIXME Windows + System::rm("-rf $file"); // XXX FIXME Windows } else { unlink($file); } |