2002-02-23 15:32:36 +00:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | PHP Version 4 |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | Copyright (c) 1997-2002 The PHP Group |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | 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-02-28 08:29:35 +00:00
|
|
|
// | Author: Stig Bakken <ssb@fast.no> |
|
2002-02-23 15:32:36 +00:00
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
require_once "PEAR/Command/Common.php";
|
|
|
|
require_once "PEAR/Installer.php";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PEAR commands for installation or deinstallation/upgrading of
|
|
|
|
* packages.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class PEAR_Command_Install extends PEAR_Command_Common
|
|
|
|
{
|
2002-03-18 17:39:52 +00:00
|
|
|
// {{{ properties
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ 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
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ getCommands()
|
|
|
|
|
2002-02-23 15:32:36 +00:00
|
|
|
/**
|
|
|
|
* Return a list of all the commands defined by this class.
|
|
|
|
* @return array list of commands
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
function getCommands()
|
|
|
|
{
|
|
|
|
return array('install', 'uninstall', 'upgrade');
|
|
|
|
}
|
|
|
|
|
2002-03-18 17:39:52 +00:00
|
|
|
// }}}
|
|
|
|
// {{{ run()
|
|
|
|
|
2002-03-21 20:52:26 +00:00
|
|
|
function run($command, $options, $params)
|
2002-02-23 15:32:36 +00:00
|
|
|
{
|
2002-03-23 10:20:41 +00:00
|
|
|
$installer = &new PEAR_Installer($this->config->get('php_dir'),
|
2002-03-21 11:10:17 +00:00
|
|
|
$this->config->get('ext_dir'),
|
|
|
|
$this->config->get('doc_dir'));
|
|
|
|
$installer->debug = $this->config->get('verbose');
|
2002-03-22 09:22:28 +00:00
|
|
|
|
2002-03-18 17:39:52 +00:00
|
|
|
$failmsg = '';
|
2002-03-21 20:52:26 +00:00
|
|
|
$opts = array();
|
2002-02-23 15:32:36 +00:00
|
|
|
switch ($command) {
|
2002-03-23 15:56:14 +00:00
|
|
|
case 'upgrade':
|
2002-03-23 10:20:41 +00:00
|
|
|
$opts['upgrade'] = true;
|
|
|
|
// fall through
|
2002-03-23 15:56:14 +00:00
|
|
|
case 'install': {
|
2002-03-21 20:52:26 +00:00
|
|
|
if (isset($options['f'])) {
|
|
|
|
$opts['force'] = true;
|
2002-02-23 15:32:36 +00:00
|
|
|
}
|
2002-03-21 22:29:03 +00:00
|
|
|
// XXX The ['nodeps'] option is still missing
|
2002-03-21 20:52:26 +00:00
|
|
|
if ($installer->install(@$params[0], $opts, $this->config)) {
|
2002-03-18 17:39:52 +00:00
|
|
|
$this->ui->displayLine("install ok");
|
2002-03-01 09:43:18 +00:00
|
|
|
} else {
|
2002-03-18 17:39:52 +00:00
|
|
|
$failmsg = "install failed";
|
2002-03-01 09:43:18 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-02-23 15:32:36 +00:00
|
|
|
}
|
2002-03-01 09:43:18 +00:00
|
|
|
case 'uninstall': {
|
2002-03-21 11:10:17 +00:00
|
|
|
if ($installer->uninstall($params[0], $options)) {
|
2002-03-18 17:39:52 +00:00
|
|
|
$this->ui->displayLine("uninstall ok");
|
2002-03-01 09:43:18 +00:00
|
|
|
} else {
|
2002-03-18 17:39:52 +00:00
|
|
|
$failmsg = "uninstall failed";
|
2002-03-01 09:43:18 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-03-21 11:10:17 +00:00
|
|
|
}
|
2002-03-18 17:39:52 +00:00
|
|
|
default: {
|
|
|
|
return false;
|
|
|
|
}
|
2002-02-23 15:32:36 +00:00
|
|
|
}
|
2002-03-18 17:39:52 +00:00
|
|
|
if ($failmsg) {
|
|
|
|
return $this->raiseError($failmsg);
|
|
|
|
}
|
|
|
|
return true;
|
2002-02-23 15:32:36 +00:00
|
|
|
}
|
2002-03-18 17:39:52 +00:00
|
|
|
|
|
|
|
// }}}
|
2002-03-21 20:52:26 +00:00
|
|
|
|
|
|
|
function getOptions()
|
|
|
|
{
|
|
|
|
return array('f');
|
|
|
|
}
|
2002-02-23 15:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|