cvs: php-src(PHP_4_3) /pear/PEAR Installer.php
| From: | Greg Beaver | Date: | Tue, 30 Sep 2003 02:57:28 +0000 |
| Subject: | cvs: php-src(PHP_4_3) /pear/PEAR Installer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13180@lists.php.net to get a copy of this message | ||
cellog Mon Sep 29 22:57:28 2003 EDT
Modified files: (Branch: PHP_4_3)
/php-src/pear/PEAR Installer.php
Log:
MFH better #45 fix
Index: php-src/pear/PEAR/Installer.php
diff -u php-src/pear/PEAR/Installer.php:1.81.2.13 php-src/pear/PEAR/Installer.php:1.81.2.14
--- php-src/pear/PEAR/Installer.php:1.81.2.13 Mon Sep 29 13:38:37 2003
+++ php-src/pear/PEAR/Installer.php Mon Sep 29 22:57:28 2003
@@ -18,7 +18,7 @@
// | Martin Jansen <mj@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Installer.php,v 1.81.2.13 2003/09/29 17:38:37 cellog Exp $
+// $Id: Installer.php,v 1.81.2.14 2003/09/30 02:57:28 cellog Exp $
require_once 'PEAR/Common.php';
require_once 'PEAR/Registry.php';
@@ -711,56 +711,46 @@
if (!is_file($pkgfile)) {
$origpkgfile = $pkgfile;
$pkgfile = $this->extractDownloadFileName($pkgfile, $version);
- $version_is_state = false;
- if ($version === null) {
- // use preferred state if no version number was specified
- $version = $state;
- $version_is_state = true;
- }
- if ($this->validPackageName($pkgfile) &&
!isset($options['upgrade'])) {
- if ($this->registry->packageExists($pkgfile)) {
+ if ($this->validPackageName($pkgfile)) {
+ if ($this->registry->packageExists($pkgfile)
+ && !isset($options['upgrade'])) {
$this->log(0, "Package '$pkgfile' already installed,
skipping");
// ignore dependencies that are installed unless we are upgrading
continue;
}
- }
- if ($version_is_state) {
- $savepkgfile = $pkgfile;
- PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
- $pkgfile = $this->_downloadFile($pkgfile, $config, $options,
- $errors, $version, $origpkgfile,
- $state);
- PEAR::popErrorHandling();
- if (PEAR::isError($pkgfile) &&
- $pkgfile->getCode() != PEAR_INSTALLER_ERROR_NO_PREF_STATE) {
- return $pkgfile;
- } elseif (PEAR::isError($pkgfile)) {
- $pkgfile = $savepkgfile;
- $states = $this->betterStates($state, false);
- $init = true;
- // try from stable down to preferred_state
- while(($init || (PEAR::isError($pkgfile) &&
- $pkgfile->getCode() == PEAR_INSTALLER_ERROR_NO_PREF_STATE))
- && count($states)) {
- $pkgfile = $savepkgfile;
- $init = false;
- $nextstate = array_pop($states);
- PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
+ if ($version === null) {
+ // use preferred state if no version number was specified
+ include_once 'PEAR/Remote.php';
+ $curver = $this->registry->packageInfo($pkgfile,
'version');
+ $remote = &new PEAR_Remote($config);
+ $releases = $remote->call('package.info', $pkgfile,
'releases');
+ $states = $this->betterStates($state, true);
+ $possible = false;
+ foreach($releases as $ver => $inf) {
+ if (in_array($inf['state'], $states)) {
+ if (is_array($possible)) {
+ if (version_compare(key($possible), $ver) < 0) {
+ $possible = array($ver => $inf['state']);
+ }
+ } else {
+ if (version_compare($ver, $curver) > 0) {
+ $possible = array($ver => $inf['state']);
+ }
+ }
+ }
+ }
+ if ($possible) {
$pkgfile = $this->_downloadFile($pkgfile, $config, $options,
- $errors, $nextstate, $origpkgfile,
- $state);
- PEAR::popErrorHandling();
+ $errors, key($possible), $origpkgfile,
+ $state);
}
+ } else {
+ $pkgfile = $this->_downloadFile($pkgfile, $config, $options,
+ $errors, $version, $origpkgfile,
+ $state);
if (PEAR::isError($pkgfile)) {
return $pkgfile;
}
- }
- } else {
- $pkgfile = $this->_downloadFile($pkgfile, $config, $options,
- $errors, $version, $origpkgfile,
- $state);
- if (PEAR::isError($pkgfile)) {
- return $pkgfile;
}
}
}