diff options
author | Stig Bakken <ssb@php.net> | 2001-04-22 01:09:14 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2001-04-22 01:09:14 +0000 |
commit | 2cf1b8d3459736457b46c295eb2e8b87acb4f521 (patch) | |
tree | 01517b5cdaf822ea988cda5d444be6e7b98cc37b /pear | |
parent | 9dd0231844ab98f306c977e01ca27b6fbd791b93 (diff) | |
download | php-git-2cf1b8d3459736457b46c295eb2e8b87acb4f521.tar.gz |
* 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
Diffstat (limited to 'pear')
-rw-r--r-- | pear/Makefile.in | 12 | ||||
-rw-r--r-- | pear/PEAR.php (renamed from pear/PEAR.php.in) | 20 | ||||
-rw-r--r-- | pear/PEAR/Common.php | 174 | ||||
-rw-r--r-- | pear/PEAR/Installer.php | 39 | ||||
-rw-r--r-- | pear/PEAR/Uploader.php | 52 | ||||
-rw-r--r-- | pear/tests/pear_error.phpt | 10 |
6 files changed, 248 insertions, 59 deletions
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 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 @@ +<?php +// +// +----------------------------------------------------------------------+ +// | 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> | +// | | +// +----------------------------------------------------------------------+ +// + +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 <ssb@fast.no> */ -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 @@ +<?php +// +// +----------------------------------------------------------------------+ +// | 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> | +// | | +// +----------------------------------------------------------------------+ +// + +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 <ssb@fast.no> + */ +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<br> -<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br> +<b>Notice</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> [pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" prepend="" append="" info=""] mode=trigger: <br> -<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br> +<b>Notice</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> [pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""] mode=trigger,level=notice: <br> -<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br> +<b>Notice</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> [pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""] mode=trigger,level=warning: <br> -<b>Warning</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br> +<b>Warning</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> [pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" prepend="" append="" info=""] mode=trigger,level=error: <br> -<b>Fatal error</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br> +<b>Fatal error</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> |