diff options
Diffstat (limited to 'pear/PEAR/Command')
-rw-r--r-- | pear/PEAR/Command/Auth.php | 131 | ||||
-rw-r--r-- | pear/PEAR/Command/Common.php | 137 | ||||
-rw-r--r-- | pear/PEAR/Command/Config.php | 169 | ||||
-rw-r--r-- | pear/PEAR/Command/Install.php | 210 | ||||
-rw-r--r-- | pear/PEAR/Command/Package.php | 469 | ||||
-rw-r--r-- | pear/PEAR/Command/Registry.php | 161 | ||||
-rw-r--r-- | pear/PEAR/Command/Remote.php | 212 |
7 files changed, 0 insertions, 1489 deletions
diff --git a/pear/PEAR/Command/Auth.php b/pear/PEAR/Command/Auth.php deleted file mode 100644 index 5f99b2756e..0000000000 --- a/pear/PEAR/Command/Auth.php +++ /dev/null @@ -1,131 +0,0 @@ -<?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. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "PEAR/Command/Common.php"; -require_once "PEAR/Remote.php"; -require_once "PEAR/Config.php"; - -/** - * PEAR commands for managing configuration data. - * - */ -class PEAR_Command_Auth extends PEAR_Command_Common -{ - var $commands = array( - 'login' => array( - 'summary' => 'Connects and authenticates to remote server', - 'function' => 'doLogin', - 'options' => array(), - 'doc' => 'To use functions in the installer that require any kind -of privilege, you need to log in first. The username and password you enter -here will be stored in your per-user PEAR configuration (~/.pearrc on -Unix-like systems). After logging in, your username and password will be -passed along in every subsequent operation on the remote server. -', - ), - 'logout' => array( - 'summary' => 'Logs out from the remote server', - 'function' => 'doLogout', - 'options' => array(), - 'doc' => 'Logs out from the remote server. -This command does not actually connect to the remote -server, it only deletes the stored username and password from your -user configuration. -', - ) - - ); - - /** - * PEAR_Command_Auth constructor. - * - * @access public - */ - function PEAR_Command_Auth(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - /** - * Execute the 'login' command. - * - * @param string $command command name - * - * @param array $options option_name => value - * - * @param array $params list of additional parameters - * - * @return bool TRUE on success, FALSE for unknown commands, or - * a PEAR error on failure - * - * @access public - */ - function doLogin($command, $options, $params) - { - $server = $this->config->get('master_server'); - $remote = new PEAR_Remote($this->config); - $username = $this->config->get('username'); - if (empty($username)) { - $username = @$_ENV['USER']; - } - $this->ui->displayLine("Logging in to $server."); - $username = trim($this->ui->userDialog('Username', 'text', $username)); - - $this->config->set('username', $username); - $password = trim($this->ui->userDialog('Password', 'password')); - $this->config->set('password', $password); - $remote->expectError(401); - $ok = $remote->call('logintest'); - $remote->popExpect(); - if ($ok === true) { - $this->ui->displayLine("Logged in."); - $this->config->store(); - } else { - $this->ui->displayLine("Login failed!"); - } - - } - - /** - * Execute the 'logout' command. - * - * @param string $command command name - * - * @param array $options option_name => value - * - * @param array $params list of additional parameters - * - * @return bool TRUE on success, FALSE for unknown commands, or - * a PEAR error on failure - * - * @access public - */ - function doLogout($command, $options, $params) - { - $server = $this->config->get('master_server'); - $this->ui->displayLine("Logging out from $server."); - $this->config->remove('username'); - $this->config->remove('password'); - $this->config->store(); - } - -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Common.php b/pear/PEAR/Command/Common.php deleted file mode 100644 index dc308c6896..0000000000 --- a/pear/PEAR/Command/Common.php +++ /dev/null @@ -1,137 +0,0 @@ -<?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. | -// +----------------------------------------------------------------------+ -// | Author: Stig Sæther Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "PEAR.php"; - -class PEAR_Command_Common extends PEAR -{ - // {{{ properties - - /** - * PEAR_Config object used to pass user system and configuration - * on when executing commands - * - * @var object - */ - var $config; - - /** - * User Interface object, for all interaction with the user. - * @var object - */ - var $ui; - - // }}} - // {{{ constructor - - /** - * PEAR_Command_Common constructor. - * - * @access public - */ - function PEAR_Command_Common(&$ui, &$config) - { - parent::PEAR(); - $this->config = &$config; - $this->ui = &$ui; - } - - // }}} - - // {{{ getCommands() - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - $ret = array(); - foreach (array_keys($this->commands) as $command) { - $ret[$command] = $this->commands[$command]['summary']; - } - return $ret; - } - - // }}} - // {{{ getOptions() - - function getOptions($command) - { - return @$this->commands[$command]['options']; - } - - // }}} - // {{{ getGetoptArgs() - - function getGetoptArgs($command, &$short_args, &$long_args) - { - $short_args = ""; - $long_args = array(); - if (empty($this->commands[$command])) { - return; - } - reset($this->commands[$command]); - while (list($option, $info) = each($this->commands[$command]['options'])) { - $larg = $sarg = ''; - if (isset($info['arg'])) { - if ($info['arg']{0} == '(') { - $larg = '=='; - $sarg = '::'; - $arg = substr($info['arg'], 1, -1); - } else { - $larg = '='; - $sarg = ':'; - $arg = $info['arg']; - } - } - if (isset($info['shortopt'])) { - $short_args .= $info['shortopt'] . $sarg; - } - $long_args[] = $option . $larg; - } - } - - // }}} - // {{{ getHelp() - - function getHelp($command) - { - $help = preg_replace('/{config\s+([^\}]+)}/e', "\$config->get('\1')", @$this->commands[$command]['doc']); - return $help; - } - - // }}} - // {{{ run() - - function run($command, $options, $params) - { - $func = @$this->commands[$command]['function']; - if (empty($func)) { - return $this->raiseError("unknown command `$command'"); - } - return $this->$func($command, $options, $params); - } - - // }}} -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Config.php b/pear/PEAR/Command/Config.php deleted file mode 100644 index 2775a306e9..0000000000 --- a/pear/PEAR/Command/Config.php +++ /dev/null @@ -1,169 +0,0 @@ -<?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. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "PEAR/Command/Common.php"; -require_once "PEAR/Config.php"; - -/** - * PEAR commands for managing configuration data. - * - */ -class PEAR_Command_Config extends PEAR_Command_Common -{ - var $commands = array( - 'config-show' => array( - 'summary' => 'Show All Settings', - 'options' => array(), - 'doc' => 'Displays all configuration values. An optional argument -may be used to tell which configuration layer to display. Valid -configuration layers are "user", "system" and "default". -', - ), - 'config-get' => array( - 'summary' => 'Show One Setting', - 'options' => array(), - 'doc' => 'Displays the value of one configuration parameter. The -first argument is the name of the parameter, an optional second argument -may be used to tell which configuration layer to look in. Valid configuration -layers are "user", "system" and "default". If no layer is specified, a value -will be picked from the first layer that defines the parameter, in the order -just specified. -', - ), - 'config-set' => array( - 'summary' => 'Change Setting', - 'options' => array(), - 'doc' => 'Sets the value of one configuration parameter. The first -argument is the name of the parameter, the second argument is the new value. -Some parameters are be subject to validation, and the command will fail with -an error message if the new value does not make sense. An optional third -argument may be used to specify which layer to set the configuration parameter -in. The default layer is "user". -', - ), - ); - - /** - * PEAR_Command_Config constructor. - * - * @access public - */ - function PEAR_Command_Config(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - function run($command, $options, $params) - { - $cf = &$this->config; - $failmsg = ''; - switch ($command) { - case 'config-show': { - // $params[0] -> the layer - if ($error = $this->_checkLayer(@$params[0])) { - $failmsg .= $error; - break; - } - $keys = $cf->getKeys(); - sort($keys); - $this->ui->startTable(array('caption' => 'Configuration:')); - foreach ($keys as $key) { - $type = $cf->getType($key); - $value = $cf->get($key, @$params[0]); - if ($type == 'password' && $value) { - $value = '********'; - } - if (empty($value)) { - $value = '<not set>'; - } - $this->ui->tableRow(array($key, $value)); - } - $this->ui->endTable(); - break; - } - case 'config-get': { - // $params[0] -> the parameter - // $params[1] -> the layer - if ($error = $this->_checkLayer(@$params[1])) { - $failmsg .= $error; - break; - } - if (sizeof($params) < 1 || sizeof($params) > 2) { - $failmsg .= "config-get expects 1 or 2 parameters. Try \"help config-get\" for help"; - } elseif (sizeof($params) == 1) { - $this->ui->displayLine("$params[0] = " . $cf->get($params[0])); - } else { - $this->ui->displayLine("($params[1])$params[0] = " . - $cf->get($params[0], $params[1])); - } - break; - } - case 'config-set': { - // $param[0] -> a parameter to set - // $param[1] -> the value for the parameter - // $param[2] -> the layer - if (sizeof($params) < 2 || sizeof($params) > 3) { - $failmsg .= "config-set expects 2 or 3 parameters. Try \"help config-set\" for help"; - break; - } - if ($error = $this->_checkLayer(@$params[2])) { - $failmsg .= $error; - break; - } - if (!call_user_func_array(array(&$cf, 'set'), $params)) - { - $failmsg = "config-set (" . implode(", ", $params) . ") failed"; - } else { - $cf->store(); - } - break; - } - default: { - return false; - } - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - /** - * Checks if a layer is defined or not - * - * @param string $layer The layer to search for - * @return mixed False on no error or the error message - */ - function _checkLayer($layer = null) - { - if (!empty($layer)) { - $layers = $this->config->getLayers(); - if (!in_array($layer, $layers)) { - return " only the layers: \"" . implode('" or "', $layers) . "\" are supported"; - } - } - return false; - } - -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php deleted file mode 100644 index d136e740a5..0000000000 --- a/pear/PEAR/Command/Install.php +++ /dev/null @@ -1,210 +0,0 @@ -<?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. | -// +----------------------------------------------------------------------+ -// | Author: Stig Sæther Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "PEAR/Command/Common.php"; -require_once "PEAR/Installer.php"; -require_once "Console/Getopt.php"; - -/** - * PEAR commands for installation or deinstallation/upgrading of - * packages. - * - */ -class PEAR_Command_Install extends PEAR_Command_Common -{ - // {{{ command definitions - - var $commands = array( - 'install' => array( - 'summary' => 'Install Package', - 'function' => 'doInstall', - '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', - ), - 'nocompress' => array( - 'shortopt' => 'Z', - 'doc' => 'request uncompressed files when downloading', - ), - ), - 'doc' => 'Installs one or more PEAR packages. You can specify a package to -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', - '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', - ), - 'nocompress' => array( - 'shortopt' => 'Z', - 'request uncompressed files when downloading', - ), - ), - 'doc' => 'Upgrades one or more PEAR packages. See documentation for the -"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. -'), - 'uninstall' => array( - 'summary' => 'Un-install Package', - 'function' => 'doUninstall', - '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', - ), - ), - 'doc' => 'Upgrades one or more PEAR packages. See documentation for the -"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. -'), - - ); - - // }}} - // {{{ constructor - - /** - * PEAR_Command_Install constructor. - * - * @access public - */ - function PEAR_Command_Install(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - // }}} - - // {{{ getCommands() - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - $ret = array(); - foreach (array_keys($this->commands) as $command) { - $ret[$command] = $this->commands[$command]['summary']; - } - return $ret; - } - - // }}} - // {{{ run() - - function run($command, $options, $params) - { - $this->installer = &new PEAR_Installer($ui); -// return parent::run($command, $options, $params); - $failmsg = ''; - switch ($command) { - case 'upgrade': - $options['upgrade'] = true; - // fall through - case 'install': - foreach ($params as $pkg) { - $bn = basename($pkg); - $info = $this->installer->install($pkg, $options, $this->config); - if (is_array($info)) { - $label = "$info[package] $info[version]"; - $this->ui->displayLine("$command ok: $label"); - } else { - $failmsg = "$command failed"; - } - } - break; - case 'uninstall': - foreach ($params as $pkg) { - if ($this->installer->uninstall($pkg, $options)) { - $this->ui->displayLine("uninstall ok"); - } else { - $failmsg = "uninstall failed"; - } - } - break; - default: - return false; - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - // }}} -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Package.php b/pear/PEAR/Command/Package.php deleted file mode 100644 index d1cba6a6f7..0000000000 --- a/pear/PEAR/Command/Package.php +++ /dev/null @@ -1,469 +0,0 @@ -<?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. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR/Command/Common.php'; -require_once 'PEAR/Packager.php'; -require_once 'PEAR/Common.php'; - -class PEAR_Command_Package extends PEAR_Command_Common -{ - var $commands = array( - 'package' => array( - 'summary' => 'Build Package', - 'function' => 'doPackage', - 'options' => array( - 'nocompress' => array( - 'shortopt' => 'Z', - 'doc' => 'Do not gzip the package file' - ), - '???' => array( - 'shortopt' => 'n', - 'doc' => 'Return only the created package file name. Useful for -shell script operations. -', - ), - ), - 'doc' => 'Creates a PEAR package from its description file (usually -called package.xml). -' - ), - 'package-info' => array( - 'summary' => 'Display information about a package file', - 'function' => 'doPackageInfo', - 'options' => array(), - 'doc' => 'Extracts information from a package file and displays it. -', - ), - 'package-list' => array( - 'summary' => 'List Files in Package', - 'function' => 'doPackageList', - 'options' => array(), - 'doc' => '', - ), - 'package-validate' => array( - 'summary' => 'Validate Package Consistency', - 'function' => 'doPackageValidate', - 'options' => array(), - 'doc' => '', - ), - 'cvstag' => array( - 'summary' => 'Set CVS Release Tag', - 'function' => 'doCvsTag', - 'options' => array(), - 'doc' => '', - ), - 'run-tests' => array( - 'summary' => 'Run Regression Tests', - 'function' => 'doRunTests', - 'options' => array(), - 'doc' => '', - ), - ); - - /** - * PEAR_Command_Package constructor. - * - * @access public - */ - function PEAR_Command_Package(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - function _displayValidationResults($err, $warn, $strict = false) - { - foreach ($err as $e) { - $this->ui->displayLine("Error: $e"); - } - foreach ($warn as $w) { - $this->ui->displayLine("Warning: $w"); - } - $this->ui->displayLine(sprintf('Validation: %d error(s), %d warning(s)', - sizeof($err), sizeof($warn))); - if ($strict && sizeof($err) > 0) { - $this->ui->displayLine("Fix these errors and try again."); - return false; - } - return true; - } - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - return array('package' => 'Build Package', - 'package-info' => 'Show Package Info', - 'package-list' => 'List Files in Package', - 'package-validate' => 'Validate Package', - 'cvstag' => 'Set CVS Release Tag', - 'run-tests' => 'Run Regression Tests'); - } - - // {{{ getOptions() - - function getOptions() - { - return array('Z', 'n', 'F' /*, 'd', 'q', 'Q'*/); - } - - // }}} - // {{{ getHelp() - - function getHelp($command) - { - switch ($command) { - case 'package': - return array('[-n] [<package.xml>]', - 'Creates a PEAR package from its description file (usually '. - "named as package.xml)\n". - " -n Return only the created package file name. Useful for\n". - " shell script operations.\n". - " -Z Do not compress the tar package"); - case 'package-list': - return array('<pear package>', - 'List the contents (the files) of a PEAR package'); - case 'package-info': - return array('<pear package>', - 'Shows information about a PEAR package'); - case 'package-validate': - return array('<package.(tgz|tar|xml)>', - 'Verifies a package or description file'); - case 'cvstag': - return array('<package.xml>', - 'Runs "cvs tag" on files contained in a release'); - } - } - - // }}} - // {{{ run() - - /** - * Execute the command. - * - * @param string command name - * - * @param array option_name => value - * - * @param array list of additional parameters - * - * @return bool TRUE on success, FALSE for unknown commands, or - * a PEAR error on failure - * - * @access public - */ - function run($command, $options, $params) - { - $failmsg = ''; - switch ($command) { - case 'package': - case 'package-list': - case 'package-info': - case 'package-validate': - break; - // {{{ cvstag - - case 'cvstag': { - } - - // }}} - // {{{ run-tests - - case 'run-tests': { - break; - } - - // }}} - default: { - return false; - } - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - // }}} - - - function doPackage($command, $options, $params) - { - $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml'; - ob_start(); - $packager =& new PEAR_Packager($this->config->get('php_dir'), - $this->config->get('ext_dir'), - $this->config->get('doc_dir')); - $packager->debug = $this->config->get('verbose'); - $err = $warn = array(); - $packager->validatePackageInfo($pkginfofile, $err, $warn); - if (!$this->_displayValidationResults($err, $warn, true)) { - return; - } - $compress = empty($options['Z']) ? true : false; - $result = $packager->Package($pkginfofile, $compress); - $output = ob_get_contents(); - ob_end_clean(); - if (PEAR::isError($result)) { - return $this->raiseError($result); - } - // Don't want output, only the package file name just created - if (isset($options['n'])) { - $this->ui->displayLine($result); - return; - } - $lines = explode("\n", $output); - foreach ($lines as $line) { - $this->ui->displayLine($line); - } - if (PEAR::isError($result)) { - $this->ui->displayLine("Package failed: ".$result->getMessage()); - } - return true; - } - - - function doPackageList($command, $options, $params) - { - // $params[0] -> the PEAR package to list its files - if (sizeof($params) != 1) { - return $this->raiseError("bad parameters, try \"help $command\""); - } - $obj = new PEAR_Common(); - - if (PEAR::isError($info = $obj->infoFromTgzFile($params[0]))) { - return $info; - } - $list =$info['filelist']; - $caption = 'Contents of ' . basename($params[0]); - $this->ui->startTable(array('caption' => $caption, - 'border' => true)); - $this->ui->tableRow(array('Package Files', 'Install Destination'), - array('bold' => true)); - foreach ($list as $file => $att) { - if (isset($att['baseinstalldir'])) { - $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . - $file; - } else { - $dest = $file; - } - switch ($att['role']) { - case 'test': - $dest = '-- will not be installed --'; break; - case 'doc': - $dest = $this->config->get('doc_dir') . DIRECTORY_SEPARATOR . - $dest; - break; - case 'php': - default: - $dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . - $dest; - } - $dest = preg_replace('!/+!', '/', $dest); - $file = preg_replace('!/+!', '/', $file); - $opts = array(0 => array('wrap' => 23), - 1 => array('wrap' => 45) - ); - $this->ui->tableRow(array($file, $dest), null, $opts); - } - $this->ui->endTable(); - return true; - } - - function doPackageInfo($command, $options, $params) - { - // $params[0] -> the PEAR package to list its information - if (sizeof($params) != 1) { - return $this->raiseError("bad parameter(s), try \"help $command\""); - } - - $obj = new PEAR_Common(); - if (PEAR::isError($info = $obj->infoFromTgzFile($params[0]))) { - return $info; - } - unset($info['filelist']); - unset($info['changelog']); - $keys = array_keys($info); - $longtext = array('description', 'summary'); - foreach ($keys as $key) { - if (is_array($info[$key])) { - switch ($key) { - case 'maintainers': { - $i = 0; - $mstr = ''; - foreach ($info[$key] as $m) { - if ($i++ > 0) { - $mstr .= "\n"; - } - $mstr .= $m['name'] . " <"; - if (isset($m['email'])) { - $mstr .= $m['email']; - } else { - $mstr .= $m['handle'] . '@php.net'; - } - $mstr .= "> ($m[role])"; - } - $info[$key] = $mstr; - break; - } - case 'release_deps': { - static $rel_trans = array( - 'lt' => '<', - 'le' => '<=', - 'eq' => '=', - 'ne' => '!=', - 'gt' => '>', - 'ge' => '>=', - ); - $i = 0; - $dstr = ''; - foreach ($info[$key] as $d) { - if ($i++ > 0) { - $dstr .= ", "; - } - if (isset($rel_trans[$d['rel']])) { - $d['rel'] = $rel_trans[$d['rel']]; - } - $dstr .= "$d[type] $d[rel]"; - if (isset($d['version'])) { - $dstr .= " $d[version]"; - } - } - $info[$key] = $dstr; - break; - } - default: { - $info[$key] = implode(", ", $info[$key]); - break; - } - } - } - $info[$key] = trim($info[$key]); - if (in_array($key, $longtext)) { - $info[$key] = preg_replace('/ +/', ' ', $info[$key]); - } - } - $caption = 'About ' . basename($params[0]); - $this->ui->startTable(array('caption' => $caption, - 'border' => true)); - foreach ($info as $key => $value) { - $key = ucwords(str_replace('_', ' ', $key)); - $this->ui->tableRow(array($key, $value), null, array(1 => array('wrap' => 55))); - } - $this->ui->endTable(); - return true; - } - - function doPackageValidate($command, $options, $params) - { - if (sizeof($params) < 1) { - $params[0] = "package.xml"; - } - $obj = new PEAR_Common; - $info = null; - if (file_exists($params[0])) { - $fp = fopen($params[0], "r"); - $test = fread($fp, 5); - fclose($fp); - if ($test == "<?xml") { - $info = $obj->infoFromDescriptionFile($params[0]); - } - } - if (empty($info)) { - $info = $obj->infoFromTgzFile($params[0]); - } - if (PEAR::isError($info)) { - return $this->raiseError($info); - } - $obj->validatePackageInfo($info, $err, $warn); - $this->_displayValidationResults($err, $warn); - return true; - } - - function doCvsTag($command, $options, $params) - { - if (sizeof($params) < 1) { - $help = $this->getHelp($command); - return $this->raiseError("$command: missing parameter: $help[0]"); - } - $obj = new PEAR_Common; - $info = $obj->infoFromDescriptionFile($params[0]); - if (PEAR::isError($info)) { - return $this->raiseError($info); - } - $err = $warn = array(); - $obj->validatePackageInfo($info, $err, $warn); - if (!$this->_displayValidationResults($err, $warn, true)) { - break; - } - $version = $info['version']; - $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version); - $cvstag = "RELEASE_$cvsversion"; - $files = array_keys($info['filelist']); - $command = "cvs"; - if (isset($options['q'])) { - $command .= ' -q'; - } - if (isset($options['Q'])) { - $command .= ' -Q'; - } - $command .= ' tag'; - if (isset($options['F'])) { - $command .= ' -F'; - } - if (isset($options['d'])) { - $command .= ' -d'; - } - $command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]); - foreach ($files as $file) { - $command .= ' ' . escapeshellarg($file); - } - $this->ui->displayLine("+ $command"); - if (empty($options['n'])) { - $fp = popen($command, "r"); - while ($line = fgets($fp, 1024)) { - $this->ui->displayLine(rtrim($line)); - } - pclose($fp); - } - return true; - } - - function doRunTests($command, $options, $params) - { - $cwd = getcwd(); - $php = PHP_BINDIR . '/php' . (OS_WINDOWS ? '.exe' : ''); - putenv("TEST_PHP_EXECUTABLE=$php"); - $ip = ini_get("include_path"); - $ps = OS_WINDOWS ? ';' : ':'; - $run_tests = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . 'run-tests.php'; - if (!file_exists($run_tests)) { - $run_tests = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . 'run-tests.php'; - } - $plist = implode(" ", $params); - $cmd = "$php -d include_path=$cwd$ps$ip $run_tests $plist"; - system($cmd); - return true; - } -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Registry.php b/pear/PEAR/Command/Registry.php deleted file mode 100644 index be5bf182a8..0000000000 --- a/pear/PEAR/Command/Registry.php +++ /dev/null @@ -1,161 +0,0 @@ -<?php -// /* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR/Command/Common.php'; -require_once 'PEAR/Registry.php'; -require_once 'PEAR/Config.php'; - -class PEAR_Command_Registry extends PEAR_Command_Common -{ - // {{{ constructor - - /** - * PEAR_Command_Registry constructor. - * - * @access public - */ - function PEAR_Command_Registry(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - // }}} - - // {{{ getCommands() - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - return array('list-installed' => 'List Installed Packages', - 'shell-test' => 'Shell Script Test'); - } - - function getHelp($command) - { - switch ($command) { - case 'list-installed': - return array(null, 'List the installed PEAR packages in the system'); - case 'shell-test': - return array('<package name> [<relation>] [<version>]', - "Tests if a package is installed in the system. Will exit(1) if it is not.\n". - " <relation> The version comparison operator. One of:\n". - " <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne\n". - " <version> The version to compare with"); - } - } - - // }}} - // {{{ run() - - /** - * Execute the command. - * - * @param string command name - * - * @param array option_name => value - * - * @param array list of additional parameters - * - * @return bool TRUE on success, FALSE if the command was unknown, - * or a PEAR error on failure - * - * @access public - */ - function run($command, $options, $params) - { - $failmsg = ''; - $cf = &PEAR_Config::singleton(); - switch ($command) { - // {{{ list-installed - - case 'list-installed': { - $reg = new PEAR_Registry($cf->get('php_dir')); - $installed = $reg->packageInfo(); - $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Installed packages:', - 'border' => true)); - foreach ($installed as $package) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version', 'State'), - array('bold' => true)); - } - $this->ui->tableRow(array($package['package'], - $package['version'], - @$package['release_state'])); - } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed yet)')); - } - $this->ui->endTable(); - break; - } - - // }}} - case 'shell-test': { - // silence error messages for the rest of the execution - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $reg = &new PEAR_Registry($this->config->get('php_dir')); - // "pear shell-test Foo" - if (sizeof($params) == 1) { - if (!$reg->packageExists($params[0])) { - exit(1); - } - // "pear shell-test Foo 1.0" - } elseif (sizeof($params) == 2) { - $v = $reg->packageInfo($params[0], 'version'); - if (!$v || !version_compare($v, $params[1], "ge")) { - exit(1); - } - // "pear shell-test Foo ge 1.0" - } elseif (sizeof($params) == 3) { - $v = $reg->packageInfo($params[0], 'version'); - if (!$v || !version_compare($v, $params[2], $params[1])) { - exit(1); - } - } else { - PEAR::popErrorHandling(); - PEAR::raiseError("$command: expects 1 to 3 parameters"); - exit(1); - } - break; - } - default: { - return false; - } - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - // }}} - - -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php deleted file mode 100644 index def57a4be1..0000000000 --- a/pear/PEAR/Command/Remote.php +++ /dev/null @@ -1,212 +0,0 @@ -<?php -// /* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR/Command/Common.php'; -require_once 'PEAR/Common.php'; -require_once 'PEAR/Remote.php'; - -class PEAR_Command_Remote extends PEAR_Command_Common -{ - // {{{ constructor - - /** - * PEAR_Command_Remote constructor. - * - * @access public - */ - function PEAR_Command_Remote(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - // }}} - - // {{{ getCommands() - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - return array('remote-package-info' => 'Information About Remote Package', - 'list-upgrades' => 'List Available Upgrades', - 'list-remote-packages' => 'List Remote Packages', - 'download' => 'Download Package'); - } - - // }}} - // {{{ run() - - /** - * Execute the command. - * - * @param string command name - * - * @param array option_name => value - * - * @param array list of additional parameters - * - * @return bool TRUE on success, FALSE for unknown commands, or - * a PEAR error on failure - * - * @access public - */ - function run($command, $options, $params) - { - $failmsg = ''; - $remote = &new PEAR_Remote($this->config); - switch ($command) { - // {{{ remote-package-info - - case 'remote-package-info': { - break; - } - - // }}} - // {{{ list-remote-packages - - case 'list-remote-packages': { - $r = new PEAR_Remote($this->config); - $available = $r->call('package.listAll', true); - if (PEAR::isError($available)) { - return $this->raiseError($available); - } - $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Available packages:', - 'border' => true)); - foreach ($available as $name => $info) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version'), - array('bold' => true)); - } - $this->ui->tableRow(array($name, $info['stable'])); - } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed yet)')); - } - $this->ui->endTable(); - break; - } - - // }}} - // {{{ download - - case 'download': { - //$params[0] -> The package to download - if (count($params) != 1) { - return PEAR::raiseError("download expects one argument: the package to download"); - } - $server = $this->config->get('master_server'); - if (!ereg('^http://', $params[0])) { - $pkgfile = "http://$server/get/$params[0]"; - } else { - $pkgfile = $params[0]; - } - $this->bytes_downloaded = 0; - $saved = PEAR_Common::downloadHttp($pkgfile, $this->ui, '.', - array(&$this, 'downloadCallback')); - if (PEAR::isError($saved)) { - return $this->raiseError($saved); - } - $fname = basename($saved); - $this->ui->displayLine("File $fname downloaded ($this->bytes_downloaded bytes)"); - break; - } - - // }}} - // {{{ list-upgrades - - case 'list-upgrades': { - include_once "PEAR/Registry.php"; - if (empty($params[0])) { - $state = $this->config->get('preferred_state'); - } else { - $state = $params[0]; - } - $caption = 'Available Upgrades'; - if (empty($state) || $state == 'any') { - $latest = $remote->call("package.listLatestReleases"); - } else { - $latest = $remote->call("package.listLatestReleases", $state); - $caption .= ' (' . $state . ')'; - } - $caption .= ':'; - if (PEAR::isError($latest)) { - return $latest; - } - $reg = new PEAR_Registry($this->config->get('php_dir')); - $inst = array_flip($reg->listPackages()); - $this->ui->startTable(array('caption' => $caption, - 'border' => 1)); - $this->ui->tableRow(array('Package', 'Version', 'Size'), - array('bold' => true)); - foreach ($latest as $package => $info) { - if (!isset($inst[$package])) { - // skip packages we don't have installed - continue; - } - extract($info); - $inst_version = $reg->packageInfo($package, 'version'); - if (version_compare($version, $inst_version, "le")) { - // installed version is up-to-date - continue; - } - if ($filesize >= 20480) { - $filesize += 1024 - ($filesize % 1024); - $fs = sprintf("%dkB", $filesize / 1024); - } elseif ($filesize > 0) { - $filesize += 103 - ($filesize % 103); - $fs = sprintf("%.1fkB", $filesize / 1024.0); - } else { - $fs = " -"; // XXX center instead - } - $this->ui->tableRow(array($package, $version, $fs)); - } - $this->ui->endTable(); - break; - } - - // }}} - default: { - return false; - } - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - // }}} - - function downloadCallback($msg, $params = null) - { - if ($msg == 'done') { - $this->bytes_downloaded = $params; - } - } -} - -?>
\ No newline at end of file |