cvs: pear-core /PEAR Downloader.php
| From: | Helgi �ormar �orbj�rnsson | Date: | Tue, 24 Jun 2008 22:03:59 +0000 |
| Subject: | cvs: pear-core /PEAR Downloader.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-7610@lists.php.net to get a copy of this message | ||
dufuz Tue Jun 24 22:03:59 2008 UTC
Modified files:
/pear-core/PEAR Downloader.php
Log:
Cosmetics, doesn't touch code logic
http://cvs.php.net/viewvc.cgi/pear-core/PEAR/Downloader.php?r1=1.138&r2=1.139&diff_format=u Index: pear-core/PEAR/Downloader.php diff -u pear-core/PEAR/Downloader.php:1.138 pear-core/PEAR/Downloader.php:1.139 --- pear-core/PEAR/Downloader.php:1.138 Fri Apr 11 01:16:40 2008 +++ pear-core/PEAR/Downloader.php Tue Jun 24 22:03:59 2008 @@ -18,7 +18,7 @@ * @author Martin Jansen <mj@php.net> * @copyright 1997-2008 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Downloader.php,v 1.138 2008/04/11 01:16:40 dufuz Exp $ + * @version CVS: $Id: Downloader.php,v 1.139 2008/06/24 22:03:59 dufuz Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.3.0 */ @@ -266,12 +266,15 @@ $a = array(); return $a; } + if (!isset($this->_registry)) { $this->_registry = &$this->config->getRegistry(); } + if (!isset($this->_remote)) { $this->_remote = &$this->config->getRemote(); } + $channelschecked = array(); // convert all parameters into PEAR_Downloader_Package objects foreach ($params as $i => $param) { @@ -283,10 +286,12 @@ // skip parameters that were missed by preferred_state continue; } + if (PEAR::isError($err)) { if (!isset($this->_options['soft'])) { $this->log(0, $err->getMessage()); } + $params[$i] = false; if (is_object($param)) { $param = $param->getChannel() . '/' . $param->getPackage(); @@ -296,8 +301,7 @@ } else { do { if ($params[$i] && $params[$i]->getType() == 'local') { - // bug #7090 - // skip channel.xml check for local packages + // bug #7090 skip channel.xml check for local packages break; } if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && @@ -307,15 +311,18 @@ if (!class_exists('System')) { require_once 'System.php'; } + $curchannel = &$this->_registry->getChannel($params[$i]->getChannel()); if (PEAR::isError($curchannel)) { PEAR::staticPopErrorHandling(); return $this->raiseError($curchannel); } + if (PEAR::isError($dir = $this->getDownloadDir())) { PEAR::staticPopErrorHandling(); break; } + $mirror = $this->config->get('preferred_mirror', null, $params[$i]->getChannel()); $a = $this->downloadHttp('http://' . $mirror . @@ -330,6 +337,7 @@ '" to update'); } } while (false); + if ($params[$i] && !isset($this->_options['downloadonly'])) { if (isset($this->_options['packagingroot'])) { $checkdir = $this->_prependPath( @@ -339,12 +347,15 @@ $checkdir = $this->config->get('php_dir', null, $params[$i]->getChannel()); } + while ($checkdir && $checkdir != '/' && !file_exists($checkdir)) { $checkdir = dirname($checkdir); } + if ($checkdir == '.') { $checkdir = '/'; } + if (!is_writeable($checkdir)) { return PEAR::raiseError('Cannot install, php_dir for channel "' . $params[$i]->getChannel() . '" is not writeable by the current user'); @@ -352,12 +363,14 @@ } } } + unset($channelschecked); PEAR_Downloader_Package::removeDuplicates($params); if (!count($params)) { $a = array(); return $a; } + if (!isset($this->_options['nodeps']) && !isset($this->_options['offline'])) { $reverify = true; while ($reverify) { @@ -379,13 +392,16 @@ } } } + if (isset($this->_options['offline'])) { $this->log(3, 'Skipping dependency download check, --offline specified'); } + if (!count($params)) { $a = array(); return $a; } + while (PEAR_Downloader_Package::mergeDependencies($params)); PEAR_Downloader_Package::removeDuplicates($params, true); $errorparams = array(); @@ -399,12 +415,14 @@ return $a; } } + PEAR_Downloader_Package::removeInstalled($params); if (!count($params)) { $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED); $a = array(); return $a; } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $err = $this->analyzeDependencies($params); PEAR::popErrorHandling(); @@ -413,11 +431,13 @@ $a = array(); return $a; } + $ret = array(); $newparams = array(); if (isset($this->_options['pretend'])) { return $params; } + $somefailed = false; foreach ($params as $i => $package) { PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); @@ -435,10 +455,13 @@ continue; } $newparams[] = &$params[$i]; - $ret[] = array('file' => $pf->getArchiveFile(), - 'info' => &$pf, - 'pkg' => $pf->getPackage()); + $ret[] = array( + 'file' => $pf->getArchiveFile(), + 'info' => &$pf, + 'pkg' => $pf->getPackage() + ); } + if ($somefailed) { // remove params that did not download successfully PEAR::pushErrorHandling(PEAR_ERROR_RETURN); @@ -450,6 +473,7 @@ return $a; } } + $this->_downloadedPackages = $ret; return $newparams; } @@ -463,8 +487,9 @@ if (isset($this->_options['downloadonly'])) { return; } + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - $redo = true; + $redo = true; $reset = false; while ($redo) { $redo = false; @@ -478,24 +503,27 @@ } else { $send = $param->getPackageFile(); } + $installcheck = $depchecker->validatePackage($send, $this, $params); if (PEAR::isError($installcheck)) { if (!isset($this->_options['soft'])) { $this->log(0, $installcheck->getMessage()); } - $hasfailed = true; + $hasfailed = true; $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; + $reset = true; + $redo = true; + $failed = false; PEAR_Downloader_Package::removeDuplicates($params); continue 2; } continue; } + if (!$reset && $param->alreadyValidated() && !$force) { continue; } + if (count($deps)) { $depchecker = &$this->getDependency2Object($this->config, $this->getOptions(), $param->getParsedPackage(), PEAR_VALIDATE_DOWNLOADING); @@ -504,19 +532,21 @@ } else { $send = $param->getPackageFile(); } + $installcheck = $depchecker->validatePackage($send, $this, $params); if (PEAR::isError($installcheck)) { if (!isset($this->_options['soft'])) { $this->log(0, $installcheck->getMessage()); } - $hasfailed = true; + $hasfailed = true; $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; + $reset = true; + $redo = true; + $failed = false; PEAR_Downloader_Package::removeDuplicates($params); continue 2; } + $failed = false; if (isset($deps['required'])) { foreach ($deps['required'] as $type => $dep) { @@ -551,6 +581,7 @@ } } } + if (isset($deps['optional'])) { foreach ($deps['optional'] as $type => $dep) { if (!isset($dep[0])) { @@ -584,11 +615,13 @@ } } } + $groupname = $param->getGroup(); if (isset($deps['group']) && $groupname) { if (!isset($deps['group'][0])) { $deps['group'] = array($deps['group']); } + $found = false; foreach ($deps['group'] as $group) { if ($group['attribs']['name'] == $groupname) { @@ -596,6 +629,7 @@ break; } } + if ($found) { unset($group['attribs']); foreach ($group as $type => $dep) { @@ -647,12 +681,13 @@ } $params[$i]->setValidated(); } + if ($failed) { - $hasfailed = true; + $hasfailed = true; $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; + $reset = true; + $redo = true; + $failed = false; PEAR_Downloader_Package::removeDuplicates($params); continue 2; }
http://cvs.php.net/viewvc.cgi/pear-core/PEAR/Downloader.php?r1=1.138&r2=1.139&diff_format=u Index: pear-core/PEAR/Downloader.php diff -u pear-core/PEAR/Downloader.php:1.138 pear-core/PEAR/Downloader.php:1.139 --- pear-core/PEAR/Downloader.php:1.138 Fri Apr 11 01:16:40 2008 +++ pear-core/PEAR/Downloader.php Tue Jun 24 22:03:59 2008 @@ -18,7 +18,7 @@ * @author Martin Jansen <mj@php.net> * @copyright 1997-2008 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Downloader.php,v 1.138 2008/04/11 01:16:40 dufuz Exp $ + * @version CVS: $Id: Downloader.php,v 1.139 2008/06/24 22:03:59 dufuz Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.3.0 */ @@ -266,12 +266,15 @@ $a = array(); return $a; } + if (!isset($this->_registry)) { $this->_registry = &$this->config->getRegistry(); } + if (!isset($this->_remote)) { $this->_remote = &$this->config->getRemote(); } + $channelschecked = array(); // convert all parameters into PEAR_Downloader_Package objects foreach ($params as $i => $param) { @@ -283,10 +286,12 @@ // skip parameters that were missed by preferred_state continue; } + if (PEAR::isError($err)) { if (!isset($this->_options['soft'])) { $this->log(0, $err->getMessage()); } + $params[$i] = false; if (is_object($param)) { $param = $param->getChannel() . '/' . $param->getPackage(); @@ -296,8 +301,7 @@ } else { do { if ($params[$i] && $params[$i]->getType() == 'local') { - // bug #7090 - // skip channel.xml check for local packages + // bug #7090 skip channel.xml check for local packages break; } if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && @@ -307,15 +311,18 @@ if (!class_exists('System')) { require_once 'System.php'; } + $curchannel = &$this->_registry->getChannel($params[$i]->getChannel()); if (PEAR::isError($curchannel)) { PEAR::staticPopErrorHandling(); return $this->raiseError($curchannel); } + if (PEAR::isError($dir = $this->getDownloadDir())) { PEAR::staticPopErrorHandling(); break; } + $mirror = $this->config->get('preferred_mirror', null, $params[$i]->getChannel()); $a = $this->downloadHttp('http://' . $mirror . @@ -330,6 +337,7 @@ '" to update'); } } while (false); + if ($params[$i] && !isset($this->_options['downloadonly'])) { if (isset($this->_options['packagingroot'])) { $checkdir = $this->_prependPath( @@ -339,12 +347,15 @@ $checkdir = $this->config->get('php_dir', null, $params[$i]->getChannel()); } + while ($checkdir && $checkdir != '/' && !file_exists($checkdir)) { $checkdir = dirname($checkdir); } + if ($checkdir == '.') { $checkdir = '/'; } + if (!is_writeable($checkdir)) { return PEAR::raiseError('Cannot install, php_dir for channel "' . $params[$i]->getChannel() . '" is not writeable by the current user'); @@ -352,12 +363,14 @@ } } } + unset($channelschecked); PEAR_Downloader_Package::removeDuplicates($params); if (!count($params)) { $a = array(); return $a; } + if (!isset($this->_options['nodeps']) && !isset($this->_options['offline'])) { $reverify = true; while ($reverify) { @@ -379,13 +392,16 @@ } } } + if (isset($this->_options['offline'])) { $this->log(3, 'Skipping dependency download check, --offline specified'); } + if (!count($params)) { $a = array(); return $a; } + while (PEAR_Downloader_Package::mergeDependencies($params)); PEAR_Downloader_Package::removeDuplicates($params, true); $errorparams = array(); @@ -399,12 +415,14 @@ return $a; } } + PEAR_Downloader_Package::removeInstalled($params); if (!count($params)) { $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED); $a = array(); return $a; } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $err = $this->analyzeDependencies($params); PEAR::popErrorHandling(); @@ -413,11 +431,13 @@ $a = array(); return $a; } + $ret = array(); $newparams = array(); if (isset($this->_options['pretend'])) { return $params; } + $somefailed = false; foreach ($params as $i => $package) { PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); @@ -435,10 +455,13 @@ continue; } $newparams[] = &$params[$i]; - $ret[] = array('file' => $pf->getArchiveFile(), - 'info' => &$pf, - 'pkg' => $pf->getPackage()); + $ret[] = array( + 'file' => $pf->getArchiveFile(), + 'info' => &$pf, + 'pkg' => $pf->getPackage() + ); } + if ($somefailed) { // remove params that did not download successfully PEAR::pushErrorHandling(PEAR_ERROR_RETURN); @@ -450,6 +473,7 @@ return $a; } } + $this->_downloadedPackages = $ret; return $newparams; } @@ -463,8 +487,9 @@ if (isset($this->_options['downloadonly'])) { return; } + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - $redo = true; + $redo = true; $reset = false; while ($redo) { $redo = false; @@ -478,24 +503,27 @@ } else { $send = $param->getPackageFile(); } + $installcheck = $depchecker->validatePackage($send, $this, $params); if (PEAR::isError($installcheck)) { if (!isset($this->_options['soft'])) { $this->log(0, $installcheck->getMessage()); } - $hasfailed = true; + $hasfailed = true; $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; + $reset = true; + $redo = true; + $failed = false; PEAR_Downloader_Package::removeDuplicates($params); continue 2; } continue; } + if (!$reset && $param->alreadyValidated() && !$force) { continue; } + if (count($deps)) { $depchecker = &$this->getDependency2Object($this->config, $this->getOptions(), $param->getParsedPackage(), PEAR_VALIDATE_DOWNLOADING); @@ -504,19 +532,21 @@ } else { $send = $param->getPackageFile(); } + $installcheck = $depchecker->validatePackage($send, $this, $params); if (PEAR::isError($installcheck)) { if (!isset($this->_options['soft'])) { $this->log(0, $installcheck->getMessage()); } - $hasfailed = true; + $hasfailed = true; $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; + $reset = true; + $redo = true; + $failed = false; PEAR_Downloader_Package::removeDuplicates($params); continue 2; } + $failed = false; if (isset($deps['required'])) { foreach ($deps['required'] as $type => $dep) { @@ -551,6 +581,7 @@ } } } + if (isset($deps['optional'])) { foreach ($deps['optional'] as $type => $dep) { if (!isset($dep[0])) { @@ -584,11 +615,13 @@ } } } + $groupname = $param->getGroup(); if (isset($deps['group']) && $groupname) { if (!isset($deps['group'][0])) { $deps['group'] = array($deps['group']); } + $found = false; foreach ($deps['group'] as $group) { if ($group['attribs']['name'] == $groupname) { @@ -596,6 +629,7 @@ break; } } + if ($found) { unset($group['attribs']); foreach ($group as $type => $dep) { @@ -647,12 +681,13 @@ } $params[$i]->setValidated(); } + if ($failed) { - $hasfailed = true; + $hasfailed = true; $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; + $reset = true; + $redo = true; + $failed = false; PEAR_Downloader_Package::removeDuplicates($params); continue 2; }