From: Greg Beaver Date: Sat, 7 Jan 2006 17:51:55 +0000 (+0000) Subject: update to PEAR 1.4.6, add support for --packagingroot to local PEAR installer (needed... X-Git-Tag: php-4.4.2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e69c67c073e0de6149fb89e2dccdb1ac38adea6;p=php update to PEAR 1.4.6, add support for --packagingroot to local PEAR installer (needed for INSTALL_ROOT) --- diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php index b454b65a20..a08c869e8d 100644 --- a/pear/PEAR/Command/Install.php +++ b/pear/PEAR/Command/Install.php @@ -81,7 +81,12 @@ class PEAR_Command_Install extends PEAR_Command_Common 'installroot' => array( 'shortopt' => 'R', 'arg' => 'DIR', - 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)', + 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT), use packagingroot for RPM', + ), + 'packagingroot' => array( + 'shortopt' => 'P', + 'arg' => 'DIR', + 'doc' => 'root directory used when packaging files, like RPM packaging', ), 'ignore-errors' => array( 'doc' => 'force install even if there were errors', @@ -162,7 +167,12 @@ four ways of specifying packages. 'installroot' => array( 'shortopt' => 'R', 'arg' => 'DIR', - 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)', + 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT), use packagingroot for RPM', + ), + 'packagingroot' => array( + 'shortopt' => 'P', + 'arg' => 'DIR', + 'doc' => 'root directory used when packaging files, like RPM packaging', ), 'ignore-errors' => array( 'doc' => 'force install even if there were errors', @@ -218,7 +228,12 @@ More than one package may be specified at once. 'installroot' => array( 'shortopt' => 'R', 'arg' => 'DIR', - 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)', + 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT), use packagingroot for RPM', + ), + 'packagingroot' => array( + 'shortopt' => 'P', + 'arg' => 'DIR', + 'doc' => 'root directory used when packaging files, like RPM packaging', ), 'ignore-errors' => array( 'doc' => 'force install even if there were errors', @@ -343,6 +358,12 @@ Run post-installation scripts in package , if any exist. if ($command == 'upgrade') { $options['upgrade'] = true; } + if (isset($options['installroot']) && isset($options['packagingroot'])) { + return $this->raiseError('ERROR: cannot use both --installroot and --packagingroot'); + } + if (isset($options['packagingroot']) && $this->config->get('verbose') > 2) { + $this->ui->outputData('using package root: ' . $options['packagingroot']); + } $reg = &$this->config->getRegistry(); if ($command == 'upgrade-all') { $options['upgrade'] = true; diff --git a/pear/PEAR/Dependency2.php b/pear/PEAR/Dependency2.php index 4602b4a342..423dc5b270 100644 --- a/pear/PEAR/Dependency2.php +++ b/pear/PEAR/Dependency2.php @@ -85,11 +85,18 @@ class PEAR_Dependency2 $state = PEAR_VALIDATE_INSTALLING) { $this->_config = &$config; - $this->_registry = &$config->getRegistry(); if (!class_exists('PEAR_DependencyDB')) { require_once 'PEAR/DependencyDB.php'; } + if (isset($installoptions['packagingroot'])) { + // make sure depdb is in the right location + $config->setInstallRoot($installoptions['packagingroot']); + } + $this->_registry = &$config->getRegistry(); $this->_dependencydb = &PEAR_DependencyDB::singleton($config); + if (isset($installoptions['packagingroot'])) { + $config->setInstallRoot(false); + } $this->_options = $installoptions; $this->_state = $state; if (!class_exists('OS_Guess')) { diff --git a/pear/PEAR/Downloader/Package.php b/pear/PEAR/Downloader/Package.php index 9680325074..725b712f66 100644 --- a/pear/PEAR/Downloader/Package.php +++ b/pear/PEAR/Downloader/Package.php @@ -62,6 +62,11 @@ class PEAR_Downloader_Package * @var PEAR_Registry */ var $_registry; + /** + * Used to implement packagingroot properly + * @var PEAR_Registry + */ + var $_installRegistry; /** * @var PEAR_PackageFile_v1|PEAR_PackageFile|v2 */ @@ -117,13 +122,21 @@ class PEAR_Downloader_Package var $_validated = false; /** - * @param PEAR_Config + * @param PEAR_Downloader */ function PEAR_Downloader_Package(&$downloader) { $this->_downloader = &$downloader; $this->_config = &$this->_downloader->config; $this->_registry = &$this->_config->getRegistry(); + $options = $downloader->getOptions(); + if (isset($options['packagingroot'])) { + $this->_config->setInstallRoot($options['packagingroot']); + $this->_installRegistry = &$this->_config->getRegistry(); + $this->_config->setInstallRoot(false); + } else { + $this->_installRegistry = &$this->_registry; + } $this->_valid = $this->_analyzed = false; } @@ -345,8 +358,8 @@ class PEAR_Downloader_Package foreach ($params as $i => $param) { // remove self if already installed with this version // this does not need any pecl magic - we only remove exact matches - if ($param->_registry->packageExists($param->getPackage(), $param->getChannel())) { - if (version_compare($param->_registry->packageInfo($param->getPackage(), 'version', + if ($param->_installRegistry->packageExists($param->getPackage(), $param->getChannel())) { + if (version_compare($param->_installRegistry->packageInfo($param->getPackage(), 'version', $param->getChannel()), $param->getVersion(), '==')) { if (!isset($options['force'])) { $info = $param->getParsedPackage(); @@ -356,7 +369,7 @@ class PEAR_Downloader_Package $param->_downloader->log(1, 'Skipping package "' . $param->getShortName() . '", already installed as version ' . - $param->_registry->packageInfo($param->getPackage(), + $param->_installRegistry->packageInfo($param->getPackage(), 'version', $param->getChannel())); } $params[$i] = false; @@ -367,7 +380,7 @@ class PEAR_Downloader_Package $param->_downloader->log(1, 'Skipping package "' . $param->getShortName() . '", already installed as version ' . - $param->_registry->packageInfo($param->getPackage(), 'version', + $param->_installRegistry->packageInfo($param->getPackage(), 'version', $param->getChannel())); $params[$i] = false; } @@ -569,7 +582,7 @@ class PEAR_Downloader_Package // we can't determine whether upgrade is necessary until we know what // version would be downloaded if (!isset($options['force']) && $this->isInstalled($ret, $oper)) { - $version = $this->_registry->packageInfo($dep['name'], 'version', + $version = $this->_installRegistry->packageInfo($dep['name'], 'version', $dep['channel']); $dep['package'] = $dep['name']; if (!isset($options['soft'])) { @@ -645,7 +658,7 @@ class PEAR_Downloader_Package $chan = 'pecl.php.net'; $url = $this->_downloader->_getDepPackageDownloadUrl($newdep, $pname); - $obj = &$this->_registry->getPackage($dep['name']); + $obj = &$this->_installRegistry->getPackage($dep['name']); if (PEAR::isError($url)) { PEAR::popErrorHandling(); if ($obj !== null && $this->isInstalled($obj, $dep['rel'])) { @@ -724,10 +737,10 @@ class PEAR_Downloader_Package 'optional'; $dep['package'] = $dep['name']; if (isset($newdep)) { - $version = $this->_registry->packageInfo($newdep['name'], 'version', + $version = $this->_installRegistry->packageInfo($newdep['name'], 'version', $newdep['channel']); } else { - $version = $this->_registry->packageInfo($dep['name'], 'version'); + $version = $this->_installRegistry->packageInfo($dep['name'], 'version'); } $dep['version'] = $url['version']; if (!isset($options['soft'])) { @@ -1075,21 +1088,21 @@ class PEAR_Downloader_Package } } $options = $this->_downloader->getOptions(); - $test = $this->_registry->packageExists($package, $channel); + $test = $this->_installRegistry->packageExists($package, $channel); if (!$test && $channel == 'pecl.php.net') { // do magic to allow upgrading from old pecl packages to new ones - $test = $this->_registry->packageExists($package, 'pear.php.net'); + $test = $this->_installRegistry->packageExists($package, 'pear.php.net'); $channel = 'pear.php.net'; } if ($test) { if (isset($dep['uri'])) { - if ($this->_registry->packageInfo($package, 'uri', '__uri') == $dep['uri']) { + if ($this->_installRegistry->packageInfo($package, 'uri', '__uri') == $dep['uri']) { return true; } } if (isset($options['upgrade'])) { if ($oper == 'has') { - if (version_compare($this->_registry->packageInfo( + if (version_compare($this->_installRegistry->packageInfo( $package, 'version', $channel), $dep['version'], '>=')) { return true; @@ -1097,7 +1110,7 @@ class PEAR_Downloader_Package return false; } } else { - if (version_compare($this->_registry->packageInfo( + if (version_compare($this->_installRegistry->packageInfo( $package, 'version', $channel), $dep['version'], '>=')) { return true; diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 978912c338..c8dfcde9ef 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -282,6 +282,15 @@ class PEAR_Installer extends PEAR_Downloader DIRECTORY_SEPARATOR), array($dest_file, $orig_file)); $final_dest_file = $installed_as = $dest_file; + if (isset($this->_options['packagingroot'])) { + $installedas_dest_dir = dirname($final_dest_file); + $installedas_dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file); + $final_dest_file = $this->_prependPath($final_dest_file, + $this->_options['packagingroot']); + } else { + $installedas_dest_dir = dirname($final_dest_file); + $installedas_dest_file = $installedas_dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file); + } $dest_dir = dirname($final_dest_file); $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file); // }}} @@ -429,7 +438,7 @@ class PEAR_Installer extends PEAR_Downloader $atts['role'] == 'ext')); // Store the full path where the file was installed for easy unistall $this->addFileOperation("installed_as", array($file, $installed_as, - $save_destdir, dirname(substr($dest_file, strlen($save_destdir))))); + $save_destdir, dirname(substr($installedas_dest_file, strlen($save_destdir))))); //$this->log(2, "installed: $dest_file"); return PEAR_INSTALLER_OK; @@ -474,6 +483,10 @@ class PEAR_Installer extends PEAR_Downloader list($save_destdir, $dest_dir, $dest_file, $orig_file) = $info; } $final_dest_file = $installed_as = $dest_file; + if (isset($this->_options['packagingroot'])) { + $final_dest_file = $this->_prependPath($final_dest_file, + $this->_options['packagingroot']); + } $dest_dir = dirname($final_dest_file); $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file); // }}} @@ -980,22 +993,38 @@ class PEAR_Installer extends PEAR_Downloader $pkgname = $pkg->getName(); $channel = $pkg->getChannel(); + if (isset($this->_options['packagingroot'])) { + $packrootphp_dir = $this->_prependPath( + $this->config->get('php_dir', null, 'pear.php.net'), + $this->_options['packagingroot']); + } if (isset($options['installroot'])) { $this->config->setInstallRoot($options['installroot']); $this->_registry = &$this->config->getRegistry(); + $installregistry = &$this->_registry; $this->installroot = ''; // all done automagically now } else { $this->config->setInstallRoot(false); $this->_registry = &$this->config->getRegistry(); + if (isset($this->_options['packagingroot'])) { + $installregistry = &new PEAR_Registry($packrootphp_dir); + $php_dir = $packrootphp_dir; + } else { + $installregistry = &$this->_registry; + $php_dir = $this->config->get('php_dir', null, $channel); + } $this->installroot = ''; } - $php_dir = $this->config->get('php_dir', null, $channel); // {{{ checks to do when not in "force" mode if (empty($options['force']) && @is_dir($this->config->get('php_dir'))) { $testp = $channel == 'pear.php.net' ? $pkgname : array($channel, $pkgname); - $test = $this->_registry->checkFileMap($pkg->getInstallationFileList(true), $testp, '1.1'); + $instfilelist = $pkg->getInstallationFileList(true); + if (PEAR::isError($instfilelist)) { + return $instfilelist; + } + $test = $installregistry->checkFileMap($instfilelist, $testp, '1.1'); if (PEAR::isError($test)) { return $test; } @@ -1010,7 +1039,7 @@ class PEAR_Installer extends PEAR_Downloader } if ($found) { // subpackages can conflict with earlier versions of parent packages - $parentreg = $this->_registry->packageInfo($param->getPackage(), null, $param->getChannel()); + $parentreg = $installregistry->packageInfo($param->getPackage(), null, $param->getChannel()); $tmp = $test; foreach ($tmp as $file => $info) { if (is_array($info)) { @@ -1031,7 +1060,7 @@ class PEAR_Installer extends PEAR_Downloader } $pfk = &new PEAR_PackageFile($this->config); $parentpkg = &$pfk->fromArray($parentreg); - $this->_registry->updatePackage2($parentpkg); + $installregistry->updatePackage2($parentpkg); } if ($param->getChannel() == 'pecl.php.net' && isset($options['upgrade'])) { $tmp = $test; @@ -1073,12 +1102,12 @@ class PEAR_Installer extends PEAR_Downloader if (empty($options['upgrade']) && empty($options['soft'])) { // checks to do only when installing new packages if ($channel == 'pecl.php.net') { - $test = $this->_registry->packageExists($pkgname, $channel); + $test = $installregistry->packageExists($pkgname, $channel); if (!$test) { - $test = $this->_registry->packageExists($pkgname, 'pear.php.net'); + $test = $installregistry->packageExists($pkgname, 'pear.php.net'); } } else { - $test = $this->_registry->packageExists($pkgname, $channel); + $test = $installregistry->packageExists($pkgname, $channel); } if (empty($options['force']) && $test) { return $this->raiseError("$channel/$pkgname is already installed"); @@ -1086,16 +1115,16 @@ class PEAR_Installer extends PEAR_Downloader } else { $usechannel = $channel; if ($channel == 'pecl.php.net') { - $test = $this->_registry->packageExists($pkgname, $channel); + $test = $installregistry->packageExists($pkgname, $channel); if (!$test) { - $test = $this->_registry->packageExists($pkgname, 'pear.php.net'); + $test = $installregistry->packageExists($pkgname, 'pear.php.net'); $usechannel = 'pear.php.net'; } } else { - $test = $this->_registry->packageExists($pkgname, $channel); + $test = $installregistry->packageExists($pkgname, $channel); } if ($test) { - $v1 = $this->_registry->packageInfo($pkgname, 'version', $usechannel); + $v1 = $installregistry->packageInfo($pkgname, 'version', $usechannel); $v2 = $pkg->getVersion(); $cmp = version_compare("$v1", "$v2", 'gt'); if (empty($options['force']) && !version_compare("$v2", "$v1", 'gt')) { @@ -1151,7 +1180,7 @@ class PEAR_Installer extends PEAR_Downloader return $filelist; } $pkg->resetFilelist(); - $pkg->setLastInstalledVersion($this->_registry->packageInfo($pkg->getPackage(), + $pkg->setLastInstalledVersion($installregistry->packageInfo($pkg->getPackage(), 'version', $pkg->getChannel())); foreach ($filelist as $file => $atts) { if ($pkg->getPackagexmlVersion() == '1.0') { @@ -1211,39 +1240,39 @@ class PEAR_Installer extends PEAR_Downloader // if 'force' is used, replace the info in registry $usechannel = $channel; if ($channel == 'pecl.php.net') { - $test = $this->_registry->packageExists($pkgname, $channel); + $test = $installregistry->packageExists($pkgname, $channel); if (!$test) { - $test = $this->_registry->packageExists($pkgname, 'pear.php.net'); + $test = $installregistry->packageExists($pkgname, 'pear.php.net'); $usechannel = 'pear.php.net'; } } else { - $test = $this->_registry->packageExists($pkgname, $channel); + $test = $installregistry->packageExists($pkgname, $channel); } if (!empty($options['force']) && $test) { - $oldversion = $this->_registry->packageInfo($pkgname, 'version', $usechannel); - $this->_registry->deletePackage($pkgname, $usechannel); + $oldversion = $installregistry->packageInfo($pkgname, 'version', $usechannel); + $installregistry->deletePackage($pkgname, $usechannel); } - $ret = $this->_registry->addPackage2($pkg); + $ret = $installregistry->addPackage2($pkg); } else { $usechannel = $channel; if ($channel == 'pecl.php.net') { - $test = $this->_registry->packageExists($pkgname, $channel); + $test = $installregistry->packageExists($pkgname, $channel); if (!$test) { - $test = $this->_registry->packageExists($pkgname, 'pear.php.net'); + $test = $installregistry->packageExists($pkgname, 'pear.php.net'); $usechannel = 'pear.php.net'; } } else { - $test = $this->_registry->packageExists($pkgname, $channel); + $test = $installregistry->packageExists($pkgname, $channel); } // new: upgrade installs a package if it isn't installed if (!$test) { - $ret = $this->_registry->addPackage2($pkg); + $ret = $installregistry->addPackage2($pkg); } else { if ($usechannel != $channel) { - $this->_registry->deletePackage($pkgname, $usechannel); - $ret = $this->_registry->addPackage2($pkg); + $installregistry->deletePackage($pkgname, $usechannel); + $ret = $installregistry->addPackage2($pkg); } else { - $ret = $this->_registry->updatePackage2($pkg); + $ret = $installregistry->updatePackage2($pkg); } $installphase = 'upgrade'; } diff --git a/pear/PEAR/Registry.php b/pear/PEAR/Registry.php index cca21cbd0e..92efa12e49 100644 --- a/pear/PEAR/Registry.php +++ b/pear/PEAR/Registry.php @@ -690,7 +690,7 @@ class PEAR_Registry extends PEAR { $fp = @fopen($this->filemap, 'r'); if (!$fp) { - return $this->raiseError('PEAR_Registry: could not open filemap', PEAR_REGISTRY_ERROR_FILE, null, null, $php_errormsg); + return $this->raiseError('PEAR_Registry: could not open filemap "' . $this->filemap . '"', PEAR_REGISTRY_ERROR_FILE, null, null, $php_errormsg); } clearstatcache(); $rt = get_magic_quotes_runtime(); diff --git a/pear/install-pear.php b/pear/install-pear.php index 1251b6874c..4bbb409c1f 100644 --- a/pear/install-pear.php +++ b/pear/install-pear.php @@ -46,6 +46,9 @@ for ($i = 0; $i < sizeof($argv); $i++) { } elseif ($arg == '-b') { $bin_dir = $argv[$i+1]; $i++; + } elseif ($arg == '-p') { + $php_bin = $argv[$i+1]; + $i++; } elseif ($arg == '--debug') { $debug = 1; } elseif ($arg == '--extremedebug') { @@ -89,6 +92,9 @@ if (!empty($with_dir)) { $config->set('cache_dir', $cdir); } } +if (!empty($php_bin)) { + $config->set('php_bin', $php_bin); +} /* Print PEAR Conf (useful for debuging do NOT REMOVE) */ if ($debug) { sort($keys); @@ -107,11 +113,12 @@ $options = array(); $options['upgrade'] = true; $install_root = getenv('INSTALL_ROOT'); if (!empty($install_root)) { - $options['installroot'] = $install_root; - $config->setInstallRoot($install_root); + $options['packagingroot'] = $install_root; + $reg = &new PEAR_Registry($options['packagingroot']); +} else { + $reg = $config->getRegistry('default'); } -$reg = $config->getRegistry('default'); $ui = &PEAR_Frontend::singleton('PEAR_Frontend_CLI'); $installer = &new PEAR_Installer($ui); $pkg = &new PEAR_PackageFile($config, $debug); diff --git a/pear/packages/PEAR-1.4.5.tar b/pear/packages/PEAR-1.4.5.tar deleted file mode 100644 index 8f3b693e93..0000000000 Binary files a/pear/packages/PEAR-1.4.5.tar and /dev/null differ diff --git a/pear/packages/PEAR-1.4.6.tar b/pear/packages/PEAR-1.4.6.tar new file mode 100644 index 0000000000..ba39730865 Binary files /dev/null and b/pear/packages/PEAR-1.4.6.tar differ