2002-02-23 15:32:36 +00:00
|
|
|
|
<?php
|
|
|
|
|
//
|
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
|
// | PHP Version 4 |
|
|
|
|
|
// +----------------------------------------------------------------------+
|
2002-12-31 16:18:29 +00:00
|
|
|
|
// | Copyright (c) 1997-2003 The PHP Group |
|
2002-02-23 15:32:36 +00:00
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
|
// | This source file is subject to version 2.02 of the PHP license, |
|
|
|
|
|
// | that is bundled with this package in the file LICENSE, and is |
|
|
|
|
|
// | available at through the world-wide-web at |
|
|
|
|
|
// | http://www.php.net/license/2_02.txt. |
|
|
|
|
|
// | If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
|
// | obtain it through the world-wide-web, please send a note to |
|
|
|
|
|
// | license@php.net so we can mail you a copy immediately. |
|
|
|
|
|
// +----------------------------------------------------------------------+
|
2002-05-12 21:09:04 +00:00
|
|
|
|
// | Author: Stig S<>ther Bakken <ssb@fast.no> |
|
2002-02-23 15:32:36 +00:00
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
|
//
|
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
require_once "PEAR/Command/Common.php";
|
|
|
|
|
require_once "PEAR/Installer.php";
|
2002-05-12 21:09:04 +00:00
|
|
|
|
require_once "Console/Getopt.php";
|
2002-02-23 15:32:36 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* PEAR commands for installation or deinstallation/upgrading of
|
|
|
|
|
* packages.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class PEAR_Command_Install extends PEAR_Command_Common
|
|
|
|
|
{
|
2002-11-26 21:49:55 +00:00
|
|
|
|
// {{{ properties
|
2002-05-12 21:09:04 +00:00
|
|
|
|
|
|
|
|
|
var $commands = array(
|
|
|
|
|
'install' => array(
|
|
|
|
|
'summary' => 'Install Package',
|
|
|
|
|
'function' => 'doInstall',
|
2002-05-21 01:38:50 +00:00
|
|
|
|
'shortcut' => 'i',
|
2002-05-12 21:09:04 +00:00
|
|
|
|
'options' => array(
|
|
|
|
|
'force' => array(
|
|
|
|
|
'shortopt' => 'f',
|
|
|
|
|
'doc' => 'will overwrite newer installed packages',
|
|
|
|
|
),
|
|
|
|
|
'nodeps' => array(
|
|
|
|
|
'shortopt' => 'n',
|
|
|
|
|
'doc' => 'ignore dependencies, install anyway',
|
|
|
|
|
),
|
|
|
|
|
'register-only' => array(
|
|
|
|
|
'shortopt' => 'r',
|
|
|
|
|
'doc' => 'do not install files, only register the package as installed',
|
|
|
|
|
),
|
|
|
|
|
'soft' => array(
|
|
|
|
|
'shortopt' => 's',
|
|
|
|
|
'doc' => 'soft install, fail silently, or upgrade if already installed',
|
|
|
|
|
),
|
2002-06-06 10:51:26 +00:00
|
|
|
|
'nobuild' => array(
|
|
|
|
|
'shortopt' => 'B',
|
|
|
|
|
'doc' => 'don\'t build C extensions',
|
|
|
|
|
),
|
2002-05-12 21:09:04 +00:00
|
|
|
|
'nocompress' => array(
|
|
|
|
|
'shortopt' => 'Z',
|
|
|
|
|
'doc' => 'request uncompressed files when downloading',
|
|
|
|
|
),
|
2002-10-10 01:02:42 +00:00
|
|
|
|
'installroot' => array(
|
|
|
|
|
'shortopt' => 'R',
|
|
|
|
|
'arg' => 'DIR',
|
|
|
|
|
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
|
|
|
|
|
),
|
2002-11-26 01:32:47 +00:00
|
|
|
|
'ignore-errors' => array(
|
|
|
|
|
'doc' => 'force install even if there were errors',
|
|
|
|
|
),
|
2002-05-12 21:09:04 +00:00
|
|
|
|
),
|
2002-05-21 01:27:53 +00:00
|
|
|
|
'doc' => '<package> ...
|
|
|
|
|
Installs one or more PEAR packages. You can specify a package to
|
2002-05-12 21:09:04 +00:00
|
|
|
|
install in four ways:
|
|
|
|
|
|
|
|
|
|
"Package-1.0.tgz" : installs from a local file
|
|
|
|
|
|
|
|
|
|
"http://example.com/Package-1.0.tgz" : installs from
|
|
|
|
|
anywhere on the net.
|
|
|
|
|
|
|
|
|
|
"package.xml" : installs the package described in
|
|
|
|
|
package.xml. Useful for testing, or for wrapping a PEAR package in
|
|
|
|
|
another package manager such as RPM.
|
|
|
|
|
|
|
|
|
|
"Package" : queries your configured server
|
|
|
|
|
({config master_server}) and downloads the newest package with
|
|
|
|
|
the preferred quality/state ({config preferred_state}).
|
|
|
|
|
|
|
|
|
|
More than one package may be specified at once. It is ok to mix these
|
|
|
|
|
four ways of specifying packages.
|
|
|
|
|
'),
|
|
|
|
|
'upgrade' => array(
|
|
|
|
|
'summary' => 'Upgrade Package',
|
|
|
|
|
'function' => 'doInstall',
|
2002-05-21 01:38:50 +00:00
|
|
|
|
'shortcut' => 'up',
|
2002-05-12 21:09:04 +00:00
|
|
|
|
'options' => array(
|
|
|
|
|
'force' => array(
|
|
|
|
|
'shortopt' => 'f',
|
|
|
|
|
'doc' => 'overwrite newer installed packages',
|
|
|
|
|
),
|
|
|
|
|
'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',
|
|
|
|
|
),
|
2002-06-06 10:51:26 +00:00
|
|
|
|
'nobuild' => array(
|
|
|
|
|
'shortopt' => 'B',
|
|
|
|
|
'doc' => 'don\'t build C extensions',
|
|
|
|
|
),
|
2002-05-12 21:09:04 +00:00
|
|
|
|
'nocompress' => array(
|
|
|
|
|
'shortopt' => 'Z',
|
2002-05-20 01:22:00 +00:00
|
|
|
|
'doc' => 'request uncompressed files when downloading',
|
2002-05-12 21:09:04 +00:00
|
|
|
|
),
|
2002-10-10 01:02:42 +00:00
|
|
|
|
'installroot' => array(
|
|
|
|
|
'shortopt' => 'R',
|
|
|
|
|
'arg' => 'DIR',
|
|
|
|
|
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
|
|
|
|
|
),
|
2002-11-26 01:32:47 +00:00
|
|
|
|
'ignore-errors' => array(
|
|
|
|
|
'doc' => 'force install even if there were errors',
|
|
|
|
|
),
|
2002-05-12 21:09:04 +00:00
|
|
|
|
),
|
2002-05-21 01:27:53 +00:00
|
|
|
|
'doc' => '<package> ...
|
|
|
|
|
Upgrades one or more PEAR packages. See documentation for the
|
2002-05-12 21:09:04 +00:00
|
|
|
|
"install" command for ways to specify a package.
|
|
|
|
|
|
|
|
|
|
When upgrading, your package will be updated if the provided new
|
|
|
|
|
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.
|
2002-07-28 08:52:55 +00:00
|
|
|
|
'),
|
|
|
|
|
'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',
|
|
|
|
|
),
|
2002-10-10 01:02:42 +00:00
|
|
|
|
'installroot' => array(
|
|
|
|
|
'shortopt' => 'R',
|
|
|
|
|
'arg' => 'DIR',
|
|
|
|
|
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
|
|
|
|
|
),
|
2002-11-26 01:32:47 +00:00
|
|
|
|
'ignore-errors' => array(
|
|
|
|
|
'doc' => 'force install even if there were errors',
|
|
|
|
|
),
|
2002-07-28 08:52:55 +00:00
|
|
|
|
),
|
|
|
|
|
'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.
|
2002-05-12 21:09:04 +00:00
|
|
|
|
'),
|
|
|
|
|
'uninstall' => array(
|
|
|
|
|
'summary' => 'Un-install Package',
|
|
|
|
|
'function' => 'doUninstall',
|
2002-05-21 01:38:50 +00:00
|
|
|
|
'shortcut' => 'un',
|
2002-05-12 21:09:04 +00:00
|
|
|
|
'options' => array(
|
|
|
|
|
'nodeps' => array(
|
|
|
|
|
'shortopt' => 'n',
|
|
|
|
|
'doc' => 'ignore dependencies, uninstall anyway',
|
|
|
|
|
),
|
|
|
|
|
'register-only' => array(
|
|
|
|
|
'shortopt' => 'r',
|
|
|
|
|
'doc' => 'do not remove files, only register the packages as not installed',
|
|
|
|
|
),
|
2002-10-10 01:02:42 +00:00
|
|
|
|
'installroot' => array(
|
|
|
|
|
'shortopt' => 'R',
|
|
|
|
|
'arg' => 'DIR',
|
|
|
|
|
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
|
|
|
|
|
),
|
2002-11-26 01:32:47 +00:00
|
|
|
|
'ignore-errors' => array(
|
|
|
|
|
'doc' => 'force install even if there were errors',
|
|
|
|
|
),
|
2002-05-12 21:09:04 +00:00
|
|
|
|
),
|
2002-05-21 01:27:53 +00:00
|
|
|
|
'doc' => '<package> ...
|
|
|
|
|
Uninstalls one or more PEAR packages. More than one package may be
|
|
|
|
|
specified at once.
|
2002-05-12 21:09:04 +00:00
|
|
|
|
'),
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// }}}
|
2002-03-18 17:39:52 +00:00
|
|
|
|
// {{{ constructor
|
|
|
|
|
|
2002-02-23 15:32:36 +00:00
|
|
|
|
/**
|
2002-03-01 09:43:18 +00:00
|
|
|
|
* PEAR_Command_Install constructor.
|
|
|
|
|
*
|
2002-02-23 15:32:36 +00:00
|
|
|
|
* @access public
|
|
|
|
|
*/
|
2002-03-21 11:10:17 +00:00
|
|
|
|
function PEAR_Command_Install(&$ui, &$config)
|
2002-02-23 15:32:36 +00:00
|
|
|
|
{
|
2002-03-21 11:10:17 +00:00
|
|
|
|
parent::PEAR_Command_Common($ui, $config);
|
2002-02-23 15:32:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-18 17:39:52 +00:00
|
|
|
|
// }}}
|
|
|
|
|
|
2002-11-26 21:49:55 +00:00
|
|
|
|
// {{{ doInstall()
|
|
|
|
|
|
2002-05-21 01:27:53 +00:00
|
|
|
|
function doInstall($command, $options, $params)
|
2002-02-23 15:32:36 +00:00
|
|
|
|
{
|
2002-05-21 01:27:53 +00:00
|
|
|
|
if (empty($this->installer)) {
|
2002-06-02 13:07:19 +00:00
|
|
|
|
$this->installer = &new PEAR_Installer($this->ui);
|
2002-05-21 01:27:53 +00:00
|
|
|
|
}
|
|
|
|
|
if ($command == 'upgrade') {
|
|
|
|
|
$options[$command] = true;
|
|
|
|
|
}
|
2002-07-28 08:52:55 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-05-21 01:27:53 +00:00
|
|
|
|
foreach ($params as $pkg) {
|
|
|
|
|
$bn = basename($pkg);
|
|
|
|
|
$info = $this->installer->install($pkg, $options, $this->config);
|
|
|
|
|
if (is_array($info)) {
|
|
|
|
|
if ($this->config->get('verbose') > 0) {
|
|
|
|
|
$label = "$info[package] $info[version]";
|
2002-11-13 14:17:26 +00:00
|
|
|
|
$out = array('data' => "$command ok: $label");
|
|
|
|
|
if (isset($info['release_warnings'])) {
|
|
|
|
|
$out['release_warnings'] = $info['release_warnings'];
|
|
|
|
|
}
|
|
|
|
|
$this->ui->outputData($out, $command);
|
2002-03-01 09:43:18 +00:00
|
|
|
|
}
|
2002-05-21 01:27:53 +00:00
|
|
|
|
} else {
|
|
|
|
|
return $this->raiseError("$command failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-06-02 13:07:19 +00:00
|
|
|
|
return true;
|
2002-05-21 01:27:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-26 21:49:55 +00:00
|
|
|
|
// }}}
|
|
|
|
|
// {{{ doUninstall()
|
|
|
|
|
|
2002-05-21 01:27:53 +00:00
|
|
|
|
function doUninstall($command, $options, $params)
|
|
|
|
|
{
|
|
|
|
|
if (empty($this->installer)) {
|
2002-06-02 13:07:19 +00:00
|
|
|
|
$this->installer = &new PEAR_Installer($this->ui);
|
2002-02-23 15:32:36 +00:00
|
|
|
|
}
|
2002-06-19 23:38:59 +00:00
|
|
|
|
if (sizeof($params) < 1) {
|
|
|
|
|
return $this->raiseError("Please supply the package(s) you want to uninstall");
|
|
|
|
|
}
|
2002-05-21 01:27:53 +00:00
|
|
|
|
foreach ($params as $pkg) {
|
|
|
|
|
if ($this->installer->uninstall($pkg, $options)) {
|
|
|
|
|
if ($this->config->get('verbose') > 0) {
|
2002-09-09 21:45:40 +00:00
|
|
|
|
$this->ui->outputData("uninstall ok: $pkg", $command);
|
2002-05-21 01:27:53 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2002-09-09 21:45:40 +00:00
|
|
|
|
return $this->raiseError("uninstall failed: $pkg");
|
2002-05-21 01:27:53 +00:00
|
|
|
|
}
|
2002-03-18 17:39:52 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
2002-02-23 15:32:36 +00:00
|
|
|
|
}
|
2002-03-18 17:39:52 +00:00
|
|
|
|
|
2002-11-26 21:49:55 +00:00
|
|
|
|
// }}}
|
2002-02-23 15:32:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-13 14:17:26 +00:00
|
|
|
|
?>
|