summaryrefslogtreecommitdiffstats
path: root/php-pear-1.10-metadata.patch
blob: 00b53e04fe1712ca0d8282d0c4091cb43c0efe76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
From e523edb6f2be7c5e672b3537e295d5007d107af8 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sun, 26 Jul 2015 08:22:52 +0200
Subject: [PATCH 1/5] add "metadata_dir" configuration option

---
 PEAR/Command/Install.php |  8 +++++++-
 PEAR/Config.php          | 34 +++++++++++++++++++++++++++++-----
 PEAR/DependencyDB.php    |  9 ++++++---
 PEAR/Installer.php       | 25 +++++++++++++++----------
 PEAR/Registry.php        | 23 +++++++++++++----------
 5 files changed, 70 insertions(+), 29 deletions(-)

diff --git a/PEAR/Command/Install.php b/PEAR/Command/Install.php
index 88c5284..87f8f17 100644
--- a/PEAR/Command/Install.php
+++ b/PEAR/Command/Install.php
@@ -555,7 +555,13 @@ function doInstall($command, $options, $params)
             $packrootphp_dir = $this->installer->_prependPath(
                 $this->config->get('php_dir', null, 'pear.php.net'),
                 $options['packagingroot']);
-            $instreg = new PEAR_Registry($packrootphp_dir); // other instreg!
+            $metadata_dir = $this->config->get('metadata_dir', null, 'pear.php.net');
+            if ($metadata_dir) {
+                $metadata_dir = $this->installer->_prependPath(
+                    $metadata_dir,
+                    $options['packagingroot']);
+            }
+            $instreg = new PEAR_Registry($packrootphp_dir, false, false, $metadata_dir); // other instreg!
 
             if ($this->config->get('verbose') > 2) {
                 $this->ui->outputData('using package root: ' . $options['packagingroot']);
diff --git a/PEAR/Config.php b/PEAR/Config.php
index cd2bb91..36ad988 100644
--- a/PEAR/Config.php
+++ b/PEAR/Config.php
@@ -86,6 +86,13 @@
     }
 }
 
+// Default for metadata_dir
+if (getenv('PHP_PEAR_METADATA_DIR')) {
+    define('PEAR_CONFIG_DEFAULT_METADATA_DIR', getenv('PHP_PEAR_METADATA_DIR'));
+} else {
+    define('PEAR_CONFIG_DEFAULT_METADATA_DIR', '');
+}
+
 // Default for ext_dir
 if (getenv('PHP_PEAR_EXTENSION_DIR')) {
     define('PEAR_CONFIG_DEFAULT_EXT_DIR', getenv('PHP_PEAR_EXTENSION_DIR'));
@@ -397,6 +404,13 @@ class PEAR_Config extends PEAR
             'prompt' => 'PEAR directory',
             'group' => 'File Locations',
             ),
+        'metadata_dir' => array(
+            'type' => 'directory',
+            'default' => PEAR_CONFIG_DEFAULT_METADATA_DIR,
+            'doc' => 'directory where metadata files are installed (registry, filemap, channels, ...)',
+            'prompt' => 'PEAR metadata directory',
+            'group' => 'File Locations',
+            ),
         'ext_dir' => array(
             'type' => 'directory',
             'default' => PEAR_CONFIG_DEFAULT_EXT_DIR,
@@ -646,7 +660,9 @@ function __construct($user_file = '', $system_file = '', $ftp_file = false,
             $this->configuration['default'][$key] = $info['default'];
         }
 
-        $this->_registry['default'] = new PEAR_Registry($this->configuration['default']['php_dir']);
+        $this->_registry['default'] = new PEAR_Registry(
+            $this->configuration['default']['php_dir'], false, false,
+            $this->configuration['default']['metadata_dir']);
         $this->_registry['default']->setConfig($this, false);
         $this->_regInitialized['default'] = false;
         //$GLOBALS['_PEAR_Config_instance'] = &$this;
@@ -750,7 +766,9 @@ function readConfigFile($file = null, $layer = 'user', $strict = true)
         $this->configuration[$layer] = $data;
         $this->_setupChannels();
         if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
-            $this->_registry[$layer] = new PEAR_Registry($phpdir);
+            $this->_registry[$layer] = new PEAR_Registry(
+                $phpdir, false, false,
+                $this->get('metadata_dir', $layer, 'pear.php.net'));
             $this->_registry[$layer]->setConfig($this, false);
             $this->_regInitialized[$layer] = false;
         } else {
@@ -907,7 +925,9 @@ function mergeConfigFile($file, $override = true, $layer = 'user', $strict = tru
 
         $this->_setupChannels();
         if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
-            $this->_registry[$layer] = new PEAR_Registry($phpdir);
+            $this->_registry[$layer] = new PEAR_Registry(
+                $phpdir, false, false,
+                $this->get('metadata_dir', $layer, 'pear.php.net'));
             $this->_registry[$layer]->setConfig($this, false);
             $this->_regInitialized[$layer] = false;
         } else {
@@ -1595,7 +1615,9 @@ function _lazyChannelSetup($uselayer = false)
 
                 if (!is_object($this->_registry[$layer])) {
                     if ($phpdir = $this->get('php_dir', $layer, 'pear.php.net')) {
-                        $this->_registry[$layer] = new PEAR_Registry($phpdir);
+                        $this->_registry[$layer] = new PEAR_Registry(
+                            $phpdir, false, false,
+                            $this->get('metadata_dir', $layer, 'pear.php.net'));
                         $this->_registry[$layer]->setConfig($this, false);
                         $this->_regInitialized[$layer] = false;
                     } else {
@@ -2079,7 +2101,9 @@ function setInstallRoot($root)
                     continue;
                 }
                 $this->_registry[$layer] =
-                    new PEAR_Registry($this->get('php_dir', $layer, 'pear.php.net'));
+                    new PEAR_Registry(
+                        $this->get('php_dir', $layer, 'pear.php.net'), false, false,
+                        $this->get('metadata_dir', $layer, 'pear.php.net'));
                 $this->_registry[$layer]->setConfig($this, false);
                 $this->_regInitialized[$layer] = false;
             }
diff --git a/PEAR/DependencyDB.php b/PEAR/DependencyDB.php
index 90731e3..4f633ff 100644
--- a/PEAR/DependencyDB.php
+++ b/PEAR/DependencyDB.php
@@ -120,8 +120,11 @@ function setConfig(&$config, $depdb = false)
 
         $this->_registry = &$this->_config->getRegistry();
         if (!$depdb) {
-            $this->_depdb = $this->_config->get('php_dir', null, 'pear.php.net') .
-                DIRECTORY_SEPARATOR . '.depdb';
+            $dir = $this->_config->get('metadata_dir', null, 'pear.php.net');
+            if (!$dir) {
+                $dir = $this->_config->get('php_dir', null, 'pear.php.net');
+            }
+            $this->_depdb =  $dir . DIRECTORY_SEPARATOR . '.depdb';
         } else {
             $this->_depdb = $depdb;
         }
@@ -758,4 +761,4 @@ function _registerDep(&$data, &$pkg, $dep, $type, $group = false)
             );
         }
     }
-}
\ No newline at end of file
+}
diff --git a/PEAR/Installer.php b/PEAR/Installer.php
index 5bd7b58..c28167b 100644
--- a/PEAR/Installer.php
+++ b/PEAR/Installer.php
@@ -1128,15 +1128,6 @@ function install($pkgfile, $options = array())
 
         $pkgname = $pkg->getName();
         $channel = $pkg->getChannel();
-        if (isset($this->_options['packagingroot'])) {
-            $regdir = $this->_prependPath(
-                $this->config->get('php_dir', null, 'pear.php.net'),
-                $this->_options['packagingroot']);
-
-            $packrootphp_dir = $this->_prependPath(
-                $this->config->get('php_dir', null, $channel),
-                $this->_options['packagingroot']);
-        }
 
         if (isset($options['installroot'])) {
             $this->config->setInstallRoot($options['installroot']);
@@ -1148,7 +1139,21 @@ function install($pkgfile, $options = array())
             $this->config->setInstallRoot(false);
             $this->_registry = &$this->config->getRegistry();
             if (isset($this->_options['packagingroot'])) {
-                $installregistry = new PEAR_Registry($regdir);
+                $regdir = $this->_prependPath(
+                    $this->config->get('php_dir', null, 'pear.php.net'),
+                    $this->_options['packagingroot']);
+
+                $metadata_dir = $this->config->get('metadata_dir', null, 'pear.php.net');
+                if ($metadata_dir) {
+                    $metadata_dir = $this->_prependPath(
+                        $metadata_dir,
+                        $this->_options['packagingroot']);
+                }
+                $packrootphp_dir = $this->_prependPath(
+                    $this->config->get('php_dir', null, $channel),
+                    $this->_options['packagingroot']);
+
+                $installregistry = new PEAR_Registry($regdir, false, false, $metadata_dir);
                 if (!$installregistry->channelExists($channel, true)) {
                     // we need to fake a channel-discover of this channel
                     $chanobj = $this->_registry->getChannel($channel, true);
diff --git a/PEAR/Registry.php b/PEAR/Registry.php
index 8bad666..6103907 100644
--- a/PEAR/Registry.php
+++ b/PEAR/Registry.php
@@ -131,23 +131,26 @@ class PEAR_Registry extends PEAR
      * @access public
      */
     function __construct($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false,
-                           $pecl_channel = false)
+                           $pecl_channel = false, $pear_metadata_dir = '')
     {
         parent::__construct();
-        $this->setInstallDir($pear_install_dir);
+        $this->setInstallDir($pear_install_dir, $pear_metadata_dir);
         $this->_pearChannel = $pear_channel;
         $this->_peclChannel = $pecl_channel;
         $this->_config      = false;
     }
 
-    function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR)
+    function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR, $pear_metadata_dir = '')
     {
         $ds = DIRECTORY_SEPARATOR;
         $this->install_dir = $pear_install_dir;
-        $this->channelsdir = $pear_install_dir.$ds.'.channels';
-        $this->statedir    = $pear_install_dir.$ds.'.registry';
-        $this->filemap     = $pear_install_dir.$ds.'.filemap';
-        $this->lockfile    = $pear_install_dir.$ds.'.lock';
+        if (!$pear_metadata_dir) {
+            $pear_metadata_dir = $pear_install_dir;
+        }
+        $this->channelsdir = $pear_metadata_dir.$ds.'.channels';
+        $this->statedir    = $pear_metadata_dir.$ds.'.registry';
+        $this->filemap     = $pear_metadata_dir.$ds.'.filemap';
+        $this->lockfile    = $pear_metadata_dir.$ds.'.lock';
     }
 
     function hasWriteAccess()
@@ -180,7 +183,7 @@ function setConfig(&$config, $resetInstallDir = true)
     {
         $this->_config = &$config;
         if ($resetInstallDir) {
-            $this->setInstallDir($config->get('php_dir'));
+            $this->setInstallDir($config->get('php_dir'), $config->get('metadata_dir'));
         }
     }
 
@@ -327,9 +330,9 @@ function _initializeDepDB()
                 $this->_dependencyDB = &PEAR_DependencyDB::singleton($this->_config);
                 if (PEAR::isError($this->_dependencyDB)) {
                     // attempt to recover by removing the dep db
-                    if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') .
+                    if (file_exists($this->_config->get('metadata_dir', null, 'pear.php.net') .
                         DIRECTORY_SEPARATOR . '.depdb')) {
-                        @unlink($this->_config->get('php_dir', null, 'pear.php.net') .
+                        @unlink($this->_config->get('metadata_dir', null, 'pear.php.net') .
                             DIRECTORY_SEPARATOR . '.depdb');
                     }
 

From 75856858b1a66f4e1c3c3f6cff9c6698d2967601 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sun, 26 Jul 2015 09:04:20 +0200
Subject: [PATCH 3/5] move metadata_dir to "File Locations (Advanced)"

---
 PEAR/Config.php | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/PEAR/Config.php b/PEAR/Config.php
index 36ad988..edb594f 100644
--- a/PEAR/Config.php
+++ b/PEAR/Config.php
@@ -404,13 +404,6 @@ class PEAR_Config extends PEAR
             'prompt' => 'PEAR directory',
             'group' => 'File Locations',
             ),
-        'metadata_dir' => array(
-            'type' => 'directory',
-            'default' => PEAR_CONFIG_DEFAULT_METADATA_DIR,
-            'doc' => 'directory where metadata files are installed (registry, filemap, channels, ...)',
-            'prompt' => 'PEAR metadata directory',
-            'group' => 'File Locations',
-            ),
         'ext_dir' => array(
             'type' => 'directory',
             'default' => PEAR_CONFIG_DEFAULT_EXT_DIR,
@@ -509,6 +502,14 @@ class PEAR_Config extends PEAR
             'prompt' => 'php.ini location',
             'group' => 'File Locations (Advanced)',
             ),
+        'metadata_dir' => array(
+            'type' => 'directory',
+            'default' => PEAR_CONFIG_DEFAULT_METADATA_DIR,
+            'doc' => 'directory where metadata files are installed (registry, filemap, channels, ...)',
+            'prompt' => 'PEAR metadata directory',
+            'group' => 'File Locations',
+            'group' => 'File Locations (Advanced)',
+            ),
         // Maintainers
         'username' => array(
             'type' => 'string',

From b81ca684ac60f62173a2958e7db06f26002fff2d Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sun, 26 Jul 2015 09:05:04 +0200
Subject: [PATCH 4/5] cleanup

---
 PEAR/Config.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/PEAR/Config.php b/PEAR/Config.php
index edb594f..0c4c8e4 100644
--- a/PEAR/Config.php
+++ b/PEAR/Config.php
@@ -507,7 +507,6 @@ class PEAR_Config extends PEAR
             'default' => PEAR_CONFIG_DEFAULT_METADATA_DIR,
             'doc' => 'directory where metadata files are installed (registry, filemap, channels, ...)',
             'prompt' => 'PEAR metadata directory',
-            'group' => 'File Locations',
             'group' => 'File Locations (Advanced)',
             ),
         // Maintainers

From d862eea2fd1f8895f51e00b4eaea0bace0899fc5 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sun, 26 Jul 2015 10:20:00 +0200
Subject: [PATCH 5/5] ignore already installed (in base system) when packaging
 root

---
 PEAR/Downloader/Package.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PEAR/Downloader/Package.php b/PEAR/Downloader/Package.php
index 5b2ce14..29592dc 100644
--- a/PEAR/Downloader/Package.php
+++ b/PEAR/Downloader/Package.php
@@ -413,7 +413,7 @@ public static function removeInstalled(&$params)
                 if ($param->_installRegistry->packageExists($package, $channel)) {
                     $packageVersion = $param->_installRegistry->packageInfo($package, 'version', $channel);
                     if (version_compare($packageVersion, $param->getVersion(), '==')) {
-                        if (!isset($options['force'])) {
+                        if (!isset($options['force']) && !isset($options['packagingroot'])) {
                             $info = $param->getParsedPackage();
                             unset($info['version']);
                             unset($info['state']);
From e484e87b800183d680b6830f23c8bef48d1b6ede Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Thu, 30 Jul 2015 13:37:55 +0200
Subject: [PATCH] skip check (in base) when packagingroot used (different tree)

---
 PEAR/Downloader/Package.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PEAR/Downloader/Package.php b/PEAR/Downloader/Package.php
index 29592dc..70ea8c3 100644
--- a/PEAR/Downloader/Package.php
+++ b/PEAR/Downloader/Package.php
@@ -425,7 +425,7 @@ public static function removeInstalled(&$params)
                             $params[$i] = false;
                         }
                     } elseif (!isset($options['force']) && !isset($options['upgrade']) &&
-                          !isset($options['soft'])) {
+                          !isset($options['soft']) && !isset($options['packagingroot'])) {
                         $info = $param->getParsedPackage();
                         $param->_downloader->log(1, 'Skipping package "' .
                             $param->getShortName() .