diff options
author | Tomas V.V.Cox <cox@php.net> | 2001-05-22 16:21:02 +0000 |
---|---|---|
committer | Tomas V.V.Cox <cox@php.net> | 2001-05-22 16:21:02 +0000 |
commit | a3d92b745a3236c7c113170c38ee2a1b595f6bce (patch) | |
tree | b50214092c2220bcbaa7222f7a20dbc5fa86f601 /pear | |
parent | 311278f273a7d39e07c8b23c028e97a3b11df9e5 (diff) | |
download | php-git-a3d92b745a3236c7c113170c38ee2a1b595f6bce.tar.gz |
- Added the following params support:
* -p set script install dir
* -e set extension install dir
* -d set documentation dest dir
* -v set verbose level
- Some error reporting clean up
- Added the standar PHP copyright header and authors
Diffstat (limited to 'pear')
-rw-r--r-- | pear/scripts/pear.in | 91 |
1 files changed, 71 insertions, 20 deletions
diff --git a/pear/scripts/pear.in b/pear/scripts/pear.in index 2cf5746969..b420a01e1d 100644 --- a/pear/scripts/pear.in +++ b/pear/scripts/pear.in @@ -1,38 +1,85 @@ #!@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/Installer.php'; +require_once 'PEAR/Packager.php'; +require_once 'Console/Getopt.php'; -require_once "PEAR.php"; -require_once "PEAR/Installer.php"; -require_once "PEAR/Packager.php"; -require_once "Console/Getopt.php"; +error_reporting(E_ALL ^ E_NOTICE); -error_reporting(7); - -$stderr = fopen("php://stderr", "w"); - -PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "usage"); - -$options = Console_Getopt::getopt($argv, "hv:?"); +$options = Console_Getopt::getopt($argv, "hv:?e:p:d:"); if (PEAR::isError($options)) { usage($options); } -PEAR::setErrorHandling(PEAR_ERROR_PRINT); +$opts = $options[0]; +foreach ($opts as $opt) { + $param = $opt[1]; + switch ($opt[0]) { + case 'v': + $verbose = $param; + break; + case 'e': + if ($param[0] != DIRECTORY_SEPARATOR) { + usage (new PEAR_Error("no absolute path (ej. /usr/lib/php)\n")); + } + $ext_dir = $param; + break; + case 'p': + if ($param[0] != DIRECTORY_SEPARATOR) { + usage (new PEAR_Error("no absolute path (ej. /usr/lib/php)\n")); + } + $script_dir = $param; + break; + case 'd': + if ($param[0] != DIRECTORY_SEPARATOR) { + usage (new PEAR_Error("no absolute path (ej. /usr/lib/php)\n")); + } + $doc_dir = $param; + break; + } +} +$verbose = (isset($verbose)) ? $verbose : 1; +$script_dir = (isset($script_dir)) ? $script_dir : PEAR_INSTALL_DIR; +$ext_dir = (isset($ext_dir)) ? $ext_dir : PEAR_EXTENSION_DIR; +$doc_dir = (isset($doc_dir)) ? $doc_dir : ''; + +PEAR::setErrorHandling(PEAR_ERROR_PRINT); $command = $options[1][1]; switch ($command) { - case "install": + case 'install': $package = $options[1][2]; - $installer =& new PEAR_Installer(); + $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; - case "package": + case 'package': $pkginfofile = $options[1][2]; - $packager =& new PEAR_Packager(); + $packager =& new PEAR_Packager($script_dir, $ext_dir, $doc_dir); + $packager->debug = $verbose; if (PEAR::isError($packager->Package($pkginfofile))) { print "\npackage failed\n"; } else { @@ -46,19 +93,23 @@ switch ($command) { function usage($obj = null) { - global $stderr; + $stderr = fopen('php://stderr', 'w'); if ($obj !== null) { fputs($stderr, $obj->getMessage()); } fputs($stderr, - "Usage: pear [-v n] [-h] command <parameters>\n". + "Usage: pear [-v n] [-h] [-p <dir>] [-e <dir>] [-d <dir>] command <parameters>\n". "Options:\n". - " -v set verbosity level to <n> (0-2, default 1)\n". - " -h display help/usage (this message)\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; } |