]> granicus.if.org Git - php/commitdiff
update to PEAR 1.4.6, add support for --packagingroot to local PEAR installer (needed...
authorGreg Beaver <cellog@php.net>
Sat, 7 Jan 2006 17:51:55 +0000 (17:51 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 7 Jan 2006 17:51:55 +0000 (17:51 +0000)
pear/PEAR/Command/Install.php
pear/PEAR/Dependency2.php
pear/PEAR/Downloader/Package.php
pear/PEAR/Installer.php
pear/PEAR/Registry.php
pear/install-pear.php
pear/packages/PEAR-1.4.5.tar [deleted file]
pear/packages/PEAR-1.4.6.tar [new file with mode: 0644]

index b454b65a20d3877df4362cf7c6e320928822766b..a08c869e8d5f431660ee7f1ddb350c9f1413d700 100644 (file)
@@ -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 <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;
index 4602b4a342f9ae64cda2ed7914582b54ed936ae9..423dc5b27038cb25280932b8c1ad9c49535460fc 100644 (file)
@@ -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')) {
index 9680325074a05d6988faf93103571491c361e8ca..725b712f66cca51281ec6c34a016ae63cc012c39 100644 (file)
@@ -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;
index 978912c3384ffffdd19b00e7fc113d7cb7c0d558..c8dfcde9ef84ddd60d29655d3a44589449e909eb 100644 (file)
@@ -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';
             }
index cca21cbd0ec181ff55c861c37041c97c757828e8..92efa12e49dc6b63711f09ab586e38d6f2bfc546 100644 (file)
@@ -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();
index 1251b6874cec1679d5ab445bfe0accf4a202f50c..4bbb409c1f3264a6ff34713837a2292ca92d0291 100644 (file)
@@ -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 (file)
index 8f3b693..0000000
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 (file)
index 0000000..ba39730
Binary files /dev/null and b/pear/packages/PEAR-1.4.6.tar differ