2001-04-17 01:17:59 +00:00
|
|
|
#!@prefix@/bin/php -Cq
|
2000-07-17 22:52:08 +00:00
|
|
|
<?php // -*- C++ -*-
|
2001-05-22 16:21:02 +00:00
|
|
|
//
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | 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';
|
2001-10-26 10:07:43 +00:00
|
|
|
require_once 'PEAR/Config.php';
|
2001-05-22 16:21:02 +00:00
|
|
|
require_once 'Console/Getopt.php';
|
2000-07-17 22:52:08 +00:00
|
|
|
|
2001-05-22 16:21:02 +00:00
|
|
|
error_reporting(E_ALL ^ E_NOTICE);
|
2000-07-17 22:52:08 +00:00
|
|
|
|
2001-10-26 10:07:43 +00:00
|
|
|
// {{{ config file and option parsing
|
|
|
|
|
|
|
|
$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sS");
|
2001-04-17 01:17:59 +00:00
|
|
|
if (PEAR::isError($options)) {
|
|
|
|
usage($options);
|
2000-07-17 22:52:08 +00:00
|
|
|
}
|
|
|
|
|
2001-10-26 10:07:43 +00:00
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
2001-05-22 16:21:02 +00:00
|
|
|
$opts = $options[0];
|
2001-10-26 10:07:43 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2001-05-22 16:21:02 +00:00
|
|
|
foreach ($opts as $opt) {
|
|
|
|
$param = $opt[1];
|
|
|
|
switch ($opt[0]) {
|
2001-10-26 10:07:43 +00:00
|
|
|
case 'd':
|
|
|
|
list($key, $value) = explode('=', $param);
|
|
|
|
$config->set($key, $value);
|
2001-05-22 16:21:02 +00:00
|
|
|
break;
|
2001-10-26 10:07:43 +00:00
|
|
|
case 'D':
|
|
|
|
list($key, $value) = explode('=', $param);
|
|
|
|
$config->set($key, $value, true);
|
2001-05-22 16:21:02 +00:00
|
|
|
break;
|
2001-10-26 10:07:43 +00:00
|
|
|
case 's':
|
|
|
|
$store_user_config = true;
|
2001-05-22 16:21:02 +00:00
|
|
|
break;
|
2001-10-26 10:07:43 +00:00
|
|
|
case 'S':
|
|
|
|
$store_default_config = true;
|
2001-05-22 16:21:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-04-17 01:17:59 +00:00
|
|
|
|
2001-10-26 10:07:43 +00:00
|
|
|
$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");
|
2001-05-22 16:21:02 +00:00
|
|
|
|
2001-04-17 01:17:59 +00:00
|
|
|
$command = $options[1][1];
|
|
|
|
switch ($command) {
|
2001-10-26 10:07:43 +00:00
|
|
|
// {{{ install
|
|
|
|
|
|
|
|
case 'install': {
|
2001-07-17 20:46:16 +00:00
|
|
|
include_once 'PEAR/Installer.php';
|
2001-04-17 01:17:59 +00:00
|
|
|
$package = $options[1][2];
|
2001-05-22 16:21:02 +00:00
|
|
|
$installer =& new PEAR_Installer($script_dir, $ext_dir, $doc_dir);
|
|
|
|
$installer->debug = $verbose;
|
2001-04-17 02:33:45 +00:00
|
|
|
if (PEAR::isError($installer->Install($package))) {
|
|
|
|
print "\ninstall failed\n";
|
|
|
|
} else {
|
|
|
|
print "install ok\n";
|
|
|
|
}
|
2001-04-17 01:17:59 +00:00
|
|
|
break;
|
2001-10-26 10:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// {{{ package
|
|
|
|
|
|
|
|
case 'package': {
|
2001-07-17 20:46:16 +00:00
|
|
|
include_once 'PEAR/Packager.php';
|
2001-04-17 01:17:59 +00:00
|
|
|
$pkginfofile = $options[1][2];
|
2001-05-22 16:21:02 +00:00
|
|
|
$packager =& new PEAR_Packager($script_dir, $ext_dir, $doc_dir);
|
|
|
|
$packager->debug = $verbose;
|
2001-04-17 02:33:45 +00:00
|
|
|
if (PEAR::isError($packager->Package($pkginfofile))) {
|
|
|
|
print "\npackage failed\n";
|
|
|
|
} else {
|
|
|
|
print "package ok\n";
|
|
|
|
}
|
2001-04-17 01:17:59 +00:00
|
|
|
break;
|
2001-10-26 10:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// {{{ list-packages
|
|
|
|
|
|
|
|
case 'list-packages': {
|
|
|
|
include_once 'PEAR/Remote.php';
|
|
|
|
$remote = new PEAR_Remote($config);
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
default: {
|
|
|
|
if (!$store_default_config && !$store_user_config) {
|
|
|
|
usage();
|
|
|
|
}
|
2001-04-17 01:17:59 +00:00
|
|
|
break;
|
2001-10-26 10:07:43 +00:00
|
|
|
}
|
2001-04-17 01:17:59 +00:00
|
|
|
}
|
2000-07-24 23:55:34 +00:00
|
|
|
|
2001-10-26 10:07:43 +00:00
|
|
|
// {{{ usage()
|
|
|
|
|
|
|
|
function usage($error = null)
|
2001-01-08 02:45:30 +00:00
|
|
|
{
|
2001-05-22 16:21:02 +00:00
|
|
|
$stderr = fopen('php://stderr', 'w');
|
2001-10-26 10:07:43 +00:00
|
|
|
if (PEAR::isError($obj)) {
|
|
|
|
fputs($stderr, $error->getMessage());
|
|
|
|
} elseif ($obj !== null) {
|
|
|
|
fputs($stderr, $error);
|
2001-04-17 01:17:59 +00:00
|
|
|
}
|
2001-01-08 02:45:30 +00:00
|
|
|
fputs($stderr,
|
2001-10-26 10:07:43 +00:00
|
|
|
"Usage: pear [options] command <parameters>\n".
|
2001-01-08 02:45:30 +00:00
|
|
|
"Options:\n".
|
2001-05-22 16:21:02 +00:00
|
|
|
" -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".
|
2001-05-23 14:38:09 +00:00
|
|
|
" -h, -? display help/usage (this message)\n".
|
2001-04-17 01:17:59 +00:00
|
|
|
"Commands:\n".
|
|
|
|
" install <package file>\n".
|
|
|
|
" package [package info file]\n".
|
|
|
|
"\n");
|
2001-05-22 16:21:02 +00:00
|
|
|
fclose($stderr);
|
2001-01-08 02:45:30 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2001-10-26 10:07:43 +00:00
|
|
|
// }}}
|
|
|
|
|
2000-07-17 22:52:08 +00:00
|
|
|
?>
|