2fd457
diff -up PEAR/Command/Install.php.metadata PEAR/Command/Install.php
2fd457
--- PEAR/Command/Install.php.metadata	2011-07-07 00:11:24.000000000 +0200
2fd457
+++ PEAR/Command/Install.php	2012-09-26 16:02:29.829393773 +0200
2fd457
@@ -556,7 +556,13 @@ Run post-installation scripts in package
2fd457
             $packrootphp_dir = $this->installer->_prependPath(
2fd457
                 $this->config->get('php_dir', null, 'pear.php.net'),
2fd457
                 $options['packagingroot']);
2fd457
-            $instreg = new PEAR_Registry($packrootphp_dir); // other instreg!
2fd457
+            $metadata_dir = $this->config->get('metadata_dir', null, 'pear.php.net');
2fd457
+            if ($metadata_dir) {
2fd457
+                $metadata_dir = $this->installer->_prependPath(
2fd457
+                    $metadata_dir,
2fd457
+                    $options['packagingroot']);
2fd457
+            }
2fd457
+            $instreg = new PEAR_Registry($packrootphp_dir, false, false, $metadata_dir); // other instreg!
2fd457
 
2fd457
             if ($this->config->get('verbose') > 2) {
2fd457
                 $this->ui->outputData('using package root: ' . $options['packagingroot']);
2fd457
diff -up PEAR/Config.php.metadata PEAR/Config.php
2fd457
--- PEAR/Config.php.metadata	2011-07-07 00:11:24.000000000 +0200
2fd457
+++ PEAR/Config.php	2012-09-26 16:02:29.831393779 +0200
2fd457
@@ -87,6 +87,13 @@ if (getenv('PHP_PEAR_INSTALL_DIR')) {
2fd457
     }
2fd457
 }
2fd457
 
2fd457
+// Default for metadata_dir
2fd457
+if (getenv('PHP_PEAR_METADATA_DIR')) {
2fd457
+    define('PEAR_CONFIG_DEFAULT_METADATA_DIR', getenv('PHP_PEAR_METADATA_DIR'));
2fd457
+} else {
2fd457
+    define('PEAR_CONFIG_DEFAULT_METADATA_DIR', '');
2fd457
+}
2fd457
+
2fd457
 // Default for ext_dir
2fd457
 if (getenv('PHP_PEAR_EXTENSION_DIR')) {
2fd457
     define('PEAR_CONFIG_DEFAULT_EXT_DIR', getenv('PHP_PEAR_EXTENSION_DIR'));
2fd457
@@ -398,6 +405,13 @@ class PEAR_Config extends PEAR
2fd457
             'prompt' => 'PEAR directory',
2fd457
             'group' => 'File Locations',
2fd457
             ),
2fd457
+        'metadata_dir' => array(
2fd457
+            'type' => 'directory',
2fd457
+            'default' => PEAR_CONFIG_DEFAULT_METADATA_DIR,
2fd457
+            'doc' => 'directory where metadata files are installed (registry, filemap, channels, ...)',
2fd457
+            'prompt' => 'PEAR metadata directory',
2fd457
+            'group' => 'File Locations',
2fd457
+            ),
2fd457
         'ext_dir' => array(
2fd457
             'type' => 'directory',
2fd457
             'default' => PEAR_CONFIG_DEFAULT_EXT_DIR,
2fd457
@@ -647,7 +661,9 @@ class PEAR_Config extends PEAR
2fd457
             $this->configuration['default'][$key] = $info['default'];
2fd457
         }
2fd457
 
2fd457
-        $this->_registry['default'] = &new PEAR_Registry($this->configuration['default']['php_dir']);
2fd457
+        $this->_registry['default'] = &new PEAR_Registry(
2fd457
+            $this->configuration['default']['php_dir'], false, false,
2fd457
+            $this->configuration['default']['metadata_dir']);
2fd457
         $this->_registry['default']->setConfig($this, false);
2fd457
         $this->_regInitialized['default'] = false;
2fd457
         //$GLOBALS['_PEAR_Config_instance'] = &$this;
2fd457
@@ -754,7 +770,9 @@ class PEAR_Config extends PEAR
2fd457
         $this->configuration[$layer] = $data;
2fd457
         $this->_setupChannels();
2fd457
         if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
2fd457
-            $this->_registry[$layer] = &new PEAR_Registry($phpdir);
2fd457
+            $this->_registry[$layer] = &new PEAR_Registry(
2fd457
+                $phpdir, false, false,
2fd457
+                $this->get('metadata_dir', $layer, 'pear.php.net'));
2fd457
             $this->_registry[$layer]->setConfig($this, false);
2fd457
             $this->_regInitialized[$layer] = false;
2fd457
         } else {
2fd457
@@ -911,7 +929,9 @@ class PEAR_Config extends PEAR
2fd457
 
2fd457
         $this->_setupChannels();
2fd457
         if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
2fd457
-            $this->_registry[$layer] = &new PEAR_Registry($phpdir);
2fd457
+            $this->_registry[$layer] = &new PEAR_Registry(
2fd457
+                $phpdir, false, false,
2fd457
+                $this->get('metadata_dir', $layer, 'pear.php.net'));
2fd457
             $this->_registry[$layer]->setConfig($this, false);
2fd457
             $this->_regInitialized[$layer] = false;
2fd457
         } else {
2fd457
@@ -1604,7 +1624,9 @@ class PEAR_Config extends PEAR
2fd457
 
2fd457
                 if (!is_object($this->_registry[$layer])) {
2fd457
                     if ($phpdir = $this->get('php_dir', $layer, 'pear.php.net')) {
2fd457
-                        $this->_registry[$layer] = &new PEAR_Registry($phpdir);
2fd457
+                        $this->_registry[$layer] = &new PEAR_Registry(
2fd457
+                            $phpdir, false, false,
2fd457
+                            $this->get('metadata_dir', $layer, 'pear.php.net'));
2fd457
                         $this->_registry[$layer]->setConfig($this, false);
2fd457
                         $this->_regInitialized[$layer] = false;
2fd457
                     } else {
2fd457
@@ -2087,8 +2109,9 @@ class PEAR_Config extends PEAR
2fd457
                 if ($layer == 'ftp' || !isset($this->_registry[$layer])) {
2fd457
                     continue;
2fd457
                 }
2fd457
-                $this->_registry[$layer] =
2fd457
-                    &new PEAR_Registry($this->get('php_dir', $layer, 'pear.php.net'));
2fd457
+                $this->_registry[$layer] = &new PEAR_Registry(
2fd457
+                    $this->get('php_dir', $layer, 'pear.php.net'), false, false,
2fd457
+                    $this->get('metadata_dir', $layer, 'pear.php.net'));
2fd457
                 $this->_registry[$layer]->setConfig($this, false);
2fd457
                 $this->_regInitialized[$layer] = false;
2fd457
             }
2fd457
diff -up PEAR/DependencyDB.php.metadata PEAR/DependencyDB.php
2fd457
--- PEAR/DependencyDB.php.metadata	2011-07-07 00:11:24.000000000 +0200
2fd457
+++ PEAR/DependencyDB.php	2012-09-26 16:02:29.832393782 +0200
2fd457
@@ -122,8 +122,11 @@ class PEAR_DependencyDB
2fd457
 
2fd457
         $this->_registry = &$this->_config->getRegistry();
2fd457
         if (!$depdb) {
2fd457
-            $this->_depdb = $this->_config->get('php_dir', null, 'pear.php.net') .
2fd457
-                DIRECTORY_SEPARATOR . '.depdb';
2fd457
+            $dir = $this->_config->get('metadata_dir', null, 'pear.php.net');
2fd457
+            if (!$dir) {
2fd457
+                $dir = $this->_config->get('php_dir', null, 'pear.php.net');
2fd457
+            }
2fd457
+            $this->_depdb =  $dir . DIRECTORY_SEPARATOR . '.depdb';
2fd457
         } else {
2fd457
             $this->_depdb = $depdb;
2fd457
         }
2fd457
@@ -766,4 +769,4 @@ class PEAR_DependencyDB
2fd457
             );
2fd457
         }
2fd457
     }
2fd457
-}
2fd457
\ Pas de fin de ligne à la fin du fichier
2fd457
+}
2fd457
diff -up PEAR/Installer.php.metadata PEAR/Installer.php
2fd457
--- PEAR/Installer.php.metadata	2011-07-07 00:11:24.000000000 +0200
2fd457
+++ PEAR/Installer.php	2012-09-26 16:03:15.079556967 +0200
2fd457
@@ -1162,15 +1162,6 @@ class PEAR_Installer extends PEAR_Downlo
2fd457
 
2fd457
         $pkgname = $pkg->getName();
2fd457
         $channel = $pkg->getChannel();
2fd457
-        if (isset($this->_options['packagingroot'])) {
2fd457
-            $regdir = $this->_prependPath(
2fd457
-                $this->config->get('php_dir', null, 'pear.php.net'),
2fd457
-                $this->_options['packagingroot']);
2fd457
-
2fd457
-            $packrootphp_dir = $this->_prependPath(
2fd457
-                $this->config->get('php_dir', null, $channel),
2fd457
-                $this->_options['packagingroot']);
2fd457
-        }
2fd457
 
2fd457
         if (isset($options['installroot'])) {
2fd457
             $this->config->setInstallRoot($options['installroot']);
2fd457
@@ -1182,7 +1173,21 @@ class PEAR_Installer extends PEAR_Downlo
2fd457
             $this->config->setInstallRoot(false);
2fd457
             $this->_registry = &$this->config->getRegistry();
2fd457
             if (isset($this->_options['packagingroot'])) {
2fd457
-                $installregistry = &new PEAR_Registry($regdir);
2fd457
+                $regdir = $this->_prependPath(
2fd457
+                    $this->config->get('php_dir', null, 'pear.php.net'),
2fd457
+                    $this->_options['packagingroot']);
2fd457
+
2fd457
+                $metadata_dir = $this->config->get('metadata_dir', null, 'pear.php.net');
2fd457
+                if ($metadata_dir) {
2fd457
+                    $metadata_dir = $this->_prependPath(
2fd457
+                        $metadata_dir,
2fd457
+                        $this->_options['packagingroot']);
2fd457
+                }
2fd457
+                $packrootphp_dir = $this->_prependPath(
2fd457
+                    $this->config->get('php_dir', null, $channel),
2fd457
+                    $this->_options['packagingroot']);
2fd457
+
2fd457
+                $installregistry = &new PEAR_Registry($regdir, false, false, $metadata_dir);
2fd457
                 if (!$installregistry->channelExists($channel, true)) {
2fd457
                     // we need to fake a channel-discover of this channel
2fd457
                     $chanobj = $this->_registry->getChannel($channel, true);
2fd457
@@ -1820,4 +1825,4 @@ class PEAR_Installer extends PEAR_Downlo
2fd457
     }
2fd457
 
2fd457
     // }}}
2fd457
-}
2fd457
\ Pas de fin de ligne à la fin du fichier
2fd457
+}
2fd457
diff --git a/PEAR/Registry.php b/PEAR/Registry.php
2fd457
index 3a7bbb1..17de529 100644
2fd457
--- PEAR/Registry.php
2fd457
+++ PEAR/Registry.php
2fd457
@@ -132,23 +132,26 @@ class PEAR_Registry extends PEAR
2fd457
      * @access public
2fd457
      */
2fd457
     function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false,
2fd457
-                           $pecl_channel = false)
2fd457
+                           $pecl_channel = false, $pear_metadata_dir = '')
2fd457
     {
2fd457
         parent::PEAR();
2fd457
-        $this->setInstallDir($pear_install_dir);
2fd457
+        $this->setInstallDir($pear_install_dir, $pear_metadata_dir);
2fd457
         $this->_pearChannel = $pear_channel;
2fd457
         $this->_peclChannel = $pecl_channel;
2fd457
         $this->_config      = false;
2fd457
     }
2fd457
 
2fd457
-    function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR)
2fd457
+    function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR, $pear_metadata_dir = '')
2fd457
     {
2fd457
         $ds = DIRECTORY_SEPARATOR;
2fd457
         $this->install_dir = $pear_install_dir;
2fd457
-        $this->channelsdir = $pear_install_dir.$ds.'.channels';
2fd457
-        $this->statedir    = $pear_install_dir.$ds.'.registry';
2fd457
-        $this->filemap     = $pear_install_dir.$ds.'.filemap';
2fd457
-        $this->lockfile    = $pear_install_dir.$ds.'.lock';
2fd457
+        if (!$pear_metadata_dir) {
2fd457
+            $pear_metadata_dir = $pear_install_dir;
2fd457
+        }
2fd457
+        $this->channelsdir = $pear_metadata_dir.$ds.'.channels';
2fd457
+        $this->statedir    = $pear_metadata_dir.$ds.'.registry';
2fd457
+        $this->filemap     = $pear_metadata_dir.$ds.'.filemap';
2fd457
+        $this->lockfile    = $pear_metadata_dir.$ds.'.lock';
2fd457
     }
2fd457
 
2fd457
     function hasWriteAccess()
2fd457
@@ -181,7 +184,7 @@ class PEAR_Registry extends PEAR
2fd457
     {
2fd457
         $this->_config = &$config;
2fd457
         if ($resetInstallDir) {
2fd457
-            $this->setInstallDir($config->get('php_dir'));
2fd457
+            $this->setInstallDir($config->get('php_dir'), $config->get('metadata_dir'));
2fd457
         }
2fd457
     }
2fd457
 
2fd457
@@ -328,9 +331,9 @@ class PEAR_Registry extends PEAR
2fd457
                 $this->_dependencyDB = &PEAR_DependencyDB::singleton($this->_config);
2fd457
                 if (PEAR::isError($this->_dependencyDB)) {
2fd457
                     // attempt to recover by removing the dep db
2fd457
-                    if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') .
2fd457
+                    if (file_exists($this->_config->get('metadata_dir', null, 'pear.php.net') .
2fd457
                         DIRECTORY_SEPARATOR . '.depdb')) {
2fd457
-                        @unlink($this->_config->get('php_dir', null, 'pear.php.net') .
2fd457
+                        @unlink($this->_config->get('metadata_dir', null, 'pear.php.net') .
2fd457
                             DIRECTORY_SEPARATOR . '.depdb');
2fd457
                     }
2fd457
 
2fd457
@@ -2328,4 +2331,4 @@ class PEAR_Registry extends PEAR
2fd457
         }
2fd457
         return $ret;
2fd457
     }
2fd457
-}
2fd457
\ No newline at end of file
2fd457
+}