Subversion Repositories Applications.gtt

Compare Revisions

Ignore whitespace Rev 186 → Rev 187

/trunk/bibliotheque/pear/PEAR/Downloader/Package.php
4,21 → 4,15
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: Package.php,v 1.104 2007/01/14 21:11:54 cellog Exp $
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
 
/**
* Error code when parameter initialization fails because no releases
* exist within preferred_state, but releases do exist
25,6 → 19,12
*/
define('PEAR_DOWNLOADER_PACKAGE_STATE', -1003);
/**
* Error code when parameter initialization fails because no releases
* exist that will work with the existing PHP version
*/
define('PEAR_DOWNLOADER_PACKAGE_PHPVERSION', -1004);
 
/**
* Coordinates download parameters and manages their dependencies
* prior to downloading them.
*
47,9 → 47,9
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 1.5.1
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
110,7 → 110,7
*/
var $_explicitGroup = false;
/**
* Package type local|url|xmlrpc
* Package type local|url
* @var string
*/
var $_type;
129,7 → 129,7
/**
* @param PEAR_Downloader
*/
function PEAR_Downloader_Package(&$downloader)
function __construct(&$downloader)
{
$this->_downloader = &$downloader;
$this->_config = &$this->_downloader->config;
157,67 → 157,87
function initialize($param)
{
$origErr = $this->_fromFile($param);
if (!$this->_valid) {
$options = $this->_downloader->getOptions();
if (isset($options['offline'])) {
if (PEAR::isError($origErr)) {
if (!isset($options['soft'])) {
$this->_downloader->log(0, $origErr->getMessage());
if ($this->_valid) {
return true;
}
 
$options = $this->_downloader->getOptions();
if (isset($options['offline'])) {
if (PEAR::isError($origErr) && !isset($options['soft'])) {
foreach ($origErr->getUserInfo() as $userInfo) {
if (isset($userInfo['message'])) {
$this->_downloader->log(0, $userInfo['message']);
}
}
return PEAR::raiseError('Cannot download non-local package "' . $param . '"');
 
$this->_downloader->log(0, $origErr->getMessage());
}
$err = $this->_fromUrl($param);
 
return PEAR::raiseError('Cannot download non-local package "' . $param . '"');
}
 
$err = $this->_fromUrl($param);
if (PEAR::isError($err) || !$this->_valid) {
if ($this->_type == 'url') {
if (PEAR::isError($err) && !isset($options['soft'])) {
$this->_downloader->log(0, $err->getMessage());
}
 
return PEAR::raiseError("Invalid or missing remote package file");
}
 
$err = $this->_fromString($param);
if (PEAR::isError($err) || !$this->_valid) {
if ($this->_type == 'url') {
if (PEAR::isError($err)) {
if (!isset($options['soft'])) {
$this->_downloader->log(0, $err->getMessage());
}
}
return PEAR::raiseError("Invalid or missing remote package file");
if (PEAR::isError($err) && $err->getCode() == PEAR_DOWNLOADER_PACKAGE_STATE) {
return false; // instruct the downloader to silently skip
}
$err = $this->_fromString($param);
if (PEAR::isError($err) || !$this->_valid) {
if (PEAR::isError($err) &&
$err->getCode() == PEAR_DOWNLOADER_PACKAGE_STATE) {
return false; // instruct the downloader to silently skip
}
if (isset($this->_type) && $this->_type == 'local' &&
PEAR::isError($origErr)) {
if (is_array($origErr->getUserInfo())) {
foreach ($origErr->getUserInfo() as $err) {
if (is_array($err)) {
$err = $err['message'];
}
if (!isset($options['soft'])) {
$this->_downloader->log(0, $err);
}
 
if (isset($this->_type) && $this->_type == 'local' && PEAR::isError($origErr)) {
if (is_array($origErr->getUserInfo())) {
foreach ($origErr->getUserInfo() as $err) {
if (is_array($err)) {
$err = $err['message'];
}
 
if (!isset($options['soft'])) {
$this->_downloader->log(0, $err);
}
}
if (!isset($options['soft'])) {
$this->_downloader->log(0, $origErr->getMessage());
}
if (is_array($param)) {
$param = $this->_registry->parsedPackageNameToString($param,
true);
}
return PEAR::raiseError(
"Cannot initialize '$param', invalid or missing package file");
}
if (PEAR::isError($err)) {
if (!isset($options['soft'])) {
$this->_downloader->log(0, $err->getMessage());
}
 
if (!isset($options['soft'])) {
$this->_downloader->log(0, $origErr->getMessage());
}
 
if (is_array($param)) {
$param = $this->_registry->parsedPackageNameToString($param, true);
}
return PEAR::raiseError(
"Cannot initialize '$param', invalid or missing package file");
 
if (!isset($options['soft'])) {
$this->_downloader->log(2, "Cannot initialize '$param', invalid or missing package file");
}
 
// Passing no message back - already logged above
return PEAR::raiseError();
}
 
if (PEAR::isError($err) && !isset($options['soft'])) {
$this->_downloader->log(0, $err->getMessage());
}
 
if (is_array($param)) {
$param = $this->_registry->parsedPackageNameToString($param, true);
}
 
if (!isset($options['soft'])) {
$this->_downloader->log(2, "Cannot initialize '$param', invalid or missing package file");
}
 
// Passing no message back - already logged above
return PEAR::raiseError();
}
}
 
return true;
}
 
230,6 → 250,7
if (isset($this->_packagefile)) {
return $this->_packagefile;
}
 
if (isset($this->_downloadURL['url'])) {
$this->_isvalid = false;
$info = $this->getParsedPackage();
236,6 → 257,7
foreach ($info as $i => $p) {
$info[$i] = strtolower($p);
}
 
$err = $this->_fromUrl($this->_downloadURL['url'],
$this->_registry->parsedPackageNameToString($this->_parsedname, true));
$newinfo = $this->getParsedPackage();
242,15 → 264,24
foreach ($newinfo as $i => $p) {
$newinfo[$i] = strtolower($p);
}
 
if ($info != $newinfo) {
do {
if ($info['package'] == 'pecl.php.net' && $newinfo['package'] == 'pear.php.net') {
$info['package'] = 'pear.php.net';
if ($info['channel'] == 'pecl.php.net' && $newinfo['channel'] == 'pear.php.net') {
$info['channel'] = 'pear.php.net';
if ($info == $newinfo) {
// skip the channel check if a pecl package says it's a PEAR package
break;
}
}
if ($info['channel'] == 'pear.php.net' && $newinfo['channel'] == 'pecl.php.net') {
$info['channel'] = 'pecl.php.net';
if ($info == $newinfo) {
// skip the channel check if a pecl package says it's a PEAR package
break;
}
}
 
return PEAR::raiseError('CRITICAL ERROR: We are ' .
$this->_registry->parsedPackageNameToString($info) . ', but the file ' .
'downloaded claims to be ' .
257,10 → 288,12
$this->_registry->parsedPackageNameToString($this->getParsedPackage()));
} while (false);
}
 
if (PEAR::isError($err) || !$this->_valid) {
return $err;
}
}
 
$this->_type = 'local';
return $this->_packagefile;
}
275,7 → 308,7
return $this->_downloader;
}
 
function getType()
function getType()
{
return $this->_type;
}
293,6 → 326,7
} else {
$ext = '.tgz';
}
 
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$err = $this->_fromUrl($dep['uri'] . $ext);
PEAR::popErrorHandling();
300,6 → 334,7
if (!isset($options['soft'])) {
$this->_downloader->log(0, $err->getMessage());
}
 
return PEAR::raiseError('Invalid uri dependency "' . $dep['uri'] . $ext . '", ' .
'cannot download');
}
314,6 → 349,7
$this->_parsedname['group'] = 'default'; // download the default dependency group
$this->_explicitGroup = false;
}
 
$this->_rawpackagefile = $dep['raw'];
}
}
324,23 → 360,27
if (isset($options['downloadonly'])) {
return;
}
 
if (isset($options['offline'])) {
$this->_downloader->log(3, 'Skipping dependency download check, --offline specified');
return;
}
 
$pname = $this->getParsedPackage();
if (!$pname) {
return;
}
 
$deps = $this->getDeps();
if (!$deps) {
return;
}
 
if (isset($deps['required'])) { // package.xml 2.0
return $this->_detect2($deps, $pname, $options, $params);
} else {
return $this->_detect1($deps, $pname, $options, $params);
}
 
return $this->_detect1($deps, $pname, $options, $params);
}
 
function setValidated()
356,22 → 396,24
/**
* Remove packages to be downloaded that are already installed
* @param array of PEAR_Downloader_Package objects
* @static
*/
function removeInstalled(&$params)
public static function removeInstalled(&$params)
{
if (!isset($params[0])) {
return;
}
 
$options = $params[0]->_downloader->getOptions();
if (!isset($options['downloadonly'])) {
foreach ($params as $i => $param) {
$package = $param->getPackage();
$channel = $param->getChannel();
// remove self if already installed with this version
// this does not need any pecl magic - we only remove exact matches
if ($param->_installRegistry->packageExists($param->getPackage(), $param->getChannel())) {
if (version_compare($param->_installRegistry->packageInfo($param->getPackage(), 'version',
$param->getChannel()), $param->getVersion(), '==')) {
if (!isset($options['force'])) {
if ($param->_installRegistry->packageExists($package, $channel)) {
$packageVersion = $param->_installRegistry->packageInfo($package, 'version', $channel);
if (version_compare($packageVersion, $param->getVersion(), '==')) {
if (!isset($options['force']) && !isset($options['packagingroot'])) {
$info = $param->getParsedPackage();
unset($info['version']);
unset($info['state']);
378,25 → 420,22
if (!isset($options['soft'])) {
$param->_downloader->log(1, 'Skipping package "' .
$param->getShortName() .
'", already installed as version ' .
$param->_installRegistry->packageInfo($param->getPackage(),
'version', $param->getChannel()));
'", already installed as version ' . $packageVersion);
}
$params[$i] = false;
}
} elseif (!isset($options['force']) && !isset($options['upgrade']) &&
!isset($options['soft'])) {
!isset($options['soft']) && !isset($options['packagingroot'])) {
$info = $param->getParsedPackage();
$param->_downloader->log(1, 'Skipping package "' .
$param->getShortName() .
'", already installed as version ' .
$param->_installRegistry->packageInfo($param->getPackage(), 'version',
$param->getChannel()));
'", already installed as version ' . $packageVersion);
$params[$i] = false;
}
}
}
}
 
PEAR_Downloader_Package::removeDuplicates($params);
}
 
416,6 → 455,8
$ret = $this->_detect2Dep($dep, $pname, 'required', $params);
if (is_array($ret)) {
$this->_downloadDeps[] = $ret;
} elseif (PEAR::isError($ret) && !isset($options['soft'])) {
$this->_downloader->log(0, $ret->getMessage());
}
}
} else {
425,10 → 466,13
$ret = $this->_detect2Dep($dep, $pname, 'required', $params);
if (is_array($ret)) {
$this->_downloadDeps[] = $ret;
} elseif (PEAR::isError($ret) && !isset($options['soft'])) {
$this->_downloader->log(0, $ret->getMessage());
}
}
}
}
 
// get optional dependency group, if any
if (isset($deps['optional'][$packagetype])) {
$skipnames = array();
435,6 → 479,7
if (!isset($deps['optional'][$packagetype][0])) {
$deps['optional'][$packagetype] = array($deps['optional'][$packagetype]);
}
 
foreach ($deps['optional'][$packagetype] as $dep) {
$skip = false;
if (!isset($options['alldeps'])) {
451,7 → 496,13
$skip = true;
unset($dep['package']);
}
if (!($ret = $this->_detect2Dep($dep, $pname, 'optional', $params))) {
 
$ret = $this->_detect2Dep($dep, $pname, 'optional', $params);
if (PEAR::isError($ret) && !isset($options['soft'])) {
$this->_downloader->log(0, $ret->getMessage());
}
 
if (!$ret) {
$dep['package'] = $dep['name'];
$skip = count($skipnames) ?
$skipnames[count($skipnames) - 1] : '';
460,10 → 511,12
array_pop($skipnames);
}
}
 
if (!$skip && is_array($ret)) {
$this->_downloadDeps[] = $ret;
}
}
 
if (count($skipnames)) {
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'Did not download optional dependencies: ' .
472,19 → 525,22
}
}
}
 
// get requested dependency group, if any
$groupname = $this->getGroup();
$explicit = $this->_explicitGroup;
$explicit = $this->_explicitGroup;
if (!$groupname) {
if ($this->canDefault()) {
$groupname = 'default'; // try the default dependency group
} else {
if (!$this->canDefault()) {
continue;
}
 
$groupname = 'default'; // try the default dependency group
}
 
if ($groupnotfound) {
continue;
}
 
if (isset($deps['group'])) {
if (isset($deps['group']['attribs'])) {
if (strtolower($deps['group']['attribs']['name']) == strtolower($groupname)) {
495,6 → 551,7
$this->_registry->parsedPackageNameToString($pname, true) .
'" has no dependency ' . 'group named "' . $groupname . '"');
}
 
$groupnotfound = true;
continue;
}
506,6 → 563,7
break;
}
}
 
if (!$found) {
if ($explicit) {
if (!isset($options['soft'])) {
514,29 → 572,33
'" has no dependency ' . 'group named "' . $groupname . '"');
}
}
 
$groupnotfound = true;
continue;
}
}
}
if (isset($group)) {
if (isset($group[$packagetype])) {
if (isset($group[$packagetype][0])) {
foreach ($group[$packagetype] as $dep) {
$ret = $this->_detect2Dep($dep, $pname, 'dependency group "' .
$group['attribs']['name'] . '"', $params);
if (is_array($ret)) {
$this->_downloadDeps[] = $ret;
}
}
} else {
$ret = $this->_detect2Dep($group[$packagetype], $pname,
'dependency group "' .
 
if (isset($group) && isset($group[$packagetype])) {
if (isset($group[$packagetype][0])) {
foreach ($group[$packagetype] as $dep) {
$ret = $this->_detect2Dep($dep, $pname, 'dependency group "' .
$group['attribs']['name'] . '"', $params);
if (is_array($ret)) {
$this->_downloadDeps[] = $ret;
} elseif (PEAR::isError($ret) && !isset($options['soft'])) {
$this->_downloader->log(0, $ret->getMessage());
}
}
} else {
$ret = $this->_detect2Dep($group[$packagetype], $pname,
'dependency group "' .
$group['attribs']['name'] . '"', $params);
if (is_array($ret)) {
$this->_downloadDeps[] = $ret;
} elseif (PEAR::isError($ret) && !isset($options['soft'])) {
$this->_downloader->log(0, $ret->getMessage());
}
}
}
}
547,10 → 609,12
if (isset($dep['conflicts'])) {
return true;
}
 
$options = $this->_downloader->getOptions();
if (isset($dep['uri'])) {
return array('uri' => $dep['uri'], 'dep' => $dep);;
}
 
$testdep = $dep;
$testdep['package'] = $dep['name'];
if (PEAR_Downloader_Package::willDownload($testdep, $params)) {
563,17 → 627,19
}
return false;
}
 
$options = $this->_downloader->getOptions();
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if ($this->_explicitState) {
$pname['state'] = $this->_explicitState;
}
$url =
$this->_downloader->_getDepPackageDownloadUrl($dep, $pname);
 
$url = $this->_downloader->_getDepPackageDownloadUrl($dep, $pname);
if (PEAR::isError($url)) {
PEAR::popErrorHandling();
return $url;
}
 
$dep['package'] = $dep['name'];
$ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params, $group == 'optional' &&
!isset($options['alldeps']), true);
582,34 → 648,38
if (!isset($options['soft'])) {
$this->_downloader->log(0, $ret->getMessage());
}
 
return false;
}
 
// check to see if a dep is already installed and is the same or newer
if (!isset($dep['min']) && !isset($dep['max']) && !isset($dep['recommended'])) {
$oper = 'has';
} else {
// check to see if a dep is already installed and is the same or newer
if (!isset($dep['min']) && !isset($dep['max']) && !isset($dep['recommended'])) {
$oper = 'has';
} else {
$oper = 'gt';
$oper = 'gt';
}
 
// do not try to move this before getDepPackageDownloadURL
// we can't determine whether upgrade is necessary until we know what
// version would be downloaded
if (!isset($options['force']) && $this->isInstalled($ret, $oper)) {
$version = $this->_installRegistry->packageInfo($dep['name'], 'version', $dep['channel']);
$dep['package'] = $dep['name'];
if (!isset($options['soft'])) {
$this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group .
' dependency "' .
$this->_registry->parsedPackageNameToString($dep, true) .
'" version ' . $url['version'] . ', already installed as version ' .
$version);
}
// do not try to move this before getDepPackageDownloadURL
// we can't determine whether upgrade is necessary until we know what
// version would be downloaded
if (!isset($options['force']) && $this->isInstalled($ret, $oper)) {
$version = $this->_installRegistry->packageInfo($dep['name'], 'version',
$dep['channel']);
$dep['package'] = $dep['name'];
if (!isset($options['soft'])) {
$this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group .
' dependency "' .
$this->_registry->parsedPackageNameToString($dep, true) .
'" version ' . $url['version'] . ', already installed as version ' .
$version);
}
return false;
}
 
return false;
}
 
if (isset($dep['nodefault'])) {
$ret['nodefault'] = true;
}
 
return $ret;
}
 
619,7 → 689,7
$skipnames = array();
foreach ($deps as $dep) {
$nodownload = false;
if ($dep['type'] == 'pkg') {
if (isset ($dep['type']) && $dep['type'] === 'pkg') {
$dep['channel'] = 'pear.php.net';
$dep['package'] = $dep['name'];
switch ($dep['rel']) {
651,12 → 721,13
continue 2;
}
}
 
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if ($this->_explicitState) {
$pname['state'] = $this->_explicitState;
}
$url =
$this->_downloader->_getDepPackageDownloadUrl($dep, $pname);
 
$url = $this->_downloader->_getDepPackageDownloadUrl($dep, $pname);
$chan = 'pear.php.net';
if (PEAR::isError($url)) {
// check to see if this is a pecl package that has jumped
664,12 → 735,12
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
 
$newdep = PEAR_Dependency2::normalizeDep($dep);
$newdep = $newdep[0];
$newdep['channel'] = 'pecl.php.net';
$chan = 'pecl.php.net';
$url =
$this->_downloader->_getDepPackageDownloadUrl($newdep, $pname);
$url = $this->_downloader->_getDepPackageDownloadUrl($newdep, $pname);
$obj = &$this->_installRegistry->getPackage($dep['name']);
if (PEAR::isError($url)) {
PEAR::popErrorHandling();
694,8 → 765,7
} else {
if (isset($dep['optional']) && $dep['optional'] == 'yes') {
$this->_downloader->log(2, $this->getShortName() .
': Skipping ' . $group
. ' dependency "' .
': Skipping optional dependency "' .
$this->_registry->parsedPackageNameToString($dep, true) .
'", no releases exist');
continue;
705,6 → 775,7
}
}
}
 
PEAR::popErrorHandling();
if (!isset($options['alldeps'])) {
if (isset($dep['optional']) && $dep['optional'] == 'yes') {
723,6 → 794,7
$nodownload = true;
}
}
 
if (!isset($options['alldeps']) && !isset($options['onlyreqdeps'])) {
if (!isset($dep['optional']) || $dep['optional'] == 'no') {
if (!isset($options['soft'])) {
740,6 → 812,7
$nodownload = true;
}
}
 
// check to see if a dep is already installed
// do not try to move this before getDepPackageDownloadURL
// we can't determine whether upgrade is necessary until we know what
751,11 → 824,11
'optional';
$dep['package'] = $dep['name'];
if (isset($newdep)) {
$version = $this->_installRegistry->packageInfo($newdep['name'], 'version',
$newdep['channel']);
$version = $this->_installRegistry->packageInfo($newdep['name'], 'version', $newdep['channel']);
} else {
$version = $this->_installRegistry->packageInfo($dep['name'], 'version');
}
 
$dep['version'] = $url['version'];
if (!isset($options['soft'])) {
$this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group .
763,6 → 836,7
$this->_registry->parsedPackageNameToString($dep, true) .
'", already installed as version ' . $version);
}
 
$skip = count($skipnames) ?
$skipnames[count($skipnames) - 1] : '';
if ($skip ==
769,15 → 843,19
$this->_registry->parsedPackageNameToString($dep, true)) {
array_pop($skipnames);
}
 
continue;
}
 
if ($nodownload) {
continue;
}
 
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if (isset($newdep)) {
$dep = $newdep;
}
 
$dep['package'] = $dep['name'];
$ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params,
isset($dep['optional']) && $dep['optional'] == 'yes' &&
789,9 → 867,11
}
continue;
}
 
$this->_downloadDeps[] = $ret;
}
}
 
if (count($skipnames)) {
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'Did not download dependencies: ' .
823,12 → 903,13
}
 
function getParsedPackage()
{
{
if (isset($this->_packagefile) || isset($this->_parsedname)) {
return array('channel' => $this->getChannel(),
'package' => $this->getPackage(),
'version' => $this->getVersion());
}
 
return false;
}
 
839,11 → 920,10
 
function canDefault()
{
if (isset($this->_downloadURL)) {
if (isset($this->_downloadURL['nodefault'])) {
return false;
}
if (isset($this->_downloadURL) && isset($this->_downloadURL['nodefault'])) {
return false;
}
 
return true;
}
 
853,9 → 933,9
return $this->_packagefile->getPackage();
} elseif (isset($this->_downloadURL['info'])) {
return $this->_downloadURL['info']->getPackage();
} else {
return false;
}
 
return false;
}
 
/**
867,9 → 947,9
return $this->_packagefile->isSubpackage($pf);
} elseif (isset($this->_downloadURL['info'])) {
return $this->_downloadURL['info']->isSubpackage($pf);
} else {
return false;
}
 
return false;
}
 
function getPackageType()
878,9 → 958,9
return $this->_packagefile->getPackageType();
} elseif (isset($this->_downloadURL['info'])) {
return $this->_downloadURL['info']->getPackageType();
} else {
return false;
}
 
return false;
}
 
function isBundle()
887,9 → 967,9
{
if (isset($this->_packagefile)) {
return $this->_packagefile->getPackageType() == 'bundle';
} else {
return false;
}
 
return false;
}
 
function getPackageXmlVersion()
898,9 → 978,9
return $this->_packagefile->getPackagexmlVersion();
} elseif (isset($this->_downloadURL['info'])) {
return $this->_downloadURL['info']->getPackagexmlVersion();
} else {
return '1.0';
}
 
return '1.0';
}
 
function getChannel()
909,9 → 989,9
return $this->_packagefile->getChannel();
} elseif (isset($this->_downloadURL['info'])) {
return $this->_downloadURL['info']->getChannel();
} else {
return false;
}
 
return false;
}
 
function getURI()
920,9 → 1000,9
return $this->_packagefile->getURI();
} elseif (isset($this->_downloadURL['info'])) {
return $this->_downloadURL['info']->getURI();
} else {
return false;
}
 
return false;
}
 
function getVersion()
931,9 → 1011,9
return $this->_packagefile->getVersion();
} elseif (isset($this->_downloadURL['version'])) {
return $this->_downloadURL['version'];
} else {
return false;
}
 
return false;
}
 
function isCompatible($pf)
942,9 → 1022,9
return $this->_packagefile->isCompatible($pf);
} elseif (isset($this->_downloadURL['info'])) {
return $this->_downloadURL['info']->isCompatible($pf);
} else {
return true;
}
 
return true;
}
 
function setGroup($group)
956,9 → 1036,9
{
if (isset($this->_parsedname['group'])) {
return $this->_parsedname['group'];
} else {
return '';
}
 
return '';
}
 
function isExtension($name)
966,14 → 1046,14
if (isset($this->_packagefile)) {
return $this->_packagefile->isExtension($name);
} elseif (isset($this->_downloadURL['info'])) {
if ($this->_downloadURL['info']->getPackagexmlVersion() == '2.0') {
return $this->_downloadURL['info']->getProvidesExtension() == $name;
} else {
return false;
}
} else {
if ($this->_downloadURL['info']->getPackagexmlVersion() == '2.0') {
return $this->_downloadURL['info']->getProvidesExtension() == $name;
}
 
return false;
}
 
return false;
}
 
function getDeps()
982,19 → 1062,19
$ver = $this->_packagefile->getPackagexmlVersion();
if (version_compare($ver, '2.0', '>=')) {
return $this->_packagefile->getDeps(true);
} else {
return $this->_packagefile->getDeps();
}
 
return $this->_packagefile->getDeps();
} elseif (isset($this->_downloadURL['info'])) {
$ver = $this->_downloadURL['info']->getPackagexmlVersion();
if (version_compare($ver, '2.0', '>=')) {
return $this->_downloadURL['info']->getDeps(true);
} else {
return $this->_downloadURL['info']->getDeps();
}
} else {
return array();
 
return $this->_downloadURL['info']->getDeps();
}
 
return array();
}
 
/**
1027,14 → 1107,14
}
return $param['uri'] == $this->getURI();
}
$package = isset($param['package']) ? $param['package'] :
$param['info']->getPackage();
$channel = isset($param['channel']) ? $param['channel'] :
$param['info']->getChannel();
 
$package = isset($param['package']) ? $param['package'] : $param['info']->getPackage();
$channel = isset($param['channel']) ? $param['channel'] : $param['info']->getChannel();
if (isset($param['rel'])) {
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
 
$newdep = PEAR_Dependency2::normalizeDep($param);
$newdep = $newdep[0];
} elseif (isset($param['min'])) {
1041,13 → 1121,16
$newdep = $param;
}
}
 
if (isset($newdep)) {
if (!isset($newdep['min'])) {
$newdep['min'] = '0';
}
 
if (!isset($newdep['max'])) {
$newdep['max'] = '100000000000000000000';
}
 
// use magic to support pecl packages suddenly jumping to the pecl channel
// we need to support both dependency possibilities
if ($channel == 'pear.php.net' && $this->getChannel() == 'pecl.php.net') {
1060,11 → 1143,13
$channel = 'pear.php.net';
}
}
 
return (strtolower($package) == strtolower($this->getPackage()) &&
$channel == $this->getChannel() &&
version_compare($newdep['min'], $this->getVersion(), '<=') &&
version_compare($newdep['max'], $this->getVersion(), '>='));
}
 
// use magic to support pecl packages suddenly jumping to the pecl channel
if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') {
if (strtolower($package) == strtolower($this->getPackage())) {
1071,14 → 1156,15
$channel = 'pear.php.net';
}
}
 
if (isset($param['version'])) {
return (strtolower($package) == strtolower($this->getPackage()) &&
$channel == $this->getChannel() &&
$param['version'] == $this->getVersion());
} else {
return strtolower($package) == strtolower($this->getPackage()) &&
$channel == $this->getChannel();
}
 
return strtolower($package) == strtolower($this->getPackage()) &&
$channel == $this->getChannel();
}
 
function isInstalled($dep, $oper = '==')
1086,9 → 1172,11
if (!$dep) {
return false;
}
 
if ($oper != 'ge' && $oper != 'gt' && $oper != 'has' && $oper != '==') {
return false;
}
 
if (is_object($dep)) {
$package = $dep->getPackage();
$channel = $dep->getChannel();
1111,13 → 1199,15
$package = $dep['info']->getPackage();
}
}
 
$options = $this->_downloader->getOptions();
$test = $this->_installRegistry->packageExists($package, $channel);
$test = $this->_installRegistry->packageExists($package, $channel);
if (!$test && $channel == 'pecl.php.net') {
// do magic to allow upgrading from old pecl packages to new ones
$test = $this->_installRegistry->packageExists($package, 'pear.php.net');
$channel = 'pear.php.net';
}
 
if ($test) {
if (isset($dep['uri'])) {
if ($this->_installRegistry->packageInfo($package, 'uri', '__uri') == $dep['uri']) {
1124,35 → 1214,73
return true;
}
}
 
if (isset($options['upgrade'])) {
if ($oper == 'has') {
if (version_compare($this->_installRegistry->packageInfo(
$package, 'version', $channel),
$dep['version'], '>=')) {
return true;
} else {
return false;
}
} else {
if (version_compare($this->_installRegistry->packageInfo(
$package, 'version', $channel),
$dep['version'], '>=')) {
return true;
}
return false;
$packageVersion = $this->_installRegistry->packageInfo($package, 'version', $channel);
if (version_compare($packageVersion, $dep['version'], '>=')) {
return true;
}
 
return false;
}
 
return true;
}
 
return false;
}
 
/**
* Detect duplicate package names with differing versions
*
* If a user requests to install Date 1.4.6 and Date 1.4.7,
* for instance, this is a logic error. This method
* detects this situation.
*
* @param array $params array of PEAR_Downloader_Package objects
* @param array $errorparams empty array
* @return array array of stupid duplicated packages in PEAR_Downloader_Package obejcts
*/
public static function detectStupidDuplicates($params, &$errorparams)
{
$existing = array();
foreach ($params as $i => $param) {
$package = $param->getPackage();
$channel = $param->getChannel();
$group = $param->getGroup();
if (!isset($existing[$channel . '/' . $package])) {
$existing[$channel . '/' . $package] = array();
}
 
if (!isset($existing[$channel . '/' . $package][$group])) {
$existing[$channel . '/' . $package][$group] = array();
}
 
$existing[$channel . '/' . $package][$group][] = $i;
}
 
$indices = array();
foreach ($existing as $package => $groups) {
foreach ($groups as $group => $dupes) {
if (count($dupes) > 1) {
$indices = $indices + $dupes;
}
}
}
 
$indices = array_unique($indices);
foreach ($indices as $index) {
$errorparams[] = $params[$index];
}
 
return count($errorparams);
}
 
/**
* @param array
* @param bool ignore install groups - for final removal of dupe packages
* @static
*/
function removeDuplicates(&$params, $ignoreGroups = false)
public static function removeDuplicates(&$params, $ignoreGroups = false)
{
$pnames = array();
foreach ($params as $i => $param) {
1159,45 → 1287,44
if (!$param) {
continue;
}
 
if ($param->getPackage()) {
if ($ignoreGroups) {
$group = '';
} else {
$group = $param->getGroup();
}
$group = $ignoreGroups ? '' : $param->getGroup();
$pnames[$i] = $param->getChannel() . '/' .
$param->getPackage() . '-' . $param->getVersion() . '#' . $group;
}
}
 
$pnames = array_unique($pnames);
$unset = array_diff(array_keys($params), array_keys($pnames));
$testp = array_flip($pnames);
$unset = array_diff(array_keys($params), array_keys($pnames));
$testp = array_flip($pnames);
foreach ($params as $i => $param) {
if (!$param) {
$unset[] = $i;
continue;
}
 
if (!is_a($param, 'PEAR_Downloader_Package')) {
$unset[] = $i;
continue;
}
if ($ignoreGroups) {
$group = '';
} else {
$group = $param->getGroup();
}
 
$group = $ignoreGroups ? '' : $param->getGroup();
if (!isset($testp[$param->getChannel() . '/' . $param->getPackage() . '-' .
$param->getVersion() . '#' . $group])) {
$unset[] = $i;
}
}
 
foreach ($unset as $i) {
unset($params[$i]);
}
 
$ret = array();
foreach ($params as $i => $param) {
$ret[] = &$params[$i];
}
 
$params = array();
foreach ($ret as $i => $param) {
$params[] = &$ret[$i];
1215,16 → 1342,15
}
 
/**
* @static
*/
function mergeDependencies(&$params)
public static function mergeDependencies(&$params)
{
$newparams = array();
$bundles = array();
$bundles = $newparams = array();
foreach ($params as $i => $param) {
if (!$param->isBundle()) {
continue;
}
 
$bundles[] = $i;
$pf = &$param->getPackageFile();
$newdeps = array();
1232,6 → 1358,7
if (!is_array($contents)) {
$contents = array($contents);
}
 
foreach ($contents as $file) {
$filecontents = $pf->getFileContents($file);
$dl = &$param->getDownloader();
1239,22 → 1366,28
if (PEAR::isError($dir = $dl->getDownloadDir())) {
return $dir;
}
 
$fp = @fopen($dir . DIRECTORY_SEPARATOR . $file, 'wb');
if (!$fp) {
continue;
}
 
// FIXME do symlink check
 
fwrite($fp, $filecontents, strlen($filecontents));
fclose($fp);
if ($s = $params[$i]->explicitState()) {
$obj->setExplicitState($s);
}
$obj = &new PEAR_Downloader_Package($params[$i]->getDownloader());
 
$obj = new PEAR_Downloader_Package($params[$i]->getDownloader());
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if (PEAR::isError($dir = $dl->getDownloadDir())) {
PEAR::popErrorHandling();
return $dir;
}
$e = $obj->_fromFile($a = $dir . DIRECTORY_SEPARATOR . $file);
$a = $dir . DIRECTORY_SEPARATOR . $file;
$e = $obj->_fromFile($a);
PEAR::popErrorHandling();
if (PEAR::isError($e)) {
if (!isset($options['soft'])) {
1262,16 → 1395,18
}
continue;
}
$j = &$obj;
if (!PEAR_Downloader_Package::willDownload($j,
array_merge($params, $newparams)) && !$param->isInstalled($j)) {
$newparams[] = &$j;
 
if (!PEAR_Downloader_Package::willDownload($obj,
array_merge($params, $newparams)) && !$param->isInstalled($obj)) {
$newparams[] = $obj;
}
}
}
 
foreach ($bundles as $i) {
unset($params[$i]); // remove bundles - only their contents matter for installation
}
 
PEAR_Downloader_Package::removeDuplicates($params); // strip any unset indices
if (count($newparams)) { // add in bundled packages for install
foreach ($newparams as $i => $unused) {
1279,24 → 1414,29
}
$newparams = array();
}
 
foreach ($params as $i => $param) {
$newdeps = array();
foreach ($param->_downloadDeps as $dep) {
if (!PEAR_Downloader_Package::willDownload($dep,
array_merge($params, $newparams)) && !$param->isInstalled($dep)) {
$merge = array_merge($params, $newparams);
if (!PEAR_Downloader_Package::willDownload($dep, $merge)
&& !$param->isInstalled($dep)
) {
$newdeps[] = $dep;
} else {
//var_dump($dep);
// detect versioning conflicts here
}
}
// convert the dependencies into PEAR_Downloader_Package objects for the next time
// around
 
// convert the dependencies into PEAR_Downloader_Package objects for the next time around
$params[$i]->_downloadDeps = array();
foreach ($newdeps as $dep) {
$obj = &new PEAR_Downloader_Package($params[$i]->getDownloader());
$obj = new PEAR_Downloader_Package($params[$i]->getDownloader());
if ($s = $params[$i]->explicitState()) {
$obj->setExplicitState($s);
}
 
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$e = $obj->fromDepURL($dep);
PEAR::popErrorHandling();
1306,6 → 1446,7
}
continue;
}
 
$e = $obj->detectDependencies($params);
if (PEAR::isError($e)) {
if (!isset($options['soft'])) {
1312,34 → 1453,36
$obj->_downloader->log(0, $e->getMessage());
}
}
$j = &$obj;
$newparams[] = &$j;
 
$newparams[] = $obj;
}
}
 
if (count($newparams)) {
foreach ($newparams as $i => $unused) {
$params[] = &$newparams[$i];
}
return true;
} else {
return false;
}
 
return false;
}
 
 
/**
* @static
*/
function willDownload($param, $params)
public static function willDownload($param, $params)
{
if (!is_array($params)) {
return false;
}
 
foreach ($params as $obj) {
if ($obj->isEqual($param)) {
return true;
}
}
 
return false;
}
 
1349,13 → 1492,12
* @param int
* @param string
*/
function &getPackagefileObject(&$c, $d, $t = false)
function &getPackagefileObject(&$c, $d)
{
$a = &new PEAR_PackageFile($c, $d, $t);
$a = new PEAR_PackageFile($c, $d);
return $a;
}
 
 
/**
* This will retrieve from a local file if possible, and parse out
* a group name as well. The original parameter will be modified to reflect this.
1369,25 → 1511,17
if (!@file_exists($param)) {
$test = explode('#', $param);
$group = array_pop($test);
if (file_exists(implode('#', $test))) {
if (@file_exists(implode('#', $test))) {
$this->setGroup($group);
$param = implode('#', $test);
$this->_explicitGroup = true;
}
}
 
if (@is_file($param)) {
$this->_type = 'local';
$options = $this->_downloader->getOptions();
if (isset($options['downloadonly'])) {
$pkg = &$this->getPackagefileObject($this->_config,
$this->_downloader->_debug);
} else {
if (PEAR::isError($dir = $this->_downloader->getDownloadDir())) {
return $dir;
}
$pkg = &$this->getPackagefileObject($this->_config,
$this->_downloader->_debug, $dir);
}
$pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->_debug);
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$pf = &$pkg->fromAnyFile($param, PEAR_VALIDATE_INSTALLING);
PEAR::popErrorHandling();
1409,8 → 1543,7
 
function _fromUrl($param, $saveparam = '')
{
if (!is_array($param) &&
(preg_match('#^(http|ftp)://#', $param))) {
if (!is_array($param) && (preg_match('#^(http|https|ftp)://#', $param))) {
$options = $this->_downloader->getOptions();
$this->_type = 'url';
$callback = $this->_downloader->ui ?
1420,8 → 1553,10
$this->_downloader->popErrorHandling();
return $dir;
}
 
$this->_downloader->log(3, 'Downloading "' . $param . '"');
$file = $this->_downloader->downloadHttp($param, $this->_downloader->ui,
$dir, $callback);
$dir, $callback, null, false, $this->getChannel());
$this->_downloader->popErrorHandling();
if (PEAR::isError($file)) {
if (!empty($saveparam)) {
1431,39 → 1566,35
'"' . $saveparam . ' (' . $file->getMessage() . ')');
return $err;
}
 
if ($this->_rawpackagefile) {
require_once 'Archive/Tar.php';
$tar = &new Archive_Tar($file);
$tar = new Archive_Tar($file);
$packagexml = $tar->extractInString('package2.xml');
if (!$packagexml) {
$packagexml = $tar->extractInString('package.xml');
}
 
if (str_replace(array("\n", "\r"), array('',''), $packagexml) !=
str_replace(array("\n", "\r"), array('',''), $this->_rawpackagefile)) {
if ($this->getChannel() == 'pear.php.net') {
// be more lax for the existing PEAR packages that have not-ok
// characters in their package.xml
$this->_downloader->log(0, 'CRITICAL WARNING: The "' .
$this->getPackage() . '" package has invalid characters in its ' .
'package.xml. The next version of PEAR may not be able to install ' .
'this package for security reasons. Please open a bug report at ' .
'http://pear.php.net/package/' . $this->getPackage() . '/bugs');
} else {
if ($this->getChannel() != 'pear.php.net') {
return PEAR::raiseError('CRITICAL ERROR: package.xml downloaded does ' .
'not match value returned from xml-rpc');
}
 
// be more lax for the existing PEAR packages that have not-ok
// characters in their package.xml
$this->_downloader->log(0, 'CRITICAL WARNING: The "' .
$this->getPackage() . '" package has invalid characters in its ' .
'package.xml. The next version of PEAR may not be able to install ' .
'this package for security reasons. Please open a bug report at ' .
'http://pear.php.net/package/' . $this->getPackage() . '/bugs');
}
}
 
// whew, download worked!
if (isset($options['downloadonly'])) {
$pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug);
} else {
if (PEAR::isError($dir = $this->_downloader->getDownloadDir())) {
return $dir;
}
$pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug,
$dir);
}
$pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug);
 
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$pf = &$pkg->fromAnyFile($file, PEAR_VALIDATE_INSTALLING);
PEAR::popErrorHandling();
1473,23 → 1604,30
if (is_array($err)) {
$err = $err['message'];
}
 
if (!isset($options['soft'])) {
$this->_downloader->log(0, "Validation Error: $err");
}
}
}
 
if (!isset($options['soft'])) {
$this->_downloader->log(0, $pf->getMessage());
}
$err = PEAR::raiseError('Download of "' . ($saveparam ? $saveparam :
$param) . '" succeeded, but it is not a valid package archive');
 
///FIXME need to pass back some error code that we can use to match with to cancel all further operations
/// At least stop all deps of this package from being installed
$out = $saveparam ? $saveparam : $param;
$err = PEAR::raiseError('Download of "' . $out . '" succeeded, but it is not a valid package archive');
$this->_valid = false;
return $err;
}
 
$this->_packagefile = &$pf;
$this->setGroup('default'); // install the default dependency group
return $this->_valid = true;
}
 
return $this->_valid = false;
}
 
1506,9 → 1644,9
function _fromString($param)
{
$options = $this->_downloader->getOptions();
$channel = $this->_config->get('default_channel');
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$pname = $this->_registry->parsePackageName($param,
$this->_config->get('default_channel'));
$pname = $this->_registry->parsePackageName($param, $channel);
PEAR::popErrorHandling();
if (PEAR::isError($pname)) {
if ($pname->getCode() == 'invalid') {
1515,13 → 1653,13
$this->_valid = false;
return false;
}
 
if ($pname->getCode() == 'channel') {
$parsed = $pname->getUserInfo();
if ($this->_downloader->discover($parsed['channel'])) {
if ($this->_config->get('auto_discover')) {
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$pname = $this->_registry->parsePackageName($param,
$this->_config->get('default_channel'));
$pname = $this->_registry->parsePackageName($param, $channel);
PEAR::popErrorHandling();
} else {
if (!isset($options['soft'])) {
1532,15 → 1670,17
}
}
}
 
if (PEAR::isError($pname)) {
if (!isset($options['soft'])) {
$this->_downloader->log(0, $pname->getMessage());
}
 
if (is_array($param)) {
$param = $this->_registry->parsedPackageNameToString($param);
}
$err = PEAR::raiseError('invalid package name/package file "' .
$param . '"');
 
$err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
$this->_valid = false;
return $err;
}
1548,26 → 1688,21
if (!isset($options['soft'])) {
$this->_downloader->log(0, $pname->getMessage());
}
$err = PEAR::raiseError('invalid package name/package file "' .
$param . '"');
 
$err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
$this->_valid = false;
return $err;
}
}
 
if (!isset($this->_type)) {
$this->_type = 'xmlrpc';
$this->_type = 'rest';
}
$this->_parsedname = $pname;
if (isset($pname['state'])) {
$this->_explicitState = $pname['state'];
} else {
$this->_explicitState = false;
}
if (isset($pname['group'])) {
$this->_explicitGroup = true;
} else {
$this->_explicitGroup = false;
}
 
$this->_parsedname = $pname;
$this->_explicitState = isset($pname['state']) ? $pname['state'] : false;
$this->_explicitGroup = isset($pname['group']) ? true : false;
 
$info = $this->_downloader->_getPackageDownloadUrl($pname);
if (PEAR::isError($info)) {
if ($info->getCode() != -976 && $pname['channel'] == 'pear.php.net') {
1586,13 → 1721,16
$pname['channel'] = 'pear.php.net';
}
}
 
return $info;
}
 
$this->_rawpackagefile = $info['raw'];
$ret = $this->_analyzeDownloadURL($info, $param, $pname);
if (PEAR::isError($ret)) {
return $ret;
}
 
if ($ret) {
$this->_downloadURL = $ret;
return $this->_valid = (bool) $ret;
1615,16 → 1753,15
if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
return false;
}
if (!$info) {
if (!is_string($param)) {
$saveparam = ", cannot download \"$param\"";
} else {
$saveparam = '';
}
 
if ($info === false) {
$saveparam = !is_string($param) ? ", cannot download \"$param\"" : '';
 
// no releases exist
return PEAR::raiseError('No releases for package "' .
$this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
}
 
if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
$err = false;
if ($pname['channel'] == 'pecl.php.net') {
1638,6 → 1775,7
} else {
$err = true;
}
 
if ($err) {
return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] .
'" retrieved another channel\'s name for download! ("' .
1644,11 → 1782,13
$info['info']->getChannel() . '")');
}
}
 
$preferred_state = $this->_config->get('preferred_state');
if (!isset($info['url'])) {
$package_version = $this->_registry->packageInfo($info['info']->getPackage(),
'version', $info['info']->getChannel());
if ($this->isInstalled($info)) {
if ($isdependency && version_compare($info['version'],
$this->_registry->packageInfo($info['info']->getPackage(),
'version', $info['info']->getChannel()), '<=')) {
if ($isdependency && version_compare($info['version'], $package_version, '<=')) {
// ignore bogus errors of "failed to download dependency"
// if it is already installed and the one that would be
// downloaded is older or the same version (Bug #7219)
1655,6 → 1795,27
return false;
}
}
 
if ($info['version'] === $package_version) {
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] .
'/' . $pname['package'] . '-' . $package_version. ', additionally the suggested version' .
' (' . $package_version . ') is the same as the locally installed one.');
}
 
return false;
}
 
if (version_compare($info['version'], $package_version, '<=')) {
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] .
'/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' .
' (' . $info['version'] . ') is a lower version than the locally installed one (' . $package_version . ').');
}
 
return false;
}
 
$instead = ', will instead download version ' . $info['version'] .
', stability "' . $info['info']->getState() . '"';
// releases exist, but we failed to get any
1667,8 → 1828,9
if (!class_exists('PEAR_Common')) {
require_once 'PEAR/Common.php';
}
 
if (!in_array($info['info']->getState(),
PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
PEAR_Common::betterStates($preferred_state, true))) {
if ($optional) {
// don't spit out confusing error message
return $this->_downloader->_getPackageDownloadUrl(
1676,12 → 1838,13
'channel' => $pname['channel'],
'version' => $info['version']));
}
$vs = ' within preferred state "' . $this->_config->get('preferred_state') .
$vs = ' within preferred state "' . $preferred_state .
'"';
} else {
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
 
if ($optional) {
// don't spit out confusing error message
return $this->_downloader->_getPackageDownloadUrl(
1693,13 → 1856,14
$instead = '';
}
} else {
$vs = ' within preferred state "' . $this->_config->get(
'preferred_state') . '"';
$vs = ' within preferred state "' . $preferred_state . '"';
}
 
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] .
'/' . $pname['package'] . $vs . $instead);
}
 
// download the latest release
return $this->_downloader->_getPackageDownloadUrl(
array('package' => $pname['package'],
1706,6 → 1870,22
'channel' => $pname['channel'],
'version' => $info['version']));
} else {
if (isset($info['php']) && $info['php']) {
$err = PEAR::raiseError('Failed to download ' .
$this->_registry->parsedPackageNameToString(
array('channel' => $pname['channel'],
'package' => $pname['package']),
true) .
', latest release is version ' . $info['php']['v'] .
', but it requires PHP version "' .
$info['php']['m'] . '", use "' .
$this->_registry->parsedPackageNameToString(
array('channel' => $pname['channel'], 'package' => $pname['package'],
'version' => $info['php']['v'])) . '" to install',
PEAR_DOWNLOADER_PACKAGE_PHPVERSION);
return $err;
}
 
// construct helpful error message
if (isset($pname['version'])) {
$vs = ', version "' . $pname['version'] . '"';
1715,8 → 1895,9
if (!class_exists('PEAR_Common')) {
require_once 'PEAR/Common.php';
}
 
if (!in_array($info['info']->getState(),
PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
PEAR_Common::betterStates($preferred_state, true))) {
if ($optional) {
// don't spit out confusing error message, and don't die on
// optional dep failure!
1725,12 → 1906,12
'channel' => $pname['channel'],
'version' => $info['version']));
}
$vs = ' within preferred state "' . $this->_config->get('preferred_state') .
'"';
$vs = ' within preferred state "' . $preferred_state . '"';
} else {
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
 
if ($optional) {
// don't spit out confusing error message, and don't die on
// optional dep failure!
1742,9 → 1923,9
$vs = PEAR_Dependency2::_getExtraString($pname);
}
} else {
$vs = ' within preferred state "' . $this->_downloader->config->get(
'preferred_state') . '"';
$vs = ' within preferred state "' . $this->_downloader->config->get('preferred_state') . '"';
}
 
$options = $this->_downloader->getOptions();
// this is only set by the "download-all" command
if (isset($options['ignorepreferred_state'])) {
1761,22 → 1942,32
PEAR_DOWNLOADER_PACKAGE_STATE);
return $err;
}
$err = PEAR::raiseError(
'Failed to download ' . $this->_registry->parsedPackageNameToString(
array('channel' => $pname['channel'], 'package' => $pname['package']),
true)
. $vs .
', latest release is version ' . $info['version'] .
', stability "' . $info['info']->getState() . '", use "' .
$this->_registry->parsedPackageNameToString(
array('channel' => $pname['channel'], 'package' => $pname['package'],
'version' => $info['version'])) . '" to install');
return $err;
 
// Checks if the user has a package installed already and checks the release against
// the state against the installed package, this allows upgrades for packages
// with lower stability than the preferred_state
$stability = $this->_registry->packageInfo($pname['package'], 'stability', $pname['channel']);
if (!$this->isInstalled($info)
|| !in_array($info['info']->getState(), PEAR_Common::betterStates($stability['release'], true))
) {
$err = PEAR::raiseError(
'Failed to download ' . $this->_registry->parsedPackageNameToString(
array('channel' => $pname['channel'], 'package' => $pname['package']),
true)
. $vs .
', latest release is version ' . $info['version'] .
', stability "' . $info['info']->getState() . '", use "' .
$this->_registry->parsedPackageNameToString(
array('channel' => $pname['channel'], 'package' => $pname['package'],
'version' => $info['version'])) . '" to install');
return $err;
}
}
}
 
if (isset($info['deprecated']) && $info['deprecated']) {
$this->_downloader->log(0,
'WARNING: "' .
'WARNING: "' .
$this->_registry->parsedPackageNameToString(
array('channel' => $info['info']->getChannel(),
'package' => $info['info']->getPackage()), true) .
1784,7 → 1975,7
$this->_registry->parsedPackageNameToString($info['deprecated'], true) .
'"');
}
 
return $info;
}
}
?>