Browse Source

This patch allows:

pear install DB-1.2     -> specific version
pear install DB-stable  -> latest stable version
                           (stable, beta, alpha, ..)
pear install DB-1.2.tar -> download in tar format

Currently only "install" and "upgrade" support this
more will come shortly.
PEAR_1_4DEV
Tomas V.V.Cox 23 years ago
parent
commit
e18e3a6edd
  1. 9
      pear/PEAR/Command/Install.php
  2. 3
      pear/PEAR/Common.php
  3. 31
      pear/PEAR/Installer.php

9
pear/PEAR/Command/Install.php

@ -256,7 +256,7 @@ package if needed.
$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";
@ -292,7 +292,12 @@ package if needed.
$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';

3
pear/PEAR/Common.php

@ -28,6 +28,9 @@ require_once 'PEAR/Config.php';
define('PEAR_COMMON_PACKAGE_NAME_PREG', '/^([A-Z][a-zA-Z0-9_]+|[a-z][a-z0-9_]+)$/');
// XXX far from perfect :-)
define('PEAR_COMMON_PACKAGE_DOWNLOAD_PREG', '/^([A-Z][a-zA-Z0-9_]+|[a-z][a-z0-9_]+)(-([.0-9a-zA-Z]+))?$/');
/**
* List of temporary files and directories registered by
* PEAR_Common::addTempFile().

31
pear/PEAR/Installer.php

@ -424,8 +424,11 @@ class PEAR_Installer extends PEAR_Common
// }}}
// {{{ 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 {
@ -448,7 +451,6 @@ class PEAR_Installer extends PEAR_Common
}
// }}}
// {{{ _prependPath($path, $prepend)
function _prependPath($path, $prepend)
@ -463,9 +465,23 @@ class PEAR_Installer extends PEAR_Common
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)) {
@ -478,7 +494,7 @@ class PEAR_Installer extends PEAR_Common
return;
}
}
$pkgfile = $this->getPackageDownloadUrl($pkgfile);
$pkgfile = $this->getPackageDownloadUrl($pkgfile, $version);
$need_download = true;
} else {
if (strlen($pkgfile)) {
@ -532,7 +548,7 @@ class PEAR_Installer extends PEAR_Common
* @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
@ -556,13 +572,15 @@ class PEAR_Installer extends PEAR_Common
// 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;
}
@ -722,7 +740,6 @@ class PEAR_Installer extends PEAR_Common
$this->installroot = '';
}
$this->registry = &new PEAR_Registry($php_dir);
$need_download = false;
// ==> XXX should be removed later on
$flag_old_format = false;

Loading…
Cancel
Save