Modified: pear2/Pyrus/trunk/src/Pyrus/ChannelInterface.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/ChannelInterface.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/ChannelInterface.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -30,4 +30,4 @@ function __toString(); public function getValidationObject($package = false); public function getValidationPackage(); -} +} \ No newline at end of file Modified: pear2/Pyrus/trunk/src/Pyrus/ChannelRegistryInterface.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/ChannelRegistryInterface.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/ChannelRegistryInterface.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -34,4 +34,4 @@ public function parseName($name); public function parsedNameToString($name); public function listChannels(); -} +} \ No newline at end of file Modified: pear2/Pyrus/trunk/src/Pyrus/Installer/Role/Cfg.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Installer/Role/Cfg.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Installer/Role/Cfg.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -39,6 +39,7 @@ if (!($package = $installer->wasInstalled($pkg->name, $pkg->channel))) { return; } + if (isset($package->files[$file]) && isset($package->files[$file]['attribs']['md5sum'])) { $this->md5 = $package->files[$file]['attribs']['md5sum']; } @@ -50,14 +51,17 @@ if ($this->md5 === null) { return parent::getRelativeLocation($pkg, $file, $retDir); } + $info = parent::getRelativeLocation($pkg, $file, $retDir); $path = \pear2\Pyrus\Config::current()->cfg_dir . DIRECTORY_SEPARATOR; + if ($retDir) { $filepath = $info[1]; } else { $filepath = $info; } + if (@file_exists($path .$filepath)) { // configuration has already been installed, check for modifications // made by the user @@ -68,6 +72,7 @@ } else { $newmd5 = $newmd5['md5sum']; } + // first check to see if the user modified the file // next check to see if the config file changed from the last installed version // if both tests are satisfied, install the new file under another name and display a warning @@ -80,12 +85,13 @@ "you should manually merge in changes to the existing configuration file"); } } + if ($retDir) { $info[1] = $filepath; } else { $info = $filepath; } + return $info; } -} -?> \ No newline at end of file +} \ No newline at end of file Modified: pear2/Pyrus/trunk/src/Pyrus/Installer/Role/Common.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Installer/Role/Common.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Installer/Role/Common.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -75,6 +75,7 @@ if (!$this->info['honorsbaseinstall']) { array_shift($location); } + $location = implode('/', $location); return $location; } Modified: pear2/Pyrus/trunk/src/Pyrus/Installer/Role.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Installer/Role.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Installer/Role.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -24,6 +24,7 @@ * @link http://svn.pear.php.net/wsvn/PEARSVN/Pyrus/ */ namespace pear2\Pyrus\Installer; +use \pear2\Pyrus\Config as Config; class Role { static private $_roles; @@ -36,7 +37,7 @@ * @access private * @static */ - public static function initializeConfig(\pear2\Pyrus\Config $config) + public static function initializeConfig(Config $config) { if (!isset(self::$_roles)) { self::registerRoles(); @@ -63,12 +64,11 @@ } if (!in_array($role, self::getValidRoles($packagetype))) { - throw new \pear2\Pyrus\Installer\Exception('Invalid role ' . $role . - 'requested for package type ' . $packagetype); + throw new Exception('Invalid role ' . $role . 'requested for package type ' . $packagetype); } $class = self::$_roles[$role]['class']; - return new $class(\pear2\Pyrus\Config::current(), self::$_roles[$role]); + return new $class(Config::current(), self::$_roles[$role]); } /** @@ -192,18 +192,19 @@ } if (!file_exists($dir) || !is_dir($dir)) { - throw new \pear2\Pyrus\Installer\Role\Exception("registerRoles: opendir($dir) failed"); + throw new Role\Exception("registerRoles: opendir($dir) failed"); } $dp = @opendir($dir); if (empty($dp)) { - throw new \pear2\Pyrus\Installer\Role\Exception("registerRoles: opendir($dir) failed"); + throw new Role\Exception("registerRoles: opendir($dir) failed"); } $schemapath = \pear2\Pyrus\Main::getDataPath() . '/customrole-2.0.xsd'; if (!file_exists($schemapath)) { $schemapath = realpath(__DIR__ . '/../../../data/customrole-2.0.xsd'); } + while ($entry = readdir($dp)) { if ($entry{0} == '.' || substr($entry, -4) != '.xml') { continue; @@ -218,6 +219,7 @@ if (!is_array($data['releasetypes'])) { $data['releasetypes'] = array($data['releasetypes']); } + self::$_roles[$role] = $data; } } @@ -245,22 +247,25 @@ if (!isset($info['configvar'][0])) { $info['configvar'] = array($info['configvar']); } + foreach ($info['configvar'] as $configvar) { $default = $configvar['default']; if (false !== strpos($default, 'temp_dir . DIRECTORY_SEPARATOR . - '.configdefault.php'; + $tmp = Config::current()->temp_dir . DIRECTORY_SEPARATOR . '.configdefault.php'; if (!file_exists(dirname($tmp))) { mkdir(dirname($tmp), 0755, true); } + file_put_contents($tmp, $default); $getDefault = function() use ($tmp) { include $tmp; return $default; }; + $default = $getDefault(); } - \pear2\Pyrus\Config::addConfigValue($configvar['name'], $default, $configvar['configtype']); + + Config::addConfigValue($configvar['name'], $default, $configvar['configtype']); } } } @@ -278,7 +283,7 @@ } if (empty(self::$_roles[$role])) { - throw new \pear2\Pyrus\Installer\Role\Exception('Unknown Role: "' . $role . '"'); + throw new Role\Exception('Unknown Role: "' . $role . '"'); } return self::$_roles[$role]; Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Base.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Base.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Base.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -255,18 +255,20 @@ function getFileContents($file, $asstream = false) { if (!isset($this[$file])) { - throw new \pear2\Pyrus\Package\Exception('file ' . $file . ' is not in this package'); + throw new Exception('file ' . $file . ' is not in this package'); } + if ($asstream) { $fp = fopen($this->getFilePath($file), 'rb'); return $fp; - } else { - $ret = file_get_contents($this->getFilePath($file)); - if (!$ret) { - $ret = ''; - } - return $ret; } + + $ret = file_get_contents($this->getFilePath($file)); + if (!$ret) { + $ret = ''; + } + + return $ret; } function getTask($file, $name) @@ -276,6 +278,7 @@ } elseif (is_array($file)) { $fileAttribs = $file; } + $taskclass = \pear2\Pyrus\Task\Common::getTask($name); return new $taskclass($this, \pear2\Pyrus\Task\Common::PACKAGE, $fileAttribs, $fileAttribs['attribs'], null); Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Cloner.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Cloner.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Cloner.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -55,11 +55,13 @@ } elseif ($p->isFileFormat(\Phar::ZIP)) { $this->zip = $p; } + $sig = $p->getSignature(); if ($sig) { $this->hash = $sig['hash']; $this->signature_algo = $sig['hash_type']; } + $info = pathinfo($base); $this->file = $info['dirname'] . DIRECTORY_SEPARATOR . $info['filename']; $this->ext = substr($info['filename'], strpos($info['filename'], '.')); @@ -75,22 +77,27 @@ if (isset($this->tgz)) { return; } + if (isset($this->tar)) { if (file_exists($this->file . '.tgz')) { try { $p = new \PharData($this->file . '.tgz'); } catch (\Exception $e) { } + if ($p->getSignature() === $this->tar->getSignature()) { $this->tgz = $p; if ($this->outfile) { copy($this->file . '.tgz', $this->outfile . '.tgz'); } + return; } + unset($p); \Phar::unlinkArchive($this->file . '.tgz'); } + $fp = fopen($this->file . '.tar', 'rb'); $gp = gzopen($this->file . '.tgz', 'wb'); stream_copy_to_stream($fp, $gp); @@ -100,17 +107,21 @@ if ($this->outfile) { copy($this->file . '.tgz', $this->outfile . '.tgz'); } + return; } + // by process of elimination, the phar is in zip format if (file_exists($this->file . '.tgz')) { \Phar::unlinkArchive($this->file . '.tgz'); unlink($this->file . '.tgz'); } + $this->tgz = $this->zip->convertToData(\Phar::TAR, \Phar::GZ, $this->ext . '.tgz'); if ($this->outfile) { copy($this->file . '.tgz', $this->outfile . '.tgz'); } + $this->zip = new \PharData($this->file . '.zip'); } @@ -119,12 +130,14 @@ if (isset($this->tar)) { return; } + if (isset($this->tgz)) { if (file_exists($this->file . '.tar')) { try { $p = new \PharData($this->file . '.tar'); } catch (\Exception $e) { } + if ($p->getSignature() === $this->phar->getSignature()) { $this->tar = $p; if ($this->outfile) { @@ -197,7 +210,7 @@ return; } } catch (\Exception $e) { - + } } } @@ -304,4 +317,3 @@ $this->zip = new \PharData($this->file . '.zip'); } } - Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Creator/TaskIterator.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Creator/TaskIterator.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Creator/TaskIterator.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -92,16 +92,20 @@ if (isset($xml['attribs'])) { $attribs = $xml['attribs']; } + $tasks[] = new $task($this->_parent, $this->_installphase, $info, $attribs, $this->lastversion); } + $attribs = isset($this->_inner['attribs']) ? array($this->_inner['attribs']) : $this->_inner; // use proxy for multiple tasks return new \pear2\Pyrus\Task\MultipleProxy($this->_parent, $tasks, $attribs, $this->key()); } + $attribs = array(); if (isset($xml['attribs'])) { $attribs = $xml['attribs']; } + $task = str_replace(array($this->_tasksNs . ':', '-'), array('', ' '), parent::key()); $task = str_replace(' ', '/', ucwords($task)); $task = str_replace('/', '_', $task); Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Creator.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Creator.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Creator.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -40,8 +40,8 @@ { if (!$pear2ExceptionPath) { if (!($pear2Exception = @fopen('pear2/Exception.php', 'r', true))) { - throw new \pear2\Pyrus\Package\Exception('Cannot locate pear2/Exception.php, please' . - ' pass in the path to the constructor'); + throw new Exception('Cannot locate pear2/Exception.php, please' . + ' pass in the path to the constructor'); } } else { if ($a = realpath($pear2ExceptionPath)) { @@ -51,16 +51,15 @@ $pear2ExceptionPath .= '/'; } if (!($pear2Exception = @fopen($pear2ExceptionPath . 'Exception.php', 'r'))) { - throw new \pear2\Pyrus\Package\Exception('Cannot locate pear2/Exception.php' . - ' in ' . $pear2ExceptionPath); + throw new Exception('Cannot locate pear2/Exception.php in ' . $pear2ExceptionPath); } } if (!$pear2AutoloadPath) { if (!($pear2Autoload = @fopen('pear2/Autoload.php', 'r', true))) { fclose($pear2Exception); - throw new \pear2\Pyrus\Package\Exception('Cannot locate pear2/Autoload.php, please' . - ' pass in the path to the constructor'); + throw new Exception('Cannot locate pear2/Autoload.php, please' . + ' pass in the path to the constructor'); } } else { if ($a = realpath($pear2AutoloadPath)) { @@ -71,8 +70,7 @@ } if (!($pear2Autoload = @fopen($pear2AutoloadPath . 'Autoload.php', 'r'))) { fclose($pear2Exception); - throw new \pear2\Pyrus\Package\Exception('Cannot locate pear2/Autoload.php' . - ' in ' . $pear2AutoloadPath); + throw new Exception('Cannot locate pear2/Autoload.php in ' . $pear2AutoloadPath); } } @@ -80,16 +78,16 @@ if (!($pear2MultiErrors = @fopen('pear2/MultiErrors.php', 'r', true))) { fclose($pear2Exception); fclose($pear2Autoload); - throw new \pear2\Pyrus\Package\Exception('Cannot locate pear2/MultiErrors.php, please' . - ' pass in the path to the constructor'); + throw new Exception('Cannot locate pear2/MultiErrors.php, please' . + ' pass in the path to the constructor'); } if (!($pear2MultiErrorsException = @fopen('pear2/MultiErrors/Exception.php', 'r', true))) { fclose($pear2Exception); fclose($pear2Autoload); fclose($pear2MultiErrors); - throw new \pear2\Pyrus\Package\Exception('Cannot locate pear2/MultiErrors/Exception.php, please' . - ' pass in the path to the constructor'); + throw new Exception('Cannot locate pear2/MultiErrors/Exception.php, please' . + ' pass in the path to the constructor'); } } else { if ($a = realpath($pear2MultiErrorsPath)) { @@ -102,16 +100,15 @@ if (!($pear2MultiErrors = @fopen($pear2MultiErrorsPath . 'MultiErrors.php', 'r'))) { fclose($pear2Exception); fclose($pear2Autoload); - throw new \pear2\Pyrus\Package\Exception('Cannot locate pear2/MultiErrors.php' . - ' in ' . $pear2MultiErrorsPath . 'MultiErrors.php'); + throw new Exception('Cannot locate pear2/MultiErrors.php in ' . $pear2MultiErrorsPath . 'MultiErrors.php'); } if (!($pear2MultiErrorsException = @fopen($pear2MultiErrorsPath . 'MultiErrors/Exception.php', 'r'))) { fclose($pear2Exception); fclose($pear2Autoload); fclose($pear2MultiErrors); - throw new \pear2\Pyrus\Package\Exception('Cannot locate pear2/MultiErrors/Exception.php' . - ' in ' . $pear2MultiErrorsPath . 'MultiErrors/Exception.php'); + throw new Exception('Cannot locate pear2/MultiErrors/Exception.php' . + ' in ' . $pear2MultiErrorsPath . 'MultiErrors/Exception.php'); } } @@ -119,21 +116,19 @@ $this->_handles['php/pear2/MultiErrors.php'] = $pear2MultiErrors; $this->_handles['php/pear2/MultiErrors/Exception.php'] = $pear2MultiErrorsException; $this->_handles['php/pear2/Exception.php'] = $pear2Exception; - if ($creators instanceof \pear2\Pyrus\Package\ICreator) { + if ($creators instanceof ICreator) { $this->_creators = array($creators); } elseif (is_array($creators)) { foreach ($creators as $creator) { - if ($creator instanceof \pear2\Pyrus\Package\ICreator) { + if ($creator instanceof ICreator) { continue; } - throw new \pear2\Pyrus\Package\Creator\Exception('Invalid ' . - 'PEAR2 package creator passed into \pear2\Pyrus\Package\Creator'); + throw new Creator\Exception('Invalid PEAR2 package creator passed into \pear2\Pyrus\Package\Creator'); } $this->_creators = $creators; } else { - throw new \pear2\Pyrus\Package\Creator\Exception('Invalid ' . - 'PEAR2 package creator passed into \pear2\Pyrus\Package\Creator'); + throw new Creator\Exception('Invalid PEAR2 package creator passed into \pear2\Pyrus\Package\Creator'); } } @@ -184,7 +179,7 @@ $creator->addFile('package.xml', $old); } } - if ($package->getInternalPackage() instanceof \pear2\Pyrus\Package\Xml) { + if ($package->getInternalPackage() instanceof Xml) { // check for package_compatible.xml if ($package->isNewPackage() && file_exists($package->getFilePath('package_compatible.xml'))) { foreach ($this->_creators as $creator) { @@ -221,21 +216,19 @@ try { $role->packageTimeValidate($package, $info); } catch (\Exception $e) { - throw new \pear2\Pyrus\Package\Creator\Exception('Invalid file ' . - $packageat . ': ' . $e->getMessage(), $e); + throw new Creator\Exception('Invalid file ' . $packageat . ': ' . $e->getMessage(), $e); } $packageat = str_replace('\\', '/', $packageat); $packageat = str_replace('//', '/', $packageat); if ($packageat[0] === '/' || (strlen($packageat) > 2 && ($packageat[1] === ':' && $packageat[2] == '/'))) { - throw new \pear2\Pyrus\Package\Creator\Exception('Invalid path, cannot' . - ' save a root path ' . $packageat); + throw new Creator\Exception('Invalid path, cannot save a root path ' . $packageat); } if (preg_match('@^\.\.?/|/\.\.?\\z|/\.\./@', $packageat)) { - throw new \pear2\Pyrus\Package\Creator\Exception('Invalid path, cannot' . - ' use directory reference . or .. ' . $packageat); + throw new Creator\Exception('Invalid path, cannot use directory ' . + 'reference . or .. ' . $packageat); } $alreadyPackaged[$packageat] = true; @@ -266,9 +259,8 @@ } else { $version = null; } - foreach (new \pear2\Pyrus\Package\Creator\TaskIterator($info, $package, - \pear2\Pyrus\Task\Common::PACKAGE, - $version) as $task) { + foreach (new Creator\TaskIterator($info, $package, \pear2\Pyrus\Task\Common::PACKAGE, + $version) as $task) { // do pre-processing of file contents try { $task->startSession($fp, $packageat); @@ -353,24 +345,21 @@ $path = str_replace('//', '/', $path); if ($path[0] === '/' || (strlen($path) > 2 && ($path[1] === ':' && $path[2] == '/'))) { - throw new \pear2\Pyrus\Package\Creator\Exception('Invalid path, cannot' . - ' save a root path ' . $path); + throw new Creator\Exception('Invalid path, cannot save a root path ' . $path); } if (preg_match('@^\.\.?/|/\.\.?\\z|/\.\./@', $path)) { - throw new \pear2\Pyrus\Package\Creator\Exception('Invalid path, cannot' . - ' use directory reference . or .. ' . $path); + throw new Creator\Exception('Invalid path, cannot use directory ' . + 'reference . or .. ' . $path); } if (isset($alreadyPackaged[$path])) { - throw new \pear2\Pyrus\Package\Creator\Exception('Path ' . $path . - 'has already been added, and cannot be overwritten'); + throw new Creator\Exception('Path ' . $path . 'has already been added, and cannot be overwritten'); } $alreadyPackaged[$path] = true; if (!@file_exists($filename) || !($fp = @fopen($filename, 'rb'))) { - throw new \pear2\Pyrus\Package\Creator\Exception('Extra file ' . - $filename . ' does not exist or cannot be read'); + throw new Creator\Exception('Extra file ' . $filename . ' does not exist or cannot be read'); } foreach ($this->_creators as $creator) { Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Phar.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Phar.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Phar.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -37,13 +37,11 @@ { $package = realpath($package); if (!$package) { - throw new \pear2\Pyrus\Package\Phar\Exception( - 'Phar package ' . $package . ' does not exist'); + throw new Phar\Exception('Phar package ' . $package . ' does not exist'); } if (!class_exists('Phar')) { - throw new \pear2\Pyrus\Package\Phar\Exception( - 'Phar extension is not available'); + throw new Phar\Exception('Phar extension is not available'); } $this->archive = $package; @@ -60,8 +58,7 @@ } } } catch (\Exception $e) { - throw new \pear2\Pyrus\Package\Phar\Exception('Could not open Phar archive ' . - $package, $e); + throw new Phar\Exception('Could not open Phar archive ' . $package, $e); } $package = str_replace('\\', '/', $package); @@ -97,12 +94,12 @@ } } } - + if ($pxml === false) { - throw new \pear2\Pyrus\Package\Phar\Exception('No package.xml in archive'); + throw new Phar\Exception('No package.xml in archive'); } } catch (\Exception $e) { - throw new \pear2\Pyrus\Package\Phar\Exception('Could not extract Phar archive ' . + throw new Phar\Exception('Could not extract Phar archive ' . $package, $e); } @@ -118,8 +115,9 @@ function copyTo($where) { - copy($this->archive, $where . DIRECTORY_SEPARATOR . basename($this->archive)); - $this->archive = $where . DIRECTORY_SEPARATOR . basename($this->archive); + $location = $where . DIRECTORY_SEPARATOR . basename($this->archive); + copy($this->archive, $location); + $this->archive = $location; } function isNewPackage() @@ -130,17 +128,17 @@ function getFilePath($file) { if (!isset($this->packagefile->info->files[$file])) { - throw new \pear2\Pyrus\Package\Exception('file ' . $file . ' is not in package.xml'); + throw new Exception('file ' . $file . ' is not in package.xml'); } - + $phar_file = 'phar://' . str_replace('\\', '/', $this->archive) . '/' . $file; if (!file_exists($phar_file)) { $phar_file = 'phar://' . str_replace('\\', '/', $this->archive) . '/' . $this->packagefile->info->name . '-' . $this->packagefile->info->version['release'] . '/' . $file; - + } return $phar_file; } -} +} \ No newline at end of file Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Remote.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Remote.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Remote.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -150,13 +150,13 @@ $internal = $this->internal->download(); if ($internal->name != $this->name) { - throw new \pear2\Pyrus\Package\Exception('Invalid package downloaded, package name changed from ' . - $this->name . ' to ' . $internal->name); + throw new Exception('Invalid package downloaded, package name changed from ' . + $this->name . ' to ' . $internal->name); } if ($internal->channel != $this->channel) { - throw new \pear2\Pyrus\Package\Exception('SECURITY ERROR: package is claiming to be from ' . - 'channel ' . $internal->channel . ', but we are ' . - 'channel ' . $this->name); + throw new Exception('SECURITY ERROR: package is claiming to be from ' . + 'channel ' . $internal->channel . ', but we are ' . + 'channel ' . $this->name); } $internal->setFrom($this->internal); $this->internal = $internal; Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Tar.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Tar.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Tar.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -47,7 +47,7 @@ if ($this->_fp) { fclose($this->_fp); if (!function_exists('gzopen')) { - throw new \pear2\Pyrus\Package\Tar\Exception('Cannot extract package '. + throw new Tar\Exception('Cannot extract package '. $package . ', PHP must have the zlib extension enabled --with-zlib.'); } else { $this->_fp = gzopen($package, 'rb'); @@ -56,14 +56,14 @@ break; case 'tbz' : if (!in_array('bzip2.*', $streamfilters)) { - throw new \pear2\Pyrus\Package\Tar\Exception('Cannot open package' . + throw new Tar\Exception('Cannot open package' . $package . ', bzip2 decompression is not available'); } stream_filter_append($this->_fp, 'bzip2.decompress'); } if (!$this->_fp) { - throw new \pear2\Pyrus\Package\Tar\Exception('Cannot open package ' . $package); + throw new Tar\Exception('Cannot open package ' . $package); } $packagexml = $this->_extract(); @@ -118,13 +118,12 @@ function getFilePath($file) { if (!isset($this->packagefile->info->files[$file])) { - throw new \pear2\Pyrus\Package\Exception('file ' . $file . ' is not in package.xml'); + throw new Exception('file ' . $file . ' is not in package.xml'); } $extract = ''; if ($this->_BCpackage) { - // old fashioned PEAR 1.x packages put everything in Package-Version/ - // directory + // old fashioned PEAR 1.x packages put everything in Package-Version/ directory $extract = $this->packagefile->info->name . '-' . $this->packagefile->info->version['release']; } @@ -139,8 +138,7 @@ private function _processHeader($rawHeader) { if (strlen($rawHeader) < 512 || $rawHeader == pack("a512", "")) { - throw new \pear2\Pyrus\Package\Tar\Exception( - 'Error: "' . $this->archive . '" has corrupted tar header'); + throw new Tar\Exception('Error: "' . $this->archive . '" has corrupted tar header'); } $header = unpack( @@ -165,8 +163,7 @@ } if (strlen($rawHeader) != 512) { - throw new \pear2\Pyrus\Package\Tar\Exception( - 'Invalid block size : ' . strlen($rawHeader)); + throw new Tar\Exception('Invalid block size : ' . strlen($rawHeader)); } $header = $this->_processHeader($rawHeader); if ($header['type'] == 'L') { @@ -189,8 +186,7 @@ $rawHeader = $newHeader; } if ($this->_maliciousFilename($header['filename'])) { - throw new \pear2\Pyrus\Package\Tar\Exception('Malicious .tar detected, file "' . - $header['filename'] . + throw new Tar\Exception('Malicious .tar detected, file "' . $header['filename'] . '" will not install in desired directory tree'); } @@ -212,8 +208,7 @@ return true; } - throw new \pear2\Pyrus\Package\Tar\Exception( - 'Invalid checksum for header of file "' . $header['filename'] . + throw new Tar\Exception('Invalid checksum for header of file "' . $header['filename'] . '" : ' . $checksum . ' calculated, ' . $header['checksum'] . ' expected'); } @@ -257,9 +252,7 @@ { $packagexml = false; $where = (string) \pear2\Pyrus\Config::current()->temp_dir; - $where = str_replace('\\', '/', $where); - $where = str_replace('//', '/', $where); - $where = str_replace('/', DIRECTORY_SEPARATOR, $where); + $where = str_replace(array('\\', '//'), DIRECTORY_SEPARATOR, $where); if (!file_exists($where)) { mkdir($where, 0777, true); } @@ -279,9 +272,7 @@ $header = $this->_readHeader($header); $extract = $where . $header['filename']; - $extract = str_replace('\\', '/', $extract); - $extract = str_replace('//', '/', $extract); - $extract = str_replace('/', DIRECTORY_SEPARATOR, $extract); + $extract = str_replace(array('\\', '//'), DIRECTORY_SEPARATOR, $extract); self::_addTempFile($extract); if (!file_exists(dirname($extract))) { self::_addTempDirectory(dirname($extract)); @@ -291,9 +282,8 @@ $fp = fopen($extract, 'wb'); $amount = stream_copy_to_stream($this->_fp, $fp, $this->_internalFileLength); if ($amount != $this->_internalFileLength) { - throw new \pear2\Pyrus\Package\Tar\Exception( - 'Unable to fully extract ' . $header['filename'] . ' from ' . - $this->archive); + throw new Tar\Exception('Unable to fully extract ' . $header['filename'] . + ' from ' . $this->archive); } if ($this->_footerLength) { @@ -318,8 +308,7 @@ fclose($fp); fclose($this->_fp); if (!$packagexml) { - throw new \pear2\Pyrus\Package\Tar\Exception('Archive ' . $this->archive . - ' does not contain a package.xml file'); + throw new Tar\Exception('Archive ' . $this->archive . ' does not contain a package.xml file'); } return $packagexml; Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Xml.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Xml.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Xml.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -50,7 +50,7 @@ function copyTo($where) { - throw new \pear2\Pyrus\Package\Exception('download/copy not supported for extracted packages'); + throw new Exception('download/copy not supported for extracted packages'); } function getFilePath($file) Modified: pear2/Pyrus/trunk/src/Pyrus/Package/Zip.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Package/Zip.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Package/Zip.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -35,29 +35,24 @@ function __construct($package, \pear2\Pyrus\Package $parent) { if (!class_exists('ZIPArchive')) { - throw new \pear2\Pyrus\Package\Zip\Exception( - 'Zip extension is not available'); + throw new Zip\Exception('Zip extension is not available'); } $this->archive = $package; $zip = new ZIPArchive; if (true !== ($zip->open($package))) { - throw new \pear2\Pyrus\Package\Zip\Exception('Could not open ZIP archive ' . - $package); + throw new Zip\Exception('Could not open ZIP archive ' . $package); } if (false !== ($pxml = $zip->getNameIndex(0))) { if (!preg_match('/^package\-.+\-\\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?.xml$/', $pxml)) { - throw new \pear2\Pyrus\Package\Zip\Exception('First file in ZIP archive ' . - 'is not package.xml, cannot process'); + throw new Zip\Exception('First file in ZIP archive is not package.xml, cannot process'); } } $where = (string) \pear2\Pyrus\Config::current()->temp_dir; - $where = str_replace('\\', '/', $where); - $where = str_replace('//', '/', $where); - $where = str_replace('/', DIRECTORY_SEPARATOR, $where); + $where = str_replace(array('\\', '//'), DIRECTORY_SEPARATOR, $where); if (!file_exists($where)) { mkdir($where, 0777, true); } @@ -105,13 +100,11 @@ function getFilePath($file) { if (!isset($this->packagefile->info->files[$file])) { - throw new \pear2\Pyrus\Package\Exception('file ' . $file . ' is not in package.xml'); + throw new Exception('file ' . $file . ' is not in package.xml'); } $extract = $this->_tmpdir . DIRECTORY_SEPARATOR . $file; - $extract = str_replace('\\', '/', $extract); - $extract = str_replace('//', '/', $extract); - $extract = str_replace('/', DIRECTORY_SEPARATOR, $extract); + $extract = str_replace(array('\\', '//'), DIRECTORY_SEPARATOR, $extract); return $extract; } } Modified: pear2/Pyrus/trunk/src/Pyrus/Registry/Pear1.php =================================================================== --- pear2/Pyrus/trunk/src/Pyrus/Registry/Pear1.php 2009-12-30 17:22:42 UTC (rev 292816) +++ pear2/Pyrus/trunk/src/Pyrus/Registry/Pear1.php 2009-12-30 17:28:53 UTC (rev 292817) @@ -105,7 +105,7 @@ } $fp = fopen($this->filemap(), 'wb'); if (!$fp) { - throw new \pear2\Pyrus\Registry\Exception('Cannot write out Pear1 filemap'); + throw new Exception('Cannot write out Pear1 filemap'); } fwrite($fp, serialize($files)); @@ -120,7 +120,7 @@ $fp = @fopen($this->filemap(), 'r'); if (!$fp) { - throw new \pear2\Pyrus\Registry\Exception('Could not open Pear1 registry filemap "' . $this->filemap . '"'); + throw new Exception('Could not open Pear1 registry filemap "' . $this->filemap . '"'); } clearstatcache(); @@ -136,7 +136,7 @@ } $tmp = unserialize($data); if (!$tmp && $fsize > 7) { - throw new \pear2\Pyrus\Registry\Exception('Invalid Pear1 registry filemap data'); + throw new Exception('Invalid Pear1 registry filemap data'); } return $tmp; } @@ -154,9 +154,9 @@ { if ($this->intransaction) { return $this->atomic->getJournalPath(); - } else { - return $this->_path; } + + return $this->_path; } private function _namePath($channel, $package) @@ -342,8 +342,7 @@ public function info($package, $channel, $field) { if (!$this->exists($package, $channel)) { - throw new \pear2\Pyrus\Registry\Exception('Unknown package ' . $channel . - '/' . $package); + throw new Exception('Unknown package ' . $channel . '/' . $package); } $pf = $this->toPackageFile($package, $channel); @@ -358,15 +357,14 @@ if ($field == 'installedfiles' || $field == 'dirtree') { $packagefile = $this->_namePath($channel, $package) . '.reg'; if (!$packagefile || !isset($packagefile[0])) { - throw new \pear2\Pyrus\Registry\Exception('Cannot find registry for package ' . - $channel . '/' . $package); + throw new Exception('Cannot find registry for package ' . $channel . '/' . $package); } $packagecontents = file_get_contents($packagefile); $data = @unserialize($packagecontents); if ($data === false) { - throw new \pear2\Pyrus\Registry\Exception('Cannot retrieve package file object ' . - 'for package ' . $channel . '/' . $package . ', PEAR 1.x registry file might be corrupt!'); + throw new Exception('Cannot retrieve package file object for package ' . + $channel . '/' . $package . ', PEAR 1.x registry file might be corrupt!'); } if ($field == 'dirtree') { $ret = $data['filelist']['dirtree']; @@ -427,8 +425,7 @@ } } } catch (\Exception $e) { - throw new \pear2\Pyrus\Registry\Exception('Could not open channel directory for ' . - 'channel ' . $channel, $e); + throw new Exception('Could not open channel directory for channel ' . $channel, $e); } return $ret; } @@ -436,26 +433,24 @@ public function toPackageFile($package, $channel) { if (!$this->exists($package, $channel)) { - throw new \pear2\Pyrus\Registry\Exception('Cannot retrieve package file object ' . - 'for package ' . $channel . '/' . $package . ', it is not installed'); + throw new Exception('Cannot retrieve package file object for package ' . + $channel . '/' . $package . ', it is not installed'); } $packagefile = $this->_nameRegistryPath(null, $channel, $package); if (!$packagefile) { - throw new \pear2\Pyrus\Registry\Exception('Cannot find registry for package ' . - $channel . '/' . $package); + throw new Exception('Cannot find registry for package ' . $channel . '/' . $package); } $contents = file_get_contents($packagefile); if (!$contents) { - throw new \pear2\Pyrus\Registry\Exception('Cannot find registry for package ' . - $channel . '/' . $package); + throw new Exception('Cannot find registry for package ' . $channel . '/' . $package); } $data = @unserialize($contents); if ($data === false) { - throw new \pear2\Pyrus\Registry\Exception('Cannot retrieve package file object ' . - 'for package ' . $channel . '/' . $package . ', PEAR 1.x registry file might be corrupt!'); + throw new Exception('Cannot retrieve package file object for package ' . + $channel . '/' . $package . ', PEAR 1.x registry file might be corrupt!'); } if (isset($data['xsdversion']) && $data['xsdversion'] == '1.0' @@ -590,7 +585,7 @@ try { \pear2\Pyrus\AtomicFileTransaction::rmrf(realpath($path . DIRECTORY_SEPARATOR . '.registry')); } catch (\pear2\Pyrus\AtomicFileTransaction\Exception $e) { - throw new \pear2\Pyrus\Registry\Exception('Cannot remove Pear1 registry: ' . $e->getMessage(), $e); + throw new Exception('Cannot remove Pear1 registry: ' . $e->getMessage(), $e); } $errs = new \pear2\MultiErrors; try { @@ -598,17 +593,16 @@ \pear2\Pyrus\AtomicFileTransaction::rmrf(realpath($path . DIRECTORY_SEPARATOR . '.channels')); } } catch (\pear2\Pyrus\AtomicFileTransaction\Exception $e) { - $errs->E_ERROR[] = new \pear2\Pyrus\Registry\Exception('Cannot remove Pear1 registry: ' . $e->getMessage(), $e); + $errs->E_ERROR[] = new Exception('Cannot remove Pear1 registry: ' . $e->getMessage(), $e); } foreach (array('.filemap', '.lock', '.depdb', '.depdblock') as $file) { if (file_exists($path . DIRECTORY_SEPARATOR . $file) && !@unlink(realpath($path . DIRECTORY_SEPARATOR . $file))) { - $errs->E_ERROR[] = new \pear2\Pyrus\Registry\Exception( - 'Cannot remove Pear1 registry: Unable to remove ' . $file); + $errs->E_ERROR[] = new Exception('Cannot remove Pear1 registry: Unable to remove ' . $file); } } if (count($errs->E_ERROR)) { - throw new \pear2\Pyrus\Registry\Exception('Unable to remove Pear1 registry', $errs); + throw new Exception('Unable to remove Pear1 registry', $errs); } } @@ -618,8 +612,7 @@ return; } if (!\pear2\Pyrus\AtomicFileTransaction::inTransaction()) { - throw new \pear2\Pyrus\Registry\Exception( - 'internal error: file transaction must be started before registry transaction'); + throw new Exception('internal error: file transaction must be started before registry transaction'); } $this->atomic = \pear2\Pyrus\AtomicFileTransaction::getTransactionObject( $this->_path);