From: Stig Bakken Date: Sun, 28 Jul 2002 08:52:55 +0000 (+0000) Subject: * added "upgrade-all" command X-Git-Tag: dev~133 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cbbc47a1991b0b4e54a06989ea72d2491adb4ff6;p=php * added "upgrade-all" command --- diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php index 36c0b80cd3..a7b590e140 100644 --- a/pear/PEAR/Command/Install.php +++ b/pear/PEAR/Command/Install.php @@ -117,6 +117,34 @@ package has a higher version number (use the -f option if you need to upgrade anyway). More than one package may be specified at once. +'), + 'upgrade-all' => array( + 'summary' => 'Upgrade All Packages', + 'function' => 'doInstall', + 'shortcut' => 'ua', + 'options' => array( + 'nodeps' => array( + 'shortopt' => 'n', + 'doc' => 'ignore dependencies, upgrade anyway', + ), + 'register-only' => array( + 'shortopt' => 'r', + 'doc' => 'do not install files, only register the package as upgraded', + ), + 'nobuild' => array( + 'shortopt' => 'B', + 'doc' => 'don\'t build C extensions', + ), + 'nocompress' => array( + 'shortopt' => 'Z', + 'doc' => 'request uncompressed files when downloading', + ), + ), + 'doc' => ' +Upgrades all packages that have a newer release available. Upgrades are +done only if there is a release available of the state specified in +"preferred_state" (currently {config preferred_state}), or a state considered +more stable. '), 'uninstall' => array( 'summary' => 'Un-install Package', @@ -162,6 +190,36 @@ specified at once. if ($command == 'upgrade') { $options[$command] = true; } + if ($command == 'upgrade-all') { + include_once "PEAR/Remote.php"; + $options['upgrade'] = true; + $remote = new PEAR_Remote($this->config); + $state = $this->config->get('preferred_state'); + if (empty($state) || $state == 'any') { + $latest = $remote->call("package.listLatestReleases"); + } else { + $latest = $remote->call("package.listLatestReleases", $state); + } + if (PEAR::isError($latest)) { + return $latest; + } + $reg = new PEAR_Registry($this->config->get('php_dir')); + $installed = array_flip($reg->listPackages()); + $params = array(); + foreach ($latest as $package => $info) { + if (!isset($installed[$package])) { + // skip packages we don't have installed + continue; + } + $inst_version = $reg->packageInfo($package, 'version'); + if (version_compare("$info[version]", "$inst_version", "le")) { + // installed version is up-to-date + continue; + } + $params[] = $package; + $this->ui->outputData("will upgrade $package", $command); + } + } foreach ($params as $pkg) { $bn = basename($pkg); $info = $this->installer->install($pkg, $options, $this->config);