From 7d96d95a5ee622c59d52fbb7b90e87e0ecd05ee9 Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Wed, 6 Aug 2003 01:58:30 +0000 Subject: [PATCH] MFH for RC3 --- pear/Makefile.frag | 4 +-- pear/PEAR.php | 2 +- pear/PEAR/Command/Install.php | 5 +-- pear/PEAR/Command/Registry.php | 1 + pear/PEAR/Command/Remote.php | 3 +- pear/PEAR/Common.php | 36 +++++++++++++------ pear/PEAR/Config.php | 3 +- pear/PEAR/Dependency.php | 1 + pear/PEAR/Installer.php | 5 +-- pear/PEAR/Packager.php | 4 +-- pear/PEAR/Registry.php | 2 +- pear/PEAR/Remote.php | 64 +++++++++++++++++++++++----------- pear/install-pear.php | 18 +++++++--- pear/package-PEAR.xml | 14 +++++--- pear/scripts/pear.sh | 2 +- 15 files changed, 112 insertions(+), 52 deletions(-) diff --git a/pear/Makefile.frag b/pear/Makefile.frag index 6fbba54dfb..a74392b2d3 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 -d "$(peardir)" $(srcdir)/package-*.xml + @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" -b "$(bindir)" $(srcdir)/package-*.xml install-pear-packages: $(top_builddir)/sapi/cli/php - @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" $(srcdir)/packages/*.tar + @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" -b "$(bindir)" $(srcdir)/packages/*.tar install-pear: @echo "Installing PEAR environment: $(INSTALL_ROOT)$(peardir)/" diff --git a/pear/PEAR.php b/pear/PEAR.php index 5305537fb1..ec98d5576f 100644 --- a/pear/PEAR.php +++ b/pear/PEAR.php @@ -769,7 +769,7 @@ class PEAR_Error is_object($this->callback[0]) && is_string($this->callback[1]) && strlen($this->callback[1])) { - @call_user_func($this->callback, $this); + call_user_func($this->callback, $this); } } if (PEAR_ZE2 && $this->mode & PEAR_ERROR_EXCEPTION) { diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php index 8a3d48e884..8026a7bfb1 100644 --- a/pear/PEAR/Command/Install.php +++ b/pear/PEAR/Command/Install.php @@ -259,6 +259,7 @@ package if needed. $installed = array_flip($reg->listPackages()); $params = array(); foreach ($latest as $package => $info) { + $package = strtolower($package); if (!isset($installed[$package])) { // skip packages we don't have installed continue; @@ -269,7 +270,7 @@ package if needed. continue; } $params[] = $package; - $this->ui->outputData("will upgrade $package", $command); + $this->ui->outputData(array('data' => "Will upgrade $package"), $command); } } foreach ($params as $pkg) { @@ -334,7 +335,7 @@ package if needed. return $this->raiseError("Please supply the package you want to bundle"); } $pkgfile = $params[0]; - + $need_download = false; if (preg_match('#^(http|ftp)://#', $pkgfile)) { $need_download = true; } elseif (!@is_file($pkgfile)) { diff --git a/pear/PEAR/Command/Registry.php b/pear/PEAR/Command/Registry.php index 31ebd8b653..e07526a5a6 100644 --- a/pear/PEAR/Command/Registry.php +++ b/pear/PEAR/Command/Registry.php @@ -340,6 +340,7 @@ installed package.' $key = ucwords(trim(str_replace('_', ' ', $key))); $data['data'][] = array($key, $value); } + $data['raw'] = $info; $this->ui->outputData($data, 'package-info'); } diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php index 45494874db..205b3dd8b6 100644 --- a/pear/PEAR/Command/Remote.php +++ b/pear/PEAR/Command/Remote.php @@ -282,7 +282,8 @@ parameter. } $server = $this->config->get('master_server'); if (!ereg('^http://', $params[0])) { - $pkgfile = "http://$server/get/$params[0]"; + $getoption = isset($options['nocompress'])&&$options['nocompress']==1?'?uncompress=on':''; + $pkgfile = "http://$server/get/$params[0]".$getoption; } else { $pkgfile = $params[0]; } diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index 99db180d24..81f88b6643 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -156,7 +156,7 @@ class PEAR_Common extends PEAR $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles']; while ($file = array_shift($tempfiles)) { if (@is_dir($file)) { - System::rm("-rf $file"); + System::rm(array('-rf', $file)); } elseif (file_exists($file)) { unlink($file); } @@ -198,7 +198,7 @@ class PEAR_Common extends PEAR function mkDirHier($dir) { $this->log(2, "+ create dir $dir"); - return System::mkDir("-p $dir"); + return System::mkDir(array('-p', $dir)); } // }}} @@ -242,11 +242,12 @@ class PEAR_Common extends PEAR function mkTempDir($tmpdir = '') { if ($tmpdir) { - $topt = "-t $tmpdir "; + $topt = array('-t', $tmpdir); } else { - $topt = ''; + $topt = array(); } - if (!$tmpdir = System::mktemp($topt . '-d pear')) { + $topt = array_merge($topt, array('-d', 'pear')); + if (!$tmpdir = System::mktemp($topt)) { return false; } $this->addTempFile($tmpdir); @@ -567,7 +568,11 @@ class PEAR_Common extends PEAR } break; case 'license': - $this->pkginfo['release_license'] = $data; + if ($this->in_changelog) { + $this->current_release['release_license'] = $data; + } else { + $this->pkginfo['release_license'] = $data; + } break; case 'dep': if ($data && !$this->in_changelog) { @@ -671,9 +676,17 @@ class PEAR_Common extends PEAR return $this->raiseError("could not open file \"$file\""); } $tar = new Archive_Tar($file); + if ($this->debug <= 1) { + $tar->pushErrorHandling(PEAR_ERROR_RETURN); + } $content = $tar->listContent(); + if ($this->debug <= 1) { + $tar->popErrorHandling(); + } if (!is_array($content)) { - return $this->raiseError("could not get contents of package \"$file\""); + $file = realpath($file); + return $this->raiseError("Could not get contents of package \"$file\"". + '. Invalid tgz file.'); } $xml = null; foreach ($content as $file) { @@ -688,7 +701,7 @@ class PEAR_Common extends PEAR } $tmpdir = System::mkTemp('-d pear'); $this->addTempFile($tmpdir); - if (!$xml || !$tar->extractList($xml, $tmpdir)) { + if (!$xml || !$tar->extractList(array($xml), $tmpdir)) { return $this->raiseError('could not extract the package.xml file'); } return $this->infoFromDescriptionFile("$tmpdir/$xml"); @@ -1099,6 +1112,7 @@ class PEAR_Common extends PEAR if (empty($c['prompt'])) { $errors[] = "configure option $i: missing prompt"; } + $i++; } } if (empty($info['filelist'])) { @@ -1155,7 +1169,7 @@ class PEAR_Common extends PEAR * Build a "provides" array from data returned by * analyzeSourceCode(). The format of the built array is like * this: - * + * * array( * 'class;MyClass' => 'array('type' => 'class', 'name' => 'MyClass'), * ... @@ -1168,7 +1182,7 @@ class PEAR_Common extends PEAR * @return void * * @access public - * + * */ function buildProvidesArray($srcinfo) { @@ -1597,7 +1611,7 @@ class PEAR_Common extends PEAR $errno, $errstr)); } return PEAR::raiseError("Connection to `$host:$port' failed: $errstr", $errno); - } + } $request = "GET $path HTTP/1.0\r\n"; } $request .= "Host: $host:$port\r\n". diff --git a/pear/PEAR/Config.php b/pear/PEAR/Config.php index fb12ded5f6..a4f51400fd 100644 --- a/pear/PEAR/Config.php +++ b/pear/PEAR/Config.php @@ -577,7 +577,8 @@ class PEAR_Config extends PEAR } $data = ($data === null) ? $this->configuration[$layer] : $data; $this->_encodeOutput($data); - if (!@System::mkDir("-p " . dirname($file))) { + $opt = array('-p', dirname($file)); + if (!@System::mkDir($opt)) { return $this->raiseError("could not create directory: " . dirname($file)); } if (@is_file($file) && !@is_writeable($file)) { diff --git a/pear/PEAR/Dependency.php b/pear/PEAR/Dependency.php index c4c2760504..37afd71a36 100644 --- a/pear/PEAR/Dependency.php +++ b/pear/PEAR/Dependency.php @@ -139,6 +139,7 @@ class PEAR_Dependency $errmsg = "requires package `$name' " . $this->signOperator($relation) . " $req"; $code = $this->codeFromRelation($relation, $version, $req); + return PEAR_DEPENDENCY_MISSING; } return false; } diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 9f95e25aa6..416fab9991 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -715,11 +715,12 @@ class PEAR_Installer extends PEAR_Common $this->rollbackFileTransaction(); return $built; } + $this->log(1, "\nBuild process completed successfully"); foreach ($built as $ext) { $bn = basename($ext['file']); - $this->log(2, "installing $bn"); $dest = $this->config->get('ext_dir') . DIRECTORY_SEPARATOR . $bn; - $this->log(3, "+ cp $ext[file] ext_dir"); + $this->log(1, "Installing '$bn' at ext_dir ($dest)"); + $this->log(3, "+ cp $ext[file] ext_dir ($dest)"); $copyto = $this->_prependPath($dest, $this->installroot); if (!@copy($ext['file'], $copyto)) { $this->rollbackFileTransaction(); diff --git a/pear/PEAR/Packager.php b/pear/PEAR/Packager.php index 58e550992c..1bf1b76436 100644 --- a/pear/PEAR/Packager.php +++ b/pear/PEAR/Packager.php @@ -116,7 +116,7 @@ class PEAR_Packager extends PEAR_Common chdir($oldcwd); return $this->raiseError($new_xml); } - if (!($tmpdir = System::mktemp('-t '.getcwd().' -d'))) { + if (!($tmpdir = System::mktemp(array('-t', getcwd(), '-d')))) { chdir($oldcwd); return $this->raiseError("PEAR_Packager: mktemp failed"); } @@ -135,7 +135,7 @@ class PEAR_Packager extends PEAR_Common $tar =& new Archive_Tar($dest_package, $compress); $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors // ----- Creates with the package.xml file - $ok = $tar->createModify($newpkgfile, '', $tmpdir); + $ok = $tar->createModify(array($newpkgfile), '', $tmpdir); if (PEAR::isError($ok)) { chdir($oldcwd); return $this->raiseError($ok); diff --git a/pear/PEAR/Registry.php b/pear/PEAR/Registry.php index a93713f184..96ac23087f 100644 --- a/pear/PEAR/Registry.php +++ b/pear/PEAR/Registry.php @@ -146,7 +146,7 @@ class PEAR_Registry extends PEAR function _assertStateDir() { if (!@is_dir($this->statedir)) { - if (!System::mkdir("-p {$this->statedir}")) { + if (!System::mkdir(array('-p', $this->statedir))) { return $this->raiseError("could not create directory '{$this->statedir}'"); } } diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php index b7e34911e3..eca2c38409 100644 --- a/pear/PEAR/Remote.php +++ b/pear/PEAR/Remote.php @@ -50,21 +50,18 @@ class PEAR_Remote extends PEAR // {{{ getCache() - + function getCache($args) { $id = md5(serialize($args)); $cachedir = $this->config->get('cache_dir'); - if (!file_exists($cachedir)) { - System::mkdir('-p '.$cachedir); - } $filename = $cachedir . DIRECTORY_SEPARATOR . 'xmlrpc_cache_' . $id; if (!file_exists($filename)) { return null; }; - - $fp = fopen($filename, "rb"); - if ($fp === null) { + + $fp = fopen($filename, 'rb'); + if (!$fp) { return null; } $content = fread($fp, filesize($filename)); @@ -78,7 +75,7 @@ class PEAR_Remote extends PEAR } // }}} - + // {{{ saveCache() function saveCache($args, $data) @@ -86,32 +83,32 @@ class PEAR_Remote extends PEAR $id = md5(serialize($args)); $cachedir = $this->config->get('cache_dir'); if (!file_exists($cachedir)) { - System::mkdir('-p '.$cachedir); + System::mkdir(array('-p', $cachedir)); } $filename = $cachedir.'/xmlrpc_cache_'.$id; - + $fp = @fopen($filename, "wb"); - if ($fp !== null) { + if ($fp) { fwrite($fp, serialize($data)); fclose($fp); }; } // }}} - + // {{{ call(method, [args...]) function call($method) { $_args = $args = func_get_args(); - + $this->cache = $this->getCache($args); $cachettl = $this->config->get('cache_ttl'); // If cache is newer than $cachettl seconds, we use the cache! if ($this->cache !== null && $this->cache['age'] < $cachettl) { return $this->cache['content']; }; - + if (extension_loaded("xmlrpc")) { $result = call_user_func_array(array(&$this, 'call_epi'), $args); if (!PEAR::isError($result)) { @@ -140,7 +137,7 @@ class PEAR_Remote extends PEAR $proxy_port = @$proxy['port']; $proxy_user = @$proxy['user']; $proxy_pass = @$proxy['pass']; - } + } $c = new XML_RPC_Client('/xmlrpc.php'.$maxAge, $server_host, 80, $proxy_host, $proxy_port, $proxy_user, $proxy_pass); if ($username && $password) { $c->setCredentials($username, $password); @@ -204,8 +201,20 @@ class PEAR_Remote extends PEAR return $this->raiseError("PEAR_Remote::call: no master_server configured"); } $server_port = 80; - $fp = @fsockopen($server_host, $server_port); - if (!$fp) { + if ($http_proxy = $this->config->get('http_proxy')) { + $proxy = parse_url($http_proxy); + $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; + $proxy_host = @$proxy['host']; + $proxy_port = @$proxy['port']; + $proxy_user = @$proxy['user']; + $proxy_pass = @$proxy['pass']; + $fp = @fsockopen($proxy_host, $proxy_port); + } else { + $fp = @fsockopen($server_host, $server_port); + } + if (!$fp && $http_proxy) { + return $this->raiseError("PEAR_Remote::call: fsockopen(`$proxy_host', $proxy_port) failed"); + } elseif (!$fp) { return $this->raiseError("PEAR_Remote::call: fsockopen(`$server_host', $server_port) failed"); } $len = strlen($request); @@ -224,15 +233,30 @@ class PEAR_Remote extends PEAR } else { $maxAge = ''; }; - + + if ($proxy_host != '' && $proxy_user != '') { + $req_headers .= 'Proxy-Authorization: Basic ' + .base64_encode($proxy_user.':'.$proxy_pass) + ."\r\n"; + } + if ($this->config->get('verbose') > 3) { print "XMLRPC REQUEST HEADERS:\n"; var_dump($req_headers); print "XMLRPC REQUEST BODY:\n"; var_dump($request); } - - fwrite($fp, ("POST /xmlrpc.php$maxAge HTTP/1.0\r\n$req_headers\r\n$request")); + + if ($proxy_host != '') { + $post_string = "POST http://".$server_host; + if ($proxy_port > '') { + $post_string .= ':'.$server_port; + } + } else { + $post_string = "POST "; + } + + fwrite($fp, ($post_string."/xmlrpc.php$maxAge HTTP/1.0\r\n$req_headers\r\n$request")); $response = ''; $line1 = fgets($fp, 2048); if (!preg_match('!^HTTP/[0-9\.]+ (\d+) (.*)!', $line1, $matches)) { diff --git a/pear/install-pear.php b/pear/install-pear.php index 1dd72d3a26..24b3d9a51b 100644 --- a/pear/install-pear.php +++ b/pear/install-pear.php @@ -23,6 +23,9 @@ for ($i = 0; $i < sizeof($argv); $i++) { } elseif ($arg == '-d') { $with_dir = $argv[$i+1]; $i++; + } elseif ($arg == '-b') { + $bin_dir = $argv[$i+1]; + $i++; } } @@ -36,11 +39,14 @@ foreach ($config_layers as $layer) { } $keys = $config->getKeys(); $config->set('verbose', 0, 'default'); +// PEAR executables +if (!empty($bin_dir)) { + $config->set('bin_dir', $bin_dir, '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'); @@ -115,13 +121,17 @@ foreach ($install_files as $package => $instfile) { 'a previous PEAR installation at ' . "'$ufile'. You may probably want to remove it."); } - $ui->outputData('Writing PEAR system config file at: ' . $config->files['system']); - $ui->outputData('You may want to add: ' . $config->get('php_dir') . ' to your php.ini include_path'); $config->set('verbose', 1, 'default'); foreach ($config->getKeys() as $key) { $data[$key] = $config->get($key); } - $config->store('system', $data); + $cnf_file = $config->getConfFile('system'); + if (!empty($install_root)) { + $cnf_file = $install_root . DIRECTORY_SEPARATOR . $cnf_file; + } + $config->writeConfigFile($cnf_file, 'system', $data); + $ui->outputData('Wrote PEAR system config file at: ' . $cnf_file); + $ui->outputData('You may want to add: ' . $config->get('php_dir') . ' to your php.ini include_path'); } } ?> diff --git a/pear/package-PEAR.xml b/pear/package-PEAR.xml index f88fc848eb..debdd6c9ba 100644 --- a/pear/package-PEAR.xml +++ b/pear/package-PEAR.xml @@ -37,17 +37,22 @@ - 1.2b3 + 1.2b5 beta - 2003-07-08 + 2003-08-05 * Changed license from PHP 2.02 to 3.0 * Added support for optional dependencies * Made upgrade and uninstall package case insensitive * pear makerpm, now works and generates a better system independant spec file -* pear install|build <pecl-package>, now exposes the compilation progress +* pear install|build pecl-package, now exposes the compilation progress * Installer now checks dependencies on package uninstall -* Added new pear bundle command, which downloads and uncompress a <pecl-package>. +* Added proxy support for remote commands using the xmlrcp C ext (Adam Ashley) +* Added the command "download-all" (Alex Merz) +* Made package dependency checking back to work +* Added support for spaces in path names (Greg) +* Various bugfixes +* Added new pear "bundle" command, which downloads and uncompress a PECL package. The main purpouse of this command is for easily adding extensions to the PHP sources before compiling it. @@ -71,6 +76,7 @@ before compiling it. + diff --git a/pear/scripts/pear.sh b/pear/scripts/pear.sh index dad0838338..6253b9014c 100644 --- a/pear/scripts/pear.sh +++ b/pear/scripts/pear.sh @@ -25,4 +25,4 @@ else fi fi -exec $PHP -C -q $INCARG -d output_buffering=1 $INCDIR/pearcmd.php $@ +exec $PHP -C -q $INCARG -d output_buffering=1 $INCDIR/pearcmd.php "$@" -- 2.40.0