diff options
Diffstat (limited to 'pear/scripts/pear.in')
-rw-r--r-- | pear/scripts/pear.in | 196 |
1 files changed, 0 insertions, 196 deletions
diff --git a/pear/scripts/pear.in b/pear/scripts/pear.in deleted file mode 100644 index ecdfa88102..0000000000 --- a/pear/scripts/pear.in +++ /dev/null @@ -1,196 +0,0 @@ -#!@prefix@/bin/php -Cq -<?php // -*- C++ -*- -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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. | -// +----------------------------------------------------------------------+ -// | Authors: Stig Bakken <ssb@fast.no> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// +----------------------------------------------------------------------+ -// -require_once 'PEAR.php'; -require_once 'PEAR/Config.php'; -require_once 'Console/Getopt.php'; - -error_reporting(E_ALL ^ E_NOTICE); - -// {{{ config file and option parsing - -$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sS"); -if (PEAR::isError($options)) { - usage($options); -} - -if (OS_WINDOWS) { - $pear_default_config = PHP_SYSCONFDIR.DIRECTORY_SEPARATOR.'pearsys.ini'; - $pear_user_config = PHP_SYSCONFDIR.DIRECTORY_SEPARATOR.'pear.ini'; -} else { - $pear_default_config = PHP_SYSCONFDIR.DIRECTORY_SEPARATOR.'pear.conf'; - $pear_user_config = $HTTP_ENV_VARS['HOME'].DIRECTORY_SEPARATOR.'.pearrc'; -} - -$opts = $options[0]; - -foreach ($opts as $opt) { - switch ($opt[0]) { - case 'c': - $pear_user_config = $opt[1]; - break; - case 'C': - $pear_default_config = $opt[1]; - break; - } -} - -$config = new PEAR_Config($pear_user_config, $pear_default_config); -$store_user_config = false; -$store_default_config = false; - -foreach ($opts as $opt) { - $param = $opt[1]; - switch ($opt[0]) { - case 'd': - list($key, $value) = explode('=', $param); - $config->set($key, $value); - break; - case 'D': - list($key, $value) = explode('=', $param); - $config->set($key, $value, true); - break; - case 's': - $store_user_config = true; - break; - case 'S': - $store_default_config = true; - break; - } -} - -$fallback_config = array( - 'php_dir' => PEAR_INSTALL_DIR, - 'ext_dir' => PEAR_EXTENSION_DIR, - 'doc_dir' => '', - 'verbose' => true, -); - -foreach ($fallback_config as $key => $value) { - if (!$config->isDefined($key)) { - $config->set($key, $value); - } -} - -$verbose = $config->get("verbose"); -$script_dir = $config->get("php_dir"); -$ext_dir = $config->get("ext_dir"); -$doc_dir = $config->get("doc_dir"); - -// }}} - -PEAR::setErrorHandling(PEAR_ERROR_PRINT, "pear: %s\n"); - -$command = $options[1][1]; -switch ($command) { - // {{{ install - - case 'install': { - include_once 'PEAR/Installer.php'; - $package = $options[1][2]; - $installer =& new PEAR_Installer($script_dir, $ext_dir, $doc_dir); - $installer->debug = $verbose; - if (PEAR::isError($installer->Install($package))) { - print "\ninstall failed\n"; - } else { - print "install ok\n"; - } - break; - } - - // }}} - // {{{ package - - case 'package': { - include_once 'PEAR/Packager.php'; - $pkginfofile = $options[1][2]; - $packager =& new PEAR_Packager($script_dir, $ext_dir, $doc_dir); - $packager->debug = $verbose; - if (PEAR::isError($packager->Package($pkginfofile))) { - print "\npackage failed\n"; - } else { - print "package ok\n"; - } - break; - } - - // }}} - // {{{ list-packages - - case 'list-packages': { - include_once 'PEAR/Remote.php'; - $remote = new PEAR_Remote($config); - $result = $remote->call('package.listAll'); - $i = $j = 0; - foreach ($result as $package) { - if ($i++ % 20 == 0) { - if ($j++ > 0) { - print "\n"; - } - printf("%-20s %-10s %-15s %s\n", - "Package", "Stable", "Lead", "Category"); - print str_repeat("=", 75)."\n"; - } - $stable = $package['stable']; - printf("%-20s %-10s %-15s %s\n", $package['name'], - $stable ? $stable : "???", - $package['lead'], $package['category']); - } - break; - } - - // }}} - default: { - if (!$store_default_config && !$store_user_config) { - usage(); - } - break; - } -} - -// {{{ usage() - -function usage($error = null) -{ - $stderr = fopen('php://stderr', 'w'); - if (PEAR::isError($obj)) { - fputs($stderr, $error->getMessage()); - } elseif ($obj !== null) { - fputs($stderr, $error); - } - fputs($stderr, - "Usage: pear [options] command <parameters>\n". - "Options:\n". - " -v set verbosity level to <n> (0-2, default 1)\n". - " -p <dir> set script install dir (absolute path)\n". - " -e <dir> set extension install dir (absolute path)\n". - " -d <dir> set documentation dest dir (absolute path)\n". - " -h, -? display help/usage (this message)\n". - "Commands:\n". - " install <package file>\n". - " package [package info file]\n". - "\n"); - fclose($stderr); - exit; -} - -// }}} - -?> |