cvs: php4 /pear/PEAR Installer.php Packager.php

From: Date: Sun, 07 Oct 2001 20:16:41 +0000
Subject: cvs: php4 /pear/PEAR Installer.php Packager.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-952@lists.php.net to get a copy of this message
cox Sun Oct 7 16:16:41 2001 EDT Modified files: /php4/pear/PEAR Installer.php Packager.php Log: work on Windows support (use Tar class and System class) Index: php4/pear/PEAR/Installer.php diff -u php4/pear/PEAR/Installer.php:1.18 php4/pear/PEAR/Installer.php:1.19 --- php4/pear/PEAR/Installer.php:1.18 Mon Aug 27 17:25:16 2001 +++ php4/pear/PEAR/Installer.php Sun Oct 7 16:16:41 2001 @@ -18,16 +18,17 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Installer.php,v 1.18 2001/08/27 21:25:16 ssb Exp $ +// $Id: Installer.php,v 1.19 2001/10/07 20:16:41 cox Exp $ -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 @@ { 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 @@ $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)"); - } - 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; - } + + $tar = new Archive_Tar($pkgfile, true); + if (!$tar->extract($this->tmpdir)) { + return $this->raiseError("Unable to unpack $pkgfile"); + } + $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."); } Index: php4/pear/PEAR/Packager.php diff -u php4/pear/PEAR/Packager.php:1.13 php4/pear/PEAR/Packager.php:1.14 --- php4/pear/PEAR/Packager.php:1.13 Thu Sep 27 19:31:15 2001 +++ php4/pear/PEAR/Packager.php Sun Oct 7 16:16:41 2001 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Packager.php,v 1.13 2001/09/27 23:31:15 cox Exp $ +// $Id: Packager.php,v 1.14 2001/10/07 20:16:41 cox Exp $ require_once 'PEAR/Common.php'; @@ -27,7 +27,7 @@ * * 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 @@ $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); }

« previous php.pear.cvs (#952) next »