move metadata to /var/lib/pear

This commit is contained in:
Remi Collet 2012-10-24 08:45:38 +02:00
parent a10ce1f7f2
commit 0b521dc095
4 changed files with 286 additions and 12 deletions

View File

@ -72,6 +72,9 @@ for ($i = 0; $i < sizeof($argv); $i++) {
} elseif ($arg == '-o' || $arg == '--download') {
$download_dir = $argv[$i+1];
$i++;
} elseif ($arg == '-m' || $arg == '--metadata') {
$metadata_dir = $argv[$i+1];
$i++;
} elseif ($arg == '-t' || $arg == '--temp') {
$temp_dir = $argv[$i+1];
$i++;
@ -159,6 +162,10 @@ if (!empty($test_dir)) {
if (!empty($with_dir)) {
$ds = DIRECTORY_SEPARATOR;
$config->set('php_dir', $with_dir, 'default');
// Metadata
if (!empty($metadata_dir)) {
$config->set('metadata_dir', $metadata_dir, 'default');
}
if (empty($doc_dir)) {
$config->set('doc_dir', $with_dir . $ds . 'doc', 'default');
}
@ -230,7 +237,7 @@ $options['upgrade'] = true;
$install_root = getenv('INSTALL_ROOT');
if (!empty($install_root)) {
$options['packagingroot'] = $install_root;
$reg = &new PEAR_Registry($options['packagingroot']);
$reg = &new PEAR_Registry($options['packagingroot'], false, false, $metadata_dir);
} else {
$reg = $config->getRegistry('default');
}

View File

@ -13,6 +13,7 @@
%pear_datadir %(%{__pear} config-get data_dir 2> /dev/null || echo undefined)
%pear_cfgdir %(%{__pear} config-get cfg_dir 2> /dev/null || echo undefined)
%pear_wwwdir %(%{__pear} config-get www_dir 2> /dev/null || echo undefined)
%pear_metadir %(%{__pear} config-get metadata_dir 2> /dev/null || echo undefined)
#
# Define PECL directories used in php-pecl-* spec files:

244
php-pear-metadata.patch Normal file
View File

@ -0,0 +1,244 @@
diff -up PEAR/Command/Install.php.metadata PEAR/Command/Install.php
--- PEAR/Command/Install.php.metadata 2011-07-07 00:11:24.000000000 +0200
+++ PEAR/Command/Install.php 2012-09-26 16:02:29.829393773 +0200
@@ -556,7 +556,13 @@ Run post-installation scripts in package
$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 -up PEAR/Config.php.metadata PEAR/Config.php
--- PEAR/Config.php.metadata 2011-07-07 00:11:24.000000000 +0200
+++ PEAR/Config.php 2012-09-26 16:02:29.831393779 +0200
@@ -87,6 +87,13 @@ if (getenv('PHP_PEAR_INSTALL_DIR')) {
}
}
+// 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'));
@@ -398,6 +405,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,
@@ -647,7 +661,9 @@ class PEAR_Config extends PEAR
$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;
@@ -754,7 +770,9 @@ class PEAR_Config extends PEAR
$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 {
@@ -911,7 +929,9 @@ class PEAR_Config extends PEAR
$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 {
@@ -1604,7 +1624,9 @@ class PEAR_Config extends PEAR
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 {
@@ -2087,8 +2109,9 @@ class PEAR_Config extends PEAR
if ($layer == 'ftp' || !isset($this->_registry[$layer])) {
continue;
}
- $this->_registry[$layer] =
- &new PEAR_Registry($this->get('php_dir', $layer, 'pear.php.net'));
+ $this->_registry[$layer] = &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 -up PEAR/DependencyDB.php.metadata PEAR/DependencyDB.php
--- PEAR/DependencyDB.php.metadata 2011-07-07 00:11:24.000000000 +0200
+++ PEAR/DependencyDB.php 2012-09-26 16:02:29.832393782 +0200
@@ -122,8 +122,11 @@ class PEAR_DependencyDB
$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;
}
@@ -766,4 +769,4 @@ class PEAR_DependencyDB
);
}
}
-}
\ Pas de fin de ligne à la fin du fichier
+}
diff -up PEAR/Installer.php.metadata PEAR/Installer.php
--- PEAR/Installer.php.metadata 2011-07-07 00:11:24.000000000 +0200
+++ PEAR/Installer.php 2012-09-26 16:03:15.079556967 +0200
@@ -1162,15 +1162,6 @@ class PEAR_Installer extends PEAR_Downlo
$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']);
@@ -1182,7 +1173,21 @@ class PEAR_Installer extends PEAR_Downlo
$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);
@@ -1820,4 +1825,4 @@ class PEAR_Installer extends PEAR_Downlo
}
// }}}
-}
\ Pas de fin de ligne à la fin du fichier
+}
diff --git a/PEAR/Registry.php b/PEAR/Registry.php
index 3a7bbb1..17de529 100644
--- PEAR/Registry.php
+++ PEAR/Registry.php
@@ -132,23 +132,26 @@ class PEAR_Registry extends PEAR
* @access public
*/
function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false,
- $pecl_channel = false)
+ $pecl_channel = false, $pear_metadata_dir = '')
{
parent::PEAR();
- $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()
@@ -181,7 +184,7 @@ class PEAR_Registry extends PEAR
{
$this->_config = &$config;
if ($resetInstallDir) {
- $this->setInstallDir($config->get('php_dir'));
+ $this->setInstallDir($config->get('php_dir'), $config->get('metadata_dir'));
}
}
@@ -328,9 +331,9 @@ class PEAR_Registry extends PEAR
$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');
}
@@ -2328,4 +2331,4 @@ class PEAR_Registry extends PEAR
}
return $ret;
}
-}
\ No newline at end of file
+}

View File

@ -1,4 +1,5 @@
%global peardir %{_datadir}/pear
%global metadir %{_localstatedir}/lib/pear
%global getoptver 1.3.1
%global arctarver 1.3.10
@ -14,7 +15,7 @@
Summary: PHP Extension and Application Repository framework
Name: php-pear
Version: 1.9.4
Release: 12%{?dist}
Release: 13%{?dist}
Epoch: 1
# PEAR, Archive_Tar, XML_Util are BSD
# Console_Getopt is PHP
@ -37,6 +38,8 @@ Source24: http://pear.php.net/get/XML_Util-%{xmlutil}.tgz
# From RHEL: ignore REST cache creation failures as non-root user (#747361)
# TODO See https://github.com/pear/pear-core/commit/dfef86e05211d2abc7870209d69064d448ef53b3#PEAR/REST.php
Patch0: php-pear-1.9.4-restcache.patch
# Relocate Metadata
Patch1: php-pear-metadata.patch
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -74,9 +77,10 @@ do
[ -f package2.xml ] && mv package2.xml ${file%%-*}.xml \
|| mv package.xml ${file%%-*}.xml
done
cp %{SOURCE1} .
# apply patches on used PEAR during install
# -- no patch
%patch1 -p0 -b .metadata
%build
# This is an empty build section.
@ -106,7 +110,8 @@ export INSTALL_ROOT=$RPM_BUILD_ROOT
%{_bindir}/php -n -dmemory_limit=32M -dshort_open_tag=0 -dsafe_mode=0 \
-derror_reporting=E_ALL -ddetect_unicode=0 \
%{SOURCE1} --dir %{peardir} \
install-pear.php --force \
--dir %{peardir} \
--cache %{_localstatedir}/cache/php-pear \
--config %{_sysconfdir}/pear \
--bin %{_bindir} \
@ -114,6 +119,7 @@ export INSTALL_ROOT=$RPM_BUILD_ROOT
--doc %{_docdir}/pear \
--test %{_datadir}/tests/pear \
--data %{_datadir}/pear-data \
--metadata %{metadir} \
%{SOURCE0} %{SOURCE21} %{SOURCE22} %{SOURCE23} %{SOURCE24}
# Replace /usr/bin/* with simple scripts:
@ -136,6 +142,7 @@ pushd $RPM_BUILD_ROOT%{peardir}
pushd PEAR
%__patch -s --no-backup --fuzz 0 -p0 < %{PATCH0}
popd
%__patch -s --no-backup --fuzz 0 -p0 < %{PATCH1}
popd
# Why this file here ?
@ -177,6 +184,14 @@ rm -rf $RPM_BUILD_ROOT
rm new-pear.conf
%pre
# Manage relocation of metadata, before update to pear
if [ -d %{peardir}/.registry -a ! -d %{metadir}/.registry ]; then
mkdir -p %{metadir}
mv -f %{peardir}/.??* %{metadir}
fi
%post
# force new value as pear.conf is (noreplace)
%{_bindir}/pear config-set \
@ -187,6 +202,10 @@ rm new-pear.conf
data_dir %{_datadir}/pear-data \
system >/dev/null || :
%{_bindir}/pear config-set \
metadata_dir %{metadir} \
system >/dev/null || :
%triggerpostun -- php-pear-XML-Util
# re-register extension unregistered during postun of obsoleted php-pear-XML-Util
@ -197,6 +216,7 @@ rm new-pear.conf
%files
%defattr(-,root,root,-)
%{peardir}
%{metadir}
%{_bindir}/*
%config(noreplace) %{_sysconfdir}/pear.conf
%config %{_sysconfdir}/rpm/macros.pear
@ -209,10 +229,12 @@ rm new-pear.conf
%dir %{_datadir}/tests
%{_datadir}/tests/pear
%{_datadir}/pear-data
%{_localstatedir}/lib/pear
%changelog
* Wed Sep 26 2012 Remi Collet <remi@fedoraproject.org> 1:1.9.4-13
- move metadata to /var/lib/pear
* Wed Sep 26 2012 Remi Collet <remi@fedoraproject.org> 1:1.9.4-12
- drop relocate stuff, no more needed