cvs: php-src /pear/PEAR Installer.php

From: Date: Tue, 30 Sep 2003 02:56:42 +0000
Subject: cvs: php-src /pear/PEAR Installer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13179@lists.php.net to get a copy of this message
cellog Mon Sep 29 22:56:42 2003 EDT Modified files: /php-src/pear/PEAR Installer.php Log: better fix for #45. Now, it will install the newest version that is preferred_state or stabler. to request a specific state, append -state like pear install Net_NNTP-beta Index: php-src/pear/PEAR/Installer.php diff -u php-src/pear/PEAR/Installer.php:1.129 php-src/pear/PEAR/Installer.php:1.130 --- php-src/pear/PEAR/Installer.php:1.129 Mon Sep 29 13:36:00 2003 +++ php-src/pear/PEAR/Installer.php Mon Sep 29 22:56:42 2003 @@ -18,7 +18,7 @@ // | Martin Jansen <mj@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Installer.php,v 1.129 2003/09/29 17:36:00 cellog Exp $ +// $Id: Installer.php,v 1.130 2003/09/30 02:56:42 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; } } }

« previous php.pear.cvs (#13179) next »