/** * @param array output of {@link parsePackageName()} * @access private */ function _getPackageDownloadUrl($parr) { $curchannel = $this->config->get('default_channel'); $this->configSet('default_channel', $parr['channel']); // getDownloadURL returns an array. On error, it only contains information // on the latest release as array(version, info). On success it contains // array(version, info, download url string) $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state'); if (!$this->_registry->channelExists($parr['channel'])) { do { if ($this->config->get('auto_discover') && $this->discover($parr['channel'])) { break; } $this->configSet('default_channel', $curchannel); return PEAR::raiseError('Unknown remote channel: ' . $parr['channel']); } while (false); } $chan =& $this->_registry->getChannel($parr['channel']); if (PEAR::isError($chan)) { return $chan; } PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); $version = $this->_registry->packageInfo($parr['package'], 'version', $parr['channel']); $stability = $this->_registry->packageInfo($parr['package'], 'stability', $parr['channel']); // package is installed - use the installed release stability level if (!isset($parr['state']) && $stability !== null) { $state = $stability['release']; } PEAR::staticPopErrorHandling(); $base2 = false; $preferred_mirror = $this->config->get('preferred_mirror'); if (!$chan->supportsREST($preferred_mirror) || !($base2 = $chan->getBaseURL('REST1.3', $preferred_mirror)) && !($base = $chan->getBaseURL('REST1.0', $preferred_mirror))) { return $this->raiseError($parr['channel'] . ' is using a unsupported protocol - This should never happen.'); } if ($base2) { $rest =& $this->config->getREST('1.3', $this->_options); $base = $base2; } else { $rest =& $this->config->getREST('1.0', $this->_options); } $downloadVersion = false; if (!isset($parr['version']) && !isset($parr['state']) && $version && !PEAR::isError($version) && !isset($this->_options['downloadonly'])) { $downloadVersion = $version; } $url = $rest->getDownloadURL($base, $parr, $state, $downloadVersion, $chan->getName()); if (PEAR::isError($url)) { $this->configSet('default_channel', $curchannel); return $url; } if ($parr['channel'] != $curchannel) { $this->configSet('default_channel', $curchannel); } if (!is_array($url)) { return $url; } $url['raw'] = false; // no checking is necessary for REST if (!is_array($url['info'])) { return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen'); } if (!isset($this->_options['force']) && !isset($this->_options['downloadonly']) && $version && !PEAR::isError($version) && !isset($parr['group'])) { if (version_compare($version, $url['version'], '=')) { return PEAR::raiseError($this->_registry->parsedPackageNameToString($parr, true) . ' is already installed and is the same as the ' . 'released version ' . $url['version'], -976); } if (version_compare($version, $url['version'], '>')) { return PEAR::raiseError($this->_registry->parsedPackageNameToString($parr, true) . ' is already installed and is newer than detected ' . 'released version ' . $url['version'], -976); } } if (isset($url['info']['required']) || $url['compatible']) { require_once 'PEAR/PackageFile/v2.php'; $pf = new PEAR_PackageFile_v2(); $pf->setRawChannel($parr['channel']); if ($url['compatible']) { $pf->setRawCompatible($url['compatible']); } } else { require_once 'PEAR/PackageFile/v1.php'; $pf = new PEAR_PackageFile_v1(); } $pf->setRawPackage($url['package']); $pf->setDeps($url['info']); if ($url['compatible']) { $pf->setCompatible($url['compatible']); } $pf->setRawState($url['stability']); $url['info'] =& $pf; if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { $ext = '.tar'; } else { $ext = '.tgz'; } if (is_array($url) && isset($url['url'])) { $url['url'] .= $ext; } return $url; }
/** * @param array output of {@link parsePackageName()} * @access private */ function _getPackageDownloadUrl($parr) { $curchannel = $this->config->get('default_channel'); $this->configSet('default_channel', $parr['channel']); // getDownloadURL returns an array. On error, it only contains information // on the latest release as array(version, info). On success it contains // array(version, info, download url string) $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state'); if (!$this->_registry->channelExists($parr['channel'])) { do { if ($this->config->get('auto_discover')) { if ($this->discover($parr['channel'])) { break; } } $this->configSet('default_channel', $curchannel); return PEAR::raiseError('Unknown remote channel: ' . $remotechannel); } while (false); } $chan =& $this->_registry->getChannel($parr['channel']); if (PEAR::isError($chan)) { return $chan; } $version = $this->_registry->packageInfo($parr['package'], 'version', $parr['channel']); if ($chan->supportsREST($this->config->get('preferred_mirror')) && ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror')))) { $rest =& $this->config->getREST('1.0', $this->_options); if (!isset($parr['version']) && !isset($parr['state']) && $version && !isset($this->_options['downloadonly'])) { $url = $rest->getDownloadURL($base, $parr, $state, $version); } else { $url = $rest->getDownloadURL($base, $parr, $state, false); } if (PEAR::isError($url)) { $this->configSet('default_channel', $curchannel); return $url; } if ($parr['channel'] != $curchannel) { $this->configSet('default_channel', $curchannel); } if (!is_array($url)) { return $url; } $url['raw'] = false; // no checking is necessary for REST if (!is_array($url['info'])) { return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen'); } if (isset($url['info']['required']) || $url['compatible']) { require_once 'PEAR/PackageFile/v2.php'; $pf = new PEAR_PackageFile_v2(); $pf->setRawChannel($parr['channel']); if ($url['compatible']) { $pf->setRawCompatible($url['compatible']); } } else { require_once 'PEAR/PackageFile/v1.php'; $pf = new PEAR_PackageFile_v1(); } $pf->setRawPackage($url['package']); $pf->setDeps($url['info']); $pf->setRawState($url['stability']); $url['info'] =& $pf; if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { $ext = '.tar'; } else { $ext = '.tgz'; } if (is_array($url)) { if (isset($url['url'])) { $url['url'] .= $ext; } } return $url; } elseif ($chan->supports('xmlrpc', 'package.getDownloadURL', false, '1.1')) { // don't install with the old version information unless we're doing a plain // vanilla simple installation. If the user says to install a particular // version or state, ignore the current installed version if (!isset($parr['version']) && !isset($parr['state']) && $version && !isset($this->_options['downloadonly'])) { $url = $this->_remote->call('package.getDownloadURL', $parr, $state, $version); } else { $url = $this->_remote->call('package.getDownloadURL', $parr, $state); } } else { $url = $this->_remote->call('package.getDownloadURL', $parr, $state); } if (PEAR::isError($url)) { return $url; } if ($parr['channel'] != $curchannel) { $this->configSet('default_channel', $curchannel); } if (isset($url['__PEAR_ERROR_CLASS__'])) { return PEAR::raiseError($url['message']); } if (!is_array($url)) { return $url; } $url['raw'] = $url['info']; if (isset($this->_options['downloadonly'])) { $pkg =& $this->getPackagefileObject($this->config, $this->debug); } else { $pkg =& $this->getPackagefileObject($this->config, $this->debug, $this->getDownloadDir()); } PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); $pinfo =& $pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote'); PEAR::staticPopErrorHandling(); if (PEAR::isError($pinfo)) { if (!isset($this->_options['soft'])) { $this->log(0, $pinfo->getMessage()); } return PEAR::raiseError('Remote package.xml is not valid - this should never happen'); } $url['info'] =& $pinfo; if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { $ext = '.tar'; } else { $ext = '.tgz'; } if (is_array($url)) { if (isset($url['url'])) { $url['url'] .= $ext; } } return $url; }