From: Alexander Merz Date: Fri, 12 Oct 2001 19:43:58 +0000 (+0000) Subject: win version of pear the pear script X-Git-Tag: POST_PARAMETER_PARSING_API~130 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=262bcc637df560bc81833c4917c860810ce97889;p=php win version of pear the pear script --- diff --git a/pear/scripts/pear.bat b/pear/scripts/pear.bat new file mode 100755 index 0000000000..5729d2eba0 --- /dev/null +++ b/pear/scripts/pear.bat @@ -0,0 +1,31 @@ +@ECHO OFF + +REM ---------------------------------------------------------------------- +REM PHP version 4.0 +REM ---------------------------------------------------------------------- +REM Copyright (c) 1997-2001 The PHP Group +REM ---------------------------------------------------------------------- +REM This source file is subject to version 2.02 of the PHP license, +REM that is bundled with this package in the file LICENSE, and is +REM available at through the world-wide-web at +REM http://www.php.net/license/2_02.txt. +REM If you did not receive a copy of the PHP license and are unable to +REM obtain it through the world-wide-web, please send a note to +REM license@php.net so we can mail you a copy immediately. +REM ---------------------------------------------------------------------- +REM Authors: Alexander Merz (alexmerz@php.net) +REM ---------------------------------------------------------------------- +REM +REM $Id$ + +REM change this three lines to match you paths +REM ------------------- +set PHP_PATH=e:\apache\php +set PEAR_INSTALL_DIR=e:\apache\php\pear +set PEAR_EXTENSION_DIR=e:\apache\php\extensions +set PEAR_DOC_DIR=e:\apache\php\pear +REM ------------------- +set DIRECTORY_SEPARATOR=\ + +%PHP_PATH%\php.exe -q %PEAR_INSTALL_DIR%\scripts\pearwin.php %1 %2 %3 %4 %5 %6 +@ECHO ON \ No newline at end of file diff --git a/pear/scripts/pearwin.php b/pear/scripts/pearwin.php new file mode 100644 index 0000000000..2d75b3766a --- /dev/null +++ b/pear/scripts/pearwin.php @@ -0,0 +1,118 @@ + | +// | Tomas V.V.Cox | +// +----------------------------------------------------------------------+ +// +// $Id$ + +require_once 'PEAR.php'; +require_once 'Console/Getopt.php'; + +error_reporting(E_ALL ^ E_NOTICE); + +$options = Console_Getopt::getopt($argv, "h?v:e:p:d:"); +if (PEAR::isError($options)) { + usage($options); +} + +$opts = $options[0]; +foreach ($opts as $opt) { + $param = $opt[1]; + switch ($opt[0]) { + case 'v': + $verbose = $param; + break; + case 'e': + if ($param{0} != getenv('DIRECTORY_SEPARATOR')) { + usage (new PEAR_Error("no absolute path (ej. /usr/lib/php)\n")); + } + $ext_dir = $param; + break; + case 'p': + if ($param{0} != getenv('DIRECTORY_SEPARATOR')) { + usage (new PEAR_Error("no absolute path (ej. /usr/lib/php)\n")); + } + $script_dir = $param; + break; + case 'd': + if ($param{0} != getenv('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 : getenv('PEAR_INSTALL_DIR'); +$ext_dir = (isset($ext_dir)) ? $ext_dir : getenv('PEAR_EXTENSION_DIR'); +$doc_dir = (isset($doc_dir)) ? $doc_dir : ''; + +PEAR::setErrorHandling(PEAR_ERROR_PRINT); +$command = $options[1][1]; + +switch ($command) { + 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; + 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; + default: + usage(); + break; +} + +function usage($obj = null) +{ + $stderr = fopen('php://stderr', 'w'); + if ($obj !== null) { + fputs($stderr, $obj->getMessage()); + } + fputs($stderr, + "Usage: pear [-v n] [-h] [-p ] [-e ] [-d ] command \n". + "Options:\n". + " -v set verbosity level to (0-2, default 1)\n". + " -p set script install dir (absolute path)\n". + " -e set extension install dir (absolute path)\n". + " -d set documentation dest dir (absolute path)\n". + " -h, -? display help/usage (this message)\n". + "Commands:\n". + " install \n". + " package [package info file]\n". + "\n"); + fclose($stderr); + exit; +} + +?>