$this->installer = &new PEAR_Installer($this->ui);
}
if ($command == 'upgrade') {
- $options[$command] = true;
+ $options['upgrade'] = true;
}
if ($command == 'upgrade-all') {
include_once "PEAR/Remote.php";
$errors = array();
$downloaded = array();
$this->installer->download($params, $options, $this->config, $downloaded,
- $errors);
+ $errors);
+ if ($command != 'upgrade-all') {
+ for ($i = 0; $i < count($params); $i++) {
+ $params[$i] = $this->installer->extractDownloadFileName($params[$i], $_tmp);
+ }
+ }
if (count($errors)) {
$err['data'] = array($errors);
$err['headline'] = 'Install Errors';
// }}}
// {{{ getPackageDownloadUrl()
- function getPackageDownloadUrl($package)
+ function getPackageDownloadUrl($package, $version = null)
{
+ if ($version) {
+ $package .= "-$version";
+ }
if ($this === null || $this->config === null) {
$package = "http://pear.php.net/get/$package";
} else {
}
// }}}
-
// {{{ _prependPath($path, $prepend)
function _prependPath($path, $prepend)
return $path;
}
+ // }}}
+ // {{ extractDownloadFileName($pkgfile, &$version)
+
+ function extractDownloadFileName($pkgfile, &$version)
+ {
+ // regex defined in Common.php
+ if (preg_match(PEAR_COMMON_PACKAGE_DOWNLOAD_PREG, $pkgfile, $m)) {
+ $version = (isset($m[3])) ? $m[3] : null;
+ return $m[1];
+ }
+ $version = null;
+ return $pkgfile;
+ }
+
// }}}
// {{{ _downloadFile()
- function _downloadFile($pkgfile, &$config, $options, &$errors)
+ function _downloadFile($pkgfile, &$config, $options, &$errors, $version)
{
$need_download = false;
if (preg_match('#^(http|ftp)://#', $pkgfile)) {
return;
}
}
- $pkgfile = $this->getPackageDownloadUrl($pkgfile);
+ $pkgfile = $this->getPackageDownloadUrl($pkgfile, $version);
$need_download = true;
} else {
if (strlen($pkgfile)) {
* @param false private recursion variable
*/
function download($packages, $options, &$config, &$installpackages,
- &$errors, $installed = false, $willinstall = false, $state = false)
+ &$errors, $installed = false, $willinstall = false, $state = false)
{
// recognized options:
// - onlyreqdeps : install all required dependencies as well
// download files in this list if necessary
foreach($packages as $pkgfile) {
+ $pkgfile = $this->extractDownloadFileName($pkgfile, $version);
if ($this->validPackageName($pkgfile) && !isset($options['upgrade'])) {
if ($this->registry->packageExists($pkgfile)) {
+ $this->log(0, "Package '$pkgfile' already installed, skipping");
// ignore dependencies that are installed unless we are upgrading
continue;
}
}
- $pkgfile = $this->_downloadFile($pkgfile, $config, $options, $errors);
+ $pkgfile = $this->_downloadFile($pkgfile, $config, $options, $errors, $version);
if (PEAR::isError($pkgfile)) {
return $pkgfile;
}
$this->installroot = '';
}
$this->registry = &new PEAR_Registry($php_dir);
- $need_download = false;
// ==> XXX should be removed later on
$flag_old_format = false;