2001-04-17 01:17:59 +00:00
|
|
|
#!@prefix@/bin/php -Cq
|
2000-07-17 22:52:08 +00:00
|
|
|
<?php // -*- C++ -*-
|
|
|
|
|
2000-07-24 23:55:34 +00:00
|
|
|
require_once "PEAR.php";
|
|
|
|
require_once "PEAR/Installer.php";
|
2001-04-17 01:17:59 +00:00
|
|
|
require_once "PEAR/Packager.php";
|
|
|
|
require_once "Console/Getopt.php";
|
2000-07-17 22:52:08 +00:00
|
|
|
|
2001-01-08 02:45:30 +00:00
|
|
|
error_reporting(7);
|
2000-07-17 22:52:08 +00:00
|
|
|
|
2001-01-08 02:45:30 +00:00
|
|
|
$stderr = fopen("php://stderr", "w");
|
|
|
|
|
2001-04-17 01:17:59 +00:00
|
|
|
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "usage");
|
2000-07-17 22:52:08 +00:00
|
|
|
|
2001-04-17 01:17:59 +00:00
|
|
|
$options = Console_Getopt::getopt($argv, "hv:?");
|
|
|
|
if (PEAR::isError($options)) {
|
|
|
|
usage($options);
|
2000-07-17 22:52:08 +00:00
|
|
|
}
|
|
|
|
|
2001-04-17 01:17:59 +00:00
|
|
|
PEAR::setErrorHandling(PEAR_ERROR_PRINT);
|
|
|
|
|
|
|
|
$command = $options[1][1];
|
|
|
|
switch ($command) {
|
|
|
|
case "install":
|
|
|
|
$package = $options[1][2];
|
|
|
|
$installer =& new PEAR_Installer();
|
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;
|
|
|
|
case "package":
|
|
|
|
$pkginfofile = $options[1][2];
|
|
|
|
$packager =& new PEAR_Packager();
|
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;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
break;
|
|
|
|
}
|
2000-07-24 23:55:34 +00:00
|
|
|
|
2001-04-17 01:17:59 +00:00
|
|
|
function usage($obj = null)
|
2001-01-08 02:45:30 +00:00
|
|
|
{
|
|
|
|
global $stderr;
|
2001-04-17 01:17:59 +00:00
|
|
|
if ($obj !== null) {
|
|
|
|
fputs($stderr, $obj->getMessage());
|
|
|
|
}
|
2001-01-08 02:45:30 +00:00
|
|
|
fputs($stderr,
|
2001-04-17 01:17:59 +00:00
|
|
|
"Usage: pear [-v n] [-h] command <parameters>\n".
|
2001-01-08 02:45:30 +00:00
|
|
|
"Options:\n".
|
|
|
|
" -v set verbosity level to <n> (0-2, default 1)\n".
|
2001-04-17 01:17:59 +00:00
|
|
|
" -h display help/usage (this message)\n".
|
|
|
|
"Commands:\n".
|
|
|
|
" install <package file>\n".
|
|
|
|
" package [package info file]\n".
|
|
|
|
"\n");
|
2001-01-08 02:45:30 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2000-07-17 22:52:08 +00:00
|
|
|
?>
|