From 2cf1b8d3459736457b46c295eb2e8b87acb4f521 Mon Sep 17 00:00:00 2001 From: Stig Bakken Date: Sun, 22 Apr 2001 01:09:14 +0000 Subject: [PATCH] * expanded the following constants and made them available in PHP: DEFAULT_INCLUDE_PATH PEAR_INSTALL_DIR PHP_EXTENSION_DIR PHP_BINDIR PHP_LIBDIR PHP_DATADIR PHP_SYSCONFDIR PHP_LOCALSTATEDIR PHP_CONFIG_FILE_PATH * no longer generating pear/PEAR.php * fixed some tests * some more installer work --- Makefile.in | 8 +- configure.in | 115 ++++++++++++++-------- ext/standard/info.c | 2 +- footer | 1 + main/build-defs.h.in | 13 ++- main/main.c | 9 ++ main/php_ini.c | 12 ++- pear/Makefile.in | 12 +-- pear/{PEAR.php.in => PEAR.php} | 20 +--- pear/PEAR/Common.php | 174 +++++++++++++++++++++++++++++++++ pear/PEAR/Installer.php | 39 ++------ pear/PEAR/Uploader.php | 52 ++++++++++ pear/tests/pear_error.phpt | 10 +- 13 files changed, 357 insertions(+), 110 deletions(-) rename pear/{PEAR.php.in => PEAR.php} (97%) create mode 100644 pear/PEAR/Common.php create mode 100644 pear/PEAR/Uploader.php diff --git a/Makefile.in b/Makefile.in index 1009646508..0bb067c87d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -50,7 +50,13 @@ install-modules: rm -f modules/*.la && \ cp modules/* $(INSTALL_ROOT)$(moduledir) >/dev/null 2>&1 || true -install-su: install-modules +install-tester: + -$(mkinstalldirs) $(datadir) + $(INSTALL) -m 755 $(srcdir)/run-tests.php $(INSTALL_ROOT)$(datadir) + +install-pear: install-modules (cd pear && $(MAKE) install) +install-su: install-pear install-tester + .NOEXPORT: diff --git a/configure.in b/configure.in index dbeb66d41b..5205b49112 100644 --- a/configure.in +++ b/configure.in @@ -461,24 +461,10 @@ fi divert(4) - - -PHP_ARG_WITH(config-file-path,whether to use a configuration file, +PHP_ARG_WITH(config-file-path,[path to configuration file], [ --with-config-file-path=PATH Sets the path in which to look for php.ini. - defaults to /usr/local/lib], yes) - -if test "$PHP_CONFIG_FILE_PATH" = "yes"; then - PHP_CONFIG_FILE_PATH="/usr/local/lib" -fi - -if test "$PHP_CONFIG_FILE_PATH" != "no"; then - AC_DEFINE_UNQUOTED(CONFIGURATION_FILE_PATH, "$PHP_CONFIG_FILE_PATH",[ ]) - AC_DEFINE(USE_CONFIG_FILE, 1, [ ]) -else - AC_DEFINE(CONFIGURATION_FILE_PATH, 0, [ ]) - AC_DEFINE(USE_CONFIG_FILE, 0, [ ]) -fi + defaults to --sysconfdir, "none" to disable], $sysconfdir) PHP_ARG_ENABLE(debug, whether to include debugging symbols, [ --enable-debug Compile with debugging symbols.], no) @@ -525,6 +511,20 @@ AC_ARG_WITH(exec-dir, AC_MSG_RESULT(/usr/local/php/bin) ]) +# compatibility +if test "x$with_pear" = "x" -a "x$enable_pear" = "xno"; then + with_pear="no" +fi + +PHP_ARG_WITH(pear, [whether to install PEAR, and where], +[ --with-pear=DIR Install PEAR in DIR (default \$datadir/php/pear) + --without-pear Do not install PEAR], $datadir/php/pear) + +if test "$PHP_PEAR" != "no"; then + PEAR_DIR=pear + PEAR_INSTALLDIR="$PHP_PEAR" +fi + PHP_ARG_WITH(openssl,for OpenSSL support, [ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.5) ]) if test "$PHP_OPENSSL" = "yes"; then @@ -592,13 +592,6 @@ if test "$PHP_DMALLOC" = "yes"; then CPPFLAGS="$CPPFLAGS -DDMALLOC_FUNC_CHECK" fi -PHP_ARG_ENABLE(pear,whether to install PEAR, -[ --disable-pear Do not install PEAR],yes) - -if test "$PHP_PEAR" = "yes"; then - PEAR_DIR=pear -fi - # temporary until streams are better integrated PHP_ARG_ENABLE(php-streams,whether to enable php streams, [ --enable-php-streams Include experimental php streams. @@ -703,31 +696,67 @@ $php_shtool mkdir -p $phplibdir phptempdir="`pwd`/libs" test "$prefix" = "NONE" && prefix="/usr/local" -test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)' +test "$exec_prefix" = "NONE" && exec_prefix='${prefix}' +case $libdir in + */php) ;; + *) libdir="$libdir/php";; +esac +case $datadir in + */php) ;; + *) datadir="$datadir/php";; +esac dnl Build extension directory path -if test "$PHP_DEBUG" = "1"; then - PART1=debug -else - PART1=no-debug -fi - -if test "$enable_experimental_zts" = "yes"; then - PART2=zts -else - PART2=non-zts -fi - ZEND_MODULE_API_NO=`egrep '#define ZEND_MODULE_API_NO ' $srcdir/Zend/zend_modules.h|sed 's/#define ZEND_MODULE_API_NO //'` -if test -z "$PEAR_INSTALLDIR"; then - PEAR_INSTALLDIR="$prefix/lib/php" -fi +extbasedir="$ZEND_MODULE_API_NO" -EXTENSION_DIR="${PEAR_INSTALLDIR}/extensions/$PART1-$PART2-$ZEND_MODULE_API_NO" +if test "$enable_experimental_zts" = "yes"; then + extbasedir="${extbasedir}-zts" +fi -INCLUDE_PATH=".:${PEAR_INSTALLDIR}" +if test "$PHP_DEBUG" = "1"; then + extbasedir="${extbasedir}-debug" +fi + +if test "x$PEAR_INSTALLDIR" = "x"; then + PEAR_INSTALLDIR="$datadir/pear" +fi + +if test "x$EXTENSION_DIR" = "x"; then + EXTENSION_DIR="$libdir/$extbasedir" +fi + +old_exec_prefix="$exec_prefix" +old_libdir="$libdir" +old_datadir="$datadir" +exec_prefix=`eval echo $exec_prefix` +libdir=`eval echo $libdir` +datadir=`eval echo $datadir` +EXPANDED_PEAR_INSTALLDIR=`eval echo $PEAR_INSTALLDIR` +EXPANDED_EXTENSION_DIR=`eval echo $EXTENSION_DIR` +EXPANDED_LOCALSTATEDIR=`eval echo $localstatedir` +EXPANDED_BINDIR=`eval echo $bindir` +EXPANDED_LIBDIR="$libdir" +EXPANDED_SYSCONFDIR=`eval echo $sysconfdir` +EXPANDED_DATADIR="$datadir" +EXPANDED_PHP_CONFIG_FILE_PATH=`eval echo "$PHP_CONFIG_FILE_PATH"` +INCLUDE_PATH=".:${EXPANDED_PEAR_INSTALLDIR}" + +exec_prefix="$old_exec_prefix" +libdir="$old_libdir" +datadir="$old_datadir" + +AC_SUBST(INCLUDE_PATH) +AC_SUBST(EXPANDED_PEAR_INSTALLDIR) +AC_SUBST(EXPANDED_EXTENSION_DIR) +AC_SUBST(EXPANDED_BINDIR) +AC_SUBST(EXPANDED_LIBDIR) +AC_SUBST(EXPANDED_DATADIR) +AC_SUBST(EXPANDED_SYSCONFDIR) +AC_SUBST(EXPANDED_LOCALSTATEDIR) +AC_SUBST(EXPANDED_PHP_CONFIG_FILE_PATH) PHP_BUILD_RPATH @@ -752,6 +781,8 @@ PHP_SUBST(phplibdir) PHP_SUBST(phptempdir) PHP_SUBST(prefix) PHP_SUBST(localstatedir) +PHP_SUBST(datadir) +PHP_SUBST(sysconfdir) PHP_SUBST(AWK) PHP_SUBST(CC) @@ -856,7 +887,7 @@ PHP_GEN_CONFIG_VARS $php_shtool mkdir -p pear/scripts ALL_OUTPUT_FILES="php4.spec Zend/Makefile main/build-defs.h \ -pear/scripts/pear pear/scripts/phpize pear/scripts/php-config pear/PEAR.php \ +pear/scripts/pear pear/scripts/phpize pear/scripts/php-config \ TSRM/Makefile $PHP_OUTPUT_FILES" AC_OUTPUT($ALL_OUTPUT_FILES, [], [ diff --git a/ext/standard/info.c b/ext/standard/info.c index e0233012c8..7b67b7a693 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -190,7 +190,7 @@ PHPAPI void php_print_info(int flag) php_info_print_table_row(2, "Virtual Directory Support", "disabled" ); #endif - php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_opened_path?php_ini_opened_path:CONFIGURATION_FILE_PATH); + php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_opened_path?php_ini_opened_path:PHP_CONFIG_FILE_PATH); #if ZEND_DEBUG php_info_print_table_row(2, "ZEND_DEBUG", "enabled" ); diff --git a/footer b/footer index c217e2be43..6513b56b0b 100644 --- a/footer +++ b/footer @@ -3,5 +3,6 @@ * Local variables: * tab-width: 4 * c-basic-offset: 4 + * indent-tabs-mode: t * End: */ diff --git a/main/build-defs.h.in b/main/build-defs.h.in index 27deeeb9ff..347e75d476 100644 --- a/main/build-defs.h.in +++ b/main/build-defs.h.in @@ -27,7 +27,6 @@ #define PHP_FHTTPD_INCLUDE "" #define PHP_FHTTPD_LIB "" #define PHP_FHTTPD_TARGET "" -#define PHP_BINNAME "@BINNAME@" #define PHP_CFLAGS "@CFLAGS@" #define PHP_DBASE_LIB "" #define PHP_BUILD_DEBUG "@DEBUG_CFLAGS@" @@ -50,9 +49,6 @@ #define PHP_MYSQL_LFLAGS "" #define PHP_MYSQL_LIBS "" #define PHP_ODBC_TYPE "@ODBC_TYPE@" -#define PHP_ODBC_INCLUDE "@ODBC_INCLUDE@" -#define PHP_ODBC_LFLAGS "@ODBC_LFLAGS@" -#define PHP_ODBC_LIBS "@ODBC_LIBS@" #define PHP_OCI8_SHARED_LIBADD "@OCI8_SHARED_LIBADD@" #define PHP_OCI8_DIR "@OCI8_DIR@" #define PHP_OCI8_VERSION "@OCI8_VERSION@" @@ -78,5 +74,12 @@ #define PHP_LDAP_LIBS "" #define PHP_VELOCIS_INCLUDE "" #define PHP_VELOCIS_LIBS "" -#define PHP_EXTENSION_DIR "@EXTENSION_DIR@" +#define PEAR_INSTALLDIR "@EXPANDED_PEAR_INSTALLDIR@" #define PHP_INCLUDE_PATH "@INCLUDE_PATH@" +#define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@" +#define PHP_BINDIR "@EXPANDED_BINDIR@" +#define PHP_LIBDIR "@EXPANDED_LIBDIR@" +#define PHP_DATADIR "@EXPANDED_DATADIR@" +#define PHP_SYSCONFDIR "@EXPANDED_SYSCONFDIR@" +#define PHP_LOCALSTATEDIR "@EXPANDED_LOCALSTATEDIR@" +#define PHP_CONFIG_FILE_PATH "@EXPANDED_PHP_CONFIG_FILE_PATH@" diff --git a/main/main.c b/main/main.c index fd3e61c27d..7a8cd97226 100644 --- a/main/main.c +++ b/main/main.c @@ -852,6 +852,15 @@ int php_module_startup(sapi_module_struct *sf) REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, sizeof(PHP_INCLUDE_PATH)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PEAR_INSTALL_DIR", PEAR_INSTALLDIR, sizeof(PEAR_INSTALLDIR)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_EXTENSION_DIR", PHP_EXTENSION_DIR, sizeof(PHP_EXTENSION_DIR)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINDIR", PHP_BINDIR, sizeof(PHP_BINDIR)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_LIBDIR", PHP_LIBDIR, sizeof(PHP_LIBDIR)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_DATADIR", PHP_DATADIR, sizeof(PHP_DATADIR)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_SYSCONFDIR", PHP_SYSCONFDIR, sizeof(PHP_SYSCONFDIR)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_LOCALSTATEDIR", PHP_LOCALSTATEDIR, sizeof(PHP_LOCALSTATEDIR)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_PATH", PHP_CONFIG_FILE_PATH, sizeof(PHP_CONFIG_FILE_PATH)-1, CONST_PERSISTENT | CONST_CS); php_output_register_constants(); if (php_startup_ticks(PLS_C) == FAILURE) { diff --git a/main/php_ini.c b/main/php_ini.c index 86e03b55b6..fe3121cf77 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -18,13 +18,13 @@ #include "php.h" +#include "build-defs.h" #include "ext/standard/info.h" #include "zend_ini.h" #include "php_ini.h" #include "ext/standard/dl.h" #include "zend_extensions.h" - typedef struct _php_extension_lists { zend_llist engine; zend_llist functions; @@ -210,7 +210,7 @@ int php_init_config(char *php_ini_path_override) } free_default_location=1; #else - default_location = CONFIGURATION_FILE_PATH; + default_location = PHP_CONFIG_FILE_PATH; free_default_location=0; #endif php_ini_search_path = (char *) emalloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); @@ -332,3 +332,11 @@ PHPAPI int cfg_get_string(char *varname, char **result) *result = tmp->value.str.val; return SUCCESS; } + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: t + * End: + */ diff --git a/pear/Makefile.in b/pear/Makefile.in index b05fa1c161..282f90ddba 100644 --- a/pear/Makefile.in +++ b/pear/Makefile.in @@ -94,14 +94,18 @@ PEAR_FILES = \ Net/SMTP.php \ Net/Socket.php \ Numbers/Roman.php \ + PEAR.php \ + PEAR/Common.php \ PEAR/Installer.php \ + PEAR/Packager.php \ + PEAR/Updater.php \ Payment/Verisign.php \ Schedule/At.php \ XML/Parser.php \ XML/RPC.php \ XML/RPC/Server.php -install-data-local: PEAR.php +install-data-local: @if $(mkinstalldirs) $(INSTALL_ROOT)$(peardir); then \ for i in $(PEAR_SUBDIRS); do \ (set -x;$(mkinstalldirs) $(INSTALL_ROOT)$(peardir)/$$i); \ @@ -110,9 +114,6 @@ install-data-local: PEAR.php dir=`echo $$i|sed 's%[^/][^/]*$$%%'`; \ (set -x;$(INSTALL_DATA) $(srcdir)/$$i $(INSTALL_ROOT)$(peardir)/$$dir); \ done; \ - for i in PEAR.php; do \ - (set -x;$(INSTALL_DATA) $$i $(INSTALL_ROOT)$(peardir)); \ - done; \ else \ cat $(srcdir)/install-pear.txt; \ exit 5; \ @@ -183,6 +184,3 @@ scripts/phpize: scripts/phpize.in $(top_builddir)/config.status scripts/php-config: scripts/php-config.in $(top_builddir)/config.status (cd ..;CONFIG_FILES=pear/scripts/php-config CONFIG_HEADERS= $(top_builddir)/config.status) - -PEAR.php: PEAR.php.in $(top_builddir)/config.status - (cd ..;CONFIG_FILES=pear/PEAR.php CONFIG_HEADERS= $(top_builddir)/config.status) diff --git a/pear/PEAR.php.in b/pear/PEAR.php similarity index 97% rename from pear/PEAR.php.in rename to pear/PEAR.php index ee5ccea9b1..fcf86225ce 100644 --- a/pear/PEAR.php.in +++ b/pear/PEAR.php @@ -26,10 +26,6 @@ define('PEAR_ERROR_TRIGGER', 4); define('PEAR_ERROR_DIE', 8); define('PEAR_ERROR_CALLBACK', 16); -define('PHP_BINDIR', '@prefix@/bin'); -define('PEAR_INSTALL_DIR', '@PEAR_INSTALLDIR@'); -define('PEAR_EXTENSION_DIR', '@EXTENSION_DIR@'); - if (substr(PHP_OS, 0, 3) == 'WIN') { define('OS_WINDOWS', true); define('OS_UNIX', false); @@ -40,18 +36,10 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { define('PEAR_OS', 'Unix'); // blatant assumption } -if (!defined("DIRECTORY_SEPARATOR")) { - if (OS_WINDOWS) { - define("DIRECTORY_SEPARATOR", "\\"); - } else { - define("DIRECTORY_SEPARATOR", "/"); - } -} - -$_PEAR_default_error_mode = PEAR_ERROR_RETURN; -$_PEAR_default_error_options = E_USER_NOTICE; -$_PEAR_default_error_callback = ''; -$_PEAR_destructor_object_list = array(); +$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; +$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; +$GLOBALS['_PEAR_default_error_callback'] = ''; +$GLOBALS['_PEAR_destructor_object_list'] = array(); // // Tests needed: - PEAR inheritance diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php new file mode 100644 index 0000000000..8741da751f --- /dev/null +++ b/pear/PEAR/Common.php @@ -0,0 +1,174 @@ + | +// | | +// +----------------------------------------------------------------------+ +// + +require_once "PEAR.php"; + +class PEAR_Common +{ + // {{{ properties + + /** stack of elements, gives some sort of XML context */ + var $element_stack; + + /** name of currently parsed XML element */ + var $current_element; + + /** array of attributes of the currently parsed XML element */ + var $current_attributes = array(); + + /** list of temporary files created by this object */ + var $_tempfiles = array(); + + /** assoc with information about a package */ + var $pkginfo = array(); + + // }}} + + // {{{ constructor + + function PEAR_Common() + { + $this->PEAR(); + } + + // }}} + // {{{ destructor + + function _PEAR_Common() { + $this->_PEAR(); + while (is_array($this->_tempfiles) && + $file = array_shift($this->_tempfiles)) + { + if (is_dir($file)) { + system("rm -rf $file"); // XXX FIXME Windows + } else { + unlink($file); + } + } + } + + // }}} + // {{{ addTempFile() + + function addTempFile($file) + { + $this->_tempfiles[] = $file; + } + + // }}} + + function _element_start($xp, $name, $attribs) + { + array_push($this->element_stack, $name); + $this->current_element = $name; + $this->current_attributes = $attribs; + } + + + function _element_end($xp, $name) + { + array_pop($this->element_stack); + $this->current_element = $this->element_stack[sizeof($this->element_stack)-1]; + } + + + function _pkginfo_cdata($xp, $data) + { + $next = $this->element_stack[sizeof($this->element_stack)-1]; + switch ($this->current_element) { + case "Name": + switch ($next) { + case "Package": + $this->pkginfo["package"] = trim($data); + break; + case "Maintainer": + $this->pkginfo["maintainer_name"] = trim($data); + break; + } + break; + case "Summary": + $this->pkginfo["summary"] = trim($data); + break; + case "Initials": + $this->pkginfo["maintainer_handle"] = trim($data); + break; + case "Email": + $this->pkginfo["maintainer_email"] = trim($data); + break; + case "Version": + $this->pkginfo["version"] = trim($data); + break; + case "Date": + $this->pkginfo["release_date"] = trim($data); + break; + case "Notes": + $this->pkginfo["release_notes"] = trim($data); + break; + case "Dir": + if (!$this->phpdir) { + break; + } + $dir = trim($data); + // XXX add to file list + break; + case "File": + $role = strtolower($this->current_attributes["Role"]); + $file = trim($data); + // XXX add to file list + break; + } + } + + + function infoFromDescriptionFile($file) + { + $fp = fopen($descfile, "r"); + $xp = xml_parser_create(); + if (!$xp) { + return $this->raiseError("Unable to create XML parser."); + } + xml_set_object($xp, $this); + xml_set_element_handler($xp, "_element_start", "_element_end"); + xml_set_character_data_handler($xp, "_pkginfo_cdata"); + xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); + + $this->element_stack = array(); + $this->pkginfo = array(); + $this->current_element = false; + $this->destdir = ''; + + // read the whole thing so we only get one cdata callback + // for each block of cdata + $data = fread($fp, filesize($descfile)); + if (!xml_parse($xp, $data, 1)) { + $msg = sprintf("XML error: %s at line %d", + xml_error_string(xml_get_error_code($xp)), + xml_get_current_line_number($xp)); + xml_parser_free($xp); + return $this->raiseError($msg); + } + + xml_parser_free($xp); + + return $this->pkginfo; + } +} + +?> diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 23b0dc77aa..912c316416 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -18,7 +18,7 @@ // +----------------------------------------------------------------------+ // -require_once "PEAR.php"; +require_once "PEAR/Common.php"; /** * Administration class used to install PEAR packages and maintain the @@ -27,22 +27,10 @@ require_once "PEAR.php"; * @since PHP 4.0.2 * @author Stig Bakken */ -class PEAR_Installer extends PEAR +class PEAR_Installer extends PEAR_Common { // {{{ properties - /** stack of elements, gives some sort of XML context */ - var $element_stack; - - /** name of currently parsed XML element */ - var $current_element; - - /** array of attributes of the currently parsed XML element */ - var $current_attributes = array(); - - /** assoc with information about the package */ - var $pkginfo = array(); - /** name of the package directory, for example Foo-1.0 */ var $pkgdir; @@ -75,9 +63,6 @@ class PEAR_Installer extends PEAR /** file pointer for package list file if open */ var $pkglist_fp; - /** list of temporary files created by this object */ - var $_tempfiles = array(); - // }}} // {{{ constructor @@ -98,7 +83,6 @@ class PEAR_Installer extends PEAR // {{{ destructor function _PEAR_Installer() { - $this->_PEAR(); if ($this->tmpdir && is_dir($this->tmpdir)) { system("rm -rf $this->tmpdir"); // XXX FIXME Windows } @@ -108,15 +92,7 @@ class PEAR_Installer extends PEAR } $this->tmpdir = null; $this->pkglist_fp = null; - while (is_array($this->_tempfiles) && - $file = array_shift($this->_tempfiles)) - { - if (is_dir($file)) { - system("rm -rf $file"); // XXX FIXME Windows - } else { - unlink($file); - } - } + $this->_PEAR_Common(); } // }}} @@ -261,7 +237,7 @@ class PEAR_Installer extends PEAR if ($need_download) { $file = basename($pkgfile); - // XXX FIXME Windows + // XXX FIXME use ??? on Windows, use $TMPDIR on unix $downloaddir = "/tmp/pearinstall"; $this->mkDirHier($downloaddir); $downloadfile = $downloaddir.DIRECTORY_SEPARATOR.$file; @@ -274,6 +250,7 @@ class PEAR_Installer extends PEAR if (!$wp) { return $this->raiseError("$downloadfile: write failed ($php_errormsg)"); } + $this->addTempFile($downloadfile); $bytes = 0; while ($data = @fread($fp, 16384)) { $bytes += strlen($data); @@ -285,9 +262,8 @@ class PEAR_Installer extends PEAR fclose($fp); fclose($wp); $this->log(1, "...done, $bytes bytes"); - $this->tempfiles[] = $downloadfile; } - // XXX FIXME need internal support for gzip+tar + // XXX FIXME depends on external gzip+tar $fp = popen("gzip -dc $pkgfile | tar -tf -", "r"); if (!$fp) { return $this->raiseError("Unable to examine $pkgfile (gzip or tar failed)"); @@ -313,9 +289,10 @@ class PEAR_Installer extends PEAR if (!mkdir($this->tmpdir, 0755)) { return $this->raiseError("Unable to create temporary directory $this->tmpdir."); } - $this->tempfiles[] = $this->tmpdir; + $this->addTempFile($this->tmpdir); $pwd = getcwd(); + // XXX FIXME Windows should check for drive if (substr($pkgfile, 0, 1) == DIRECTORY_SEPARATOR) { $pkgfilepath = $pkgfile; } else { diff --git a/pear/PEAR/Uploader.php b/pear/PEAR/Uploader.php new file mode 100644 index 0000000000..575e3edf99 --- /dev/null +++ b/pear/PEAR/Uploader.php @@ -0,0 +1,52 @@ + | +// | | +// +----------------------------------------------------------------------+ +// + +require_once "PEAR/Common.php"; + +/** + * Administration class used to install PEAR packages and maintain the + * installed package database. + * + * @since PHP 4.0.2 + * @author Stig Bakken + */ +class PEAR_Uploader extends PEAR_Common +{ + // {{{ properties + + var $_tempfiles = array(); + + // }}} + + // {{{ constructor + + function PEAR_Uploader() + { + $this->PEAR_Common(); + } + + // }}} + + function Upload($pkgfile, $infofile) + { + } +} + +?> diff --git a/pear/tests/pear_error.phpt b/pear/tests/pear_error.phpt index 3d1a9f2601..e42085403b 100644 --- a/pear/tests/pear_error.phpt +++ b/pear/tests/pear_error.phpt @@ -113,16 +113,16 @@ mode=print: test error[pear_error: message="test error" code=-42 mode=print leve mode=callback(function): errorhandler function called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorhandler prefix="" prepend="" append="" info=""] mode=callback(method): errorhandler method called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorclass::errorhandler prefix="" prepend="" append="" info=""] mode=print&trigger: test error
-Notice: test error in /usr/local/lib/php/PEAR.php on line 413
+Notice: test error in /usr/local/share/php/pear/PEAR.php on line 401
[pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" prepend="" append="" info=""] mode=trigger:
-Notice: test error in /usr/local/lib/php/PEAR.php on line 413
+Notice: test error in /usr/local/share/php/pear/PEAR.php on line 401
[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""] mode=trigger,level=notice:
-Notice: test error in /usr/local/lib/php/PEAR.php on line 413
+Notice: test error in /usr/local/share/php/pear/PEAR.php on line 401
[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""] mode=trigger,level=warning:
-Warning: test error in /usr/local/lib/php/PEAR.php on line 413
+Warning: test error in /usr/local/share/php/pear/PEAR.php on line 401
[pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" prepend="" append="" info=""] mode=trigger,level=error:
-Fatal error: test error in /usr/local/lib/php/PEAR.php on line 413
+Fatal error: test error in /usr/local/share/php/pear/PEAR.php on line 401
-- 2.40.0