From 1d14341231ed91db61c21a21a47d28c695a118c6 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Wed, 2 Jul 2003 10:38:09 +0000 Subject: [PATCH] - MFH --- pear/Console/Getopt.php | 2 +- pear/Makefile.frag | 4 +-- pear/PEAR/Command/Package.php | 2 +- pear/PEAR/Command/Remote.php | 4 +-- pear/PEAR/Config.php | 20 +++++++---- pear/PEAR/Frontend/CLI.php | 2 ++ pear/install-pear.php | 68 +++++++++++++++++++---------------- pear/package-Archive_Tar.xml | 37 +++++++++++++++---- pear/package.dtd | 2 +- pear/scripts/pear.bat | 6 ++-- pear/scripts/pearcmd.php | 5 ++- 11 files changed, 98 insertions(+), 54 deletions(-) diff --git a/pear/Console/Getopt.php b/pear/Console/Getopt.php index 1f98a1c083..9bc48c1480 100644 --- a/pear/Console/Getopt.php +++ b/pear/Console/Getopt.php @@ -183,7 +183,7 @@ class Console_Getopt { if (substr($long_opt, -2) != '==') { /* Long option requires an argument. Take the next argument if one wasn't specified. */; - if (!$opt_arg && !(list(, $opt_arg) = each($args))) { + if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args))) { return PEAR::raiseError("Console_Getopt: option --$opt requires an argument"); } } diff --git a/pear/Makefile.frag b/pear/Makefile.frag index 022e80d747..6fbba54dfb 100644 --- a/pear/Makefile.frag +++ b/pear/Makefile.frag @@ -6,10 +6,10 @@ peardir=$(PEAR_INSTALLDIR) PEAR_INSTALL_FLAGS = -n -dsafe_mode=0 install-pear-installer: $(top_builddir)/sapi/cli/php - @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php $(srcdir)/package-*.xml + @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" $(srcdir)/package-*.xml install-pear-packages: $(top_builddir)/sapi/cli/php - @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php $(srcdir)/packages/*.tar + @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" $(srcdir)/packages/*.tar install-pear: @echo "Installing PEAR environment: $(INSTALL_ROOT)$(peardir)/" diff --git a/pear/PEAR/Command/Package.php b/pear/PEAR/Command/Package.php index 986c6c7dab..54a44d6fc0 100644 --- a/pear/PEAR/Command/Package.php +++ b/pear/PEAR/Command/Package.php @@ -662,7 +662,7 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm $spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\1"]', fread($fp, filesize($spec_template))); fclose($fp); $spec_file = "$info[rpm_package]-$info[version].spec"; - $wp = fopen($spec_file, "w"); + $wp = fopen($spec_file, "wb"); if (!$wp) { return $this->raiseError("could not write RPM spec file $spec_file: $php_errormsg"); } diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php index 9d23dc7391..45494874db 100644 --- a/pear/PEAR/Command/Remote.php +++ b/pear/PEAR/Command/Remote.php @@ -332,7 +332,7 @@ parameter. $data = array( 'caption' => $caption, 'border' => 1, - 'headline' => array('Package', 'Version', 'Size'), + 'headline' => array('Package', 'Local', 'Remote', 'Size'), ); foreach ($latest as $pkg => $info) { $package = strtolower($pkg); @@ -355,7 +355,7 @@ parameter. } else { $fs = " -"; // XXX center instead } - $data['data'][] = array($pkg, $version, $fs); + $data['data'][] = array($pkg, $inst_version, $version, $fs); } if (empty($data['data'])) { $this->ui->outputData('No upgrades available'); diff --git a/pear/PEAR/Config.php b/pear/PEAR/Config.php index 82c36fad4a..44d23e2117 100644 --- a/pear/PEAR/Config.php +++ b/pear/PEAR/Config.php @@ -26,6 +26,11 @@ require_once 'System.php'; * @var object */ $GLOBALS['_PEAR_Config_instance'] = null; +if (!defined('PEAR_INSTALL_DIR') || !PEAR_INSTALL_DIR) { + $PEAR_INSTALL_DIR = PHP_LIBDIR . DIRECTORY_SEPARATOR . 'pear'; +} else { + $PEAR_INSTALL_DIR = PEAR_INSTALL_DIR; +} // Below we define constants with default values for all configuration // parameters except username/password. All of them can have their @@ -61,11 +66,11 @@ if (getenv('PHP_PEAR_HTTP_PROXY')) { if (getenv('PHP_PEAR_INSTALL_DIR')) { define('PEAR_CONFIG_DEFAULT_PHP_DIR', getenv('PHP_PEAR_INSTALL_DIR')); } else { - if (@is_dir(PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'lib')) { + if (@is_dir($PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'lib')) { define('PEAR_CONFIG_DEFAULT_PHP_DIR', - PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'lib'); + $PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'lib'); } else { - define('PEAR_CONFIG_DEFAULT_PHP_DIR', PEAR_INSTALL_DIR); + define('PEAR_CONFIG_DEFAULT_PHP_DIR', $PEAR_INSTALL_DIR); } } @@ -73,7 +78,7 @@ if (getenv('PHP_PEAR_INSTALL_DIR')) { if (getenv('PHP_PEAR_EXTENSION_DIR')) { define('PEAR_CONFIG_DEFAULT_EXT_DIR', getenv('PHP_PEAR_EXTENSION_DIR')); } else { - if (!ini_get('extension_dir')) { + if (ini_get('extension_dir')) { define('PEAR_CONFIG_DEFAULT_EXT_DIR', ini_get('extension_dir')); } elseif (defined('PEAR_EXTENSION_DIR') && @is_dir(PEAR_EXTENSION_DIR)) { define('PEAR_CONFIG_DEFAULT_EXT_DIR', PEAR_EXTENSION_DIR); @@ -89,7 +94,7 @@ if (getenv('PHP_PEAR_DOC_DIR')) { define('PEAR_CONFIG_DEFAULT_DOC_DIR', getenv('PHP_PEAR_DOC_DIR')); } else { define('PEAR_CONFIG_DEFAULT_DOC_DIR', - PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'docs'); + $PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'docs'); } // Default for bin_dir @@ -104,7 +109,7 @@ if (getenv('PHP_PEAR_DATA_DIR')) { define('PEAR_CONFIG_DEFAULT_DATA_DIR', getenv('PHP_PEAR_DATA_DIR')); } else { define('PEAR_CONFIG_DEFAULT_DATA_DIR', - PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'data'); + $PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'data'); } // Default for test_dir @@ -112,7 +117,7 @@ if (getenv('PHP_PEAR_TEST_DIR')) { define('PEAR_CONFIG_DEFAULT_TEST_DIR', getenv('PHP_PEAR_TEST_DIR')); } else { define('PEAR_CONFIG_DEFAULT_TEST_DIR', - PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'tests'); + $PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'tests'); } // Default for cache_dir @@ -1004,6 +1009,7 @@ class PEAR_Config extends PEAR { if (isset($this->configuration[$layer])) { unset($this->configuration[$layer]); + $this->layers = array_keys($this->configuration); return true; } return false; diff --git a/pear/PEAR/Frontend/CLI.php b/pear/PEAR/Frontend/CLI.php index 5213ea9c91..81326d27b4 100644 --- a/pear/PEAR/Frontend/CLI.php +++ b/pear/PEAR/Frontend/CLI.php @@ -449,6 +449,8 @@ class PEAR_Frontend_CLI extends PEAR 1 => array('wrap' => 20), 2 => array('wrap' => 35) ); + } else { + $opts = null; } if (isset($data['headline']) && is_array($data['headline'])) { $this->_tableRow($data['headline'], diff --git a/pear/install-pear.php b/pear/install-pear.php index c1a2d1341d..c6d08703a0 100644 --- a/pear/install-pear.php +++ b/pear/install-pear.php @@ -1,41 +1,31 @@ install_file +$force = false; $install_files = array(); - -/* -$dp = opendir($pear_dir); -while ($ent = readdir($dp)) { - if (ereg('^package-(.*)\.xml$', $ent, $matches)) { - $install_files[$matches[1]] = $ent; - } -} -closedir($dp); -*/ -foreach ($argv as $arg) { +array_shift($argv); +for ($i = 0; $i < sizeof($argv); $i++) { + $arg = $argv[$i]; $bn = basename($arg); - if (ereg('^package-(.*)\.xml$', $bn, $matches) || - ereg('^([A-Za-z0-9_:]+)-.*\.(tar|tgz)$', $bn, $matches)) { - $install_files[$matches[1]] = $arg; + if (ereg('package-(.*)\.xml$', $bn, $matches) || + ereg('([A-Za-z0-9_:]+)-.*\.(tar|tgz)$', $bn, $matches)) { + $install_files[$matches[1]] = $bn; + } elseif ($arg == '--force') { + $force = true; + } elseif ($arg == '-d') { + $with_dir = $argv[$i+1]; + $i++; } } @@ -47,11 +37,29 @@ foreach ($config_layers as $layer) { if ($layer == 'default') continue; $config->removeLayer($layer); } +$keys = $config->getKeys(); $config->set('verbose', 0, 'default'); +// User supplied a dir prefix +if (!empty($with_dir)) { + $ds = DIRECTORY_SEPARATOR; + $config->set('php_dir', $with_dir . $ds . 'lib', 'default'); + $config->set('bin_dir', $with_dir . $ds . 'bin', 'default'); + $config->set('doc_dir', $with_dir . $ds . 'doc', 'default'); + $config->set('data_dir', $with_dir . $ds . 'data', 'default'); + $config->set('test_dir', $with_dir . $ds . 'test', 'default'); +} +/* Print PEAR Conf (useful for debuging do NOT REMOVE) +sort($keys); +foreach ($keys as $key) { + echo $config->getPrompt($key) . ": " . $config->get($key) . "\n"; +} +exit; +// end print +//*/ -$options = array(); -$install_root = getenv("INSTALL_ROOT"); $php_dir = $config->get('php_dir'); +$options = array(); +$install_root = getenv('INSTALL_ROOT'); if (!empty($install_root)) { $options['installroot'] = $install_root; $reg_dir = $install_root . $php_dir; @@ -62,7 +70,7 @@ if (!empty($install_root)) { $reg = &new PEAR_Registry($reg_dir); $ui = &new PEAR_Frontend_CLI(); $installer = &new PEAR_Installer($ui); -$installer->registry = &$reg; +//$installer->registry = &$reg; // This should be changed in Installer/Registry foreach ($install_files as $package => $instfile) { if ($reg->packageExists($package)) { @@ -82,7 +90,7 @@ foreach ($install_files as $package => $instfile) { } $ui->outputData(sprintf("[PEAR] %-15s- upgraded: %s", $package, $new_ver)); } else { - if (@$argv[1] == '--force') { + if ($force) { $options['force'] = true; $err = $installer->install($instfile, $options); if (PEAR::isError($err)) { @@ -106,4 +114,4 @@ foreach ($install_files as $package => $instfile) { } } -?> \ No newline at end of file +?> diff --git a/pear/package-Archive_Tar.xml b/pear/package-Archive_Tar.xml index 64ee07b5c8..7d54a01739 100644 --- a/pear/package-Archive_Tar.xml +++ b/pear/package-Archive_Tar.xml @@ -6,7 +6,7 @@ This class provides handling of tar files in PHP. It supports creating, listing, extracting and adding to tar files. Gzip support is available if PHP has the zlib extension built-in or -loaded. +loaded. Bz2 compression is also supported with the bz2 extension loaded. PHP License @@ -24,11 +24,12 @@ loaded. - 0.9 - 2002-05-27 - - * Auto-detect gzip'ed files - + 1.1 + 2003-05-28 + * Add support for BZ2 compression +* Add support for add and extract without using temporary files : methods addString() and extractInString() + + stable @@ -38,6 +39,30 @@ loaded. + + 1.0 + 2003-01-24 + Change status to stable + stable + + + + + + + + + 0.10-b1 + 2003-01-08 + Add support for long filenames (greater than 99 characters) + beta + + + 0.9 + 2002-05-27 + Auto-detect gzip'ed files + stable + 0.4 2002-05-20 diff --git a/pear/package.dtd b/pear/package.dtd index 2515b738c2..a570325899 100644 --- a/pear/package.dtd +++ b/pear/package.dtd @@ -1,5 +1,5 @@