From d4b666e66f513c2f052fa91a943a766e8dbdcafa Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 19 Jul 2007 18:31:05 +0000 Subject: [PATCH] update to PEAR-1.6.1 update to Console_Getopt-1.2.3 new spec file using "install-pear.php" instead of "install-pear-nozlib.phar" --- .cvsignore | 9 +- install-pear.php | 210 +++++++++++++++++++++++++++++++++++++++++ pear-downloaddir.patch | 15 +++ pear-peclinstall.patch | 24 +++++ php-pear.spec | 104 ++++++++++++-------- sources | 5 +- 6 files changed, 323 insertions(+), 44 deletions(-) create mode 100644 install-pear.php create mode 100644 pear-downloaddir.patch create mode 100644 pear-peclinstall.patch diff --git a/.cvsignore b/.cvsignore index 75ee3de..fa7fd1b 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,6 +1,5 @@ +PEAR-1.6.1.tgz XML_RPC-1.5.1.tgz -pear-1.5.4 -*.src.rpm -noarch -clog -install-pear-nozlib-1.5.4.phar +Archive_Tar-1.3.2.tgz +Console_Getopt-1.2.3.tgz +Structures_Graph-1.0.2.tgz diff --git a/install-pear.php b/install-pear.php new file mode 100644 index 0000000..eb9bc23 --- /dev/null +++ b/install-pear.php @@ -0,0 +1,210 @@ +getLayers(); +foreach ($config_layers as $layer) { + if ($layer == 'default') continue; + $config->removeLayer($layer); +} +$keys = $config->getKeys(); +if ($debug) { + $config->set('verbose', 5, 'default'); +} else { + $config->set('verbose', 0, 'default'); +} +// PEAR executables +if (!empty($bin_dir)) { + $config->set('bin_dir', $bin_dir, 'default'); +} +// User supplied a dir prefix +if (!empty($with_dir)) { + $ds = DIRECTORY_SEPARATOR; + $config->set('php_dir', $with_dir, 'default'); + $config->set('doc_dir', $with_dir . $ds . 'doc', 'default'); + $config->set('data_dir', $with_dir . $ds . 'data', 'default'); + $config->set('test_dir', $with_dir . $ds . 'test', 'default'); + if (!is_writable($config->get('cache_dir'))) { + include_once 'System.php'; + $cdir = System::mktemp(array('-d', 'pear')); + if (PEAR::isError($cdir)) { + $ui->outputData("[PEAR] cannot make new temporary directory: " . $cdir); + die(1); + } + $oldcachedir = $config->get('cache_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); + foreach ($keys as $key) { + echo $key . ' ' . + $config->getPrompt($key) . ": " . $config->get($key, null, 'default') . "\n"; + } + if ($debug == 2) { // extreme debugging + exit; + } +} +// end print + +$php_dir = $config->get('php_dir'); +$options = array(); +$options['upgrade'] = true; +$install_root = getenv('INSTALL_ROOT'); +if (!empty($install_root)) { + $options['packagingroot'] = $install_root; + $reg = &new PEAR_Registry($options['packagingroot']); +} else { + $reg = $config->getRegistry('default'); +} + +$ui = PEAR_Frontend::singleton('PEAR_Frontend_CLI'); +if (PEAR::isError($ui)) { + die($ui->getMessage()); +} +$installer = new PEAR_Installer($ui); +$pkg = new PEAR_PackageFile($config, $debug); + +foreach ($install_files as $package => $instfile) { + $info = $pkg->fromAnyFile($instfile, PEAR_VALIDATE_INSTALLING); + if (PEAR::isError($info)) { + if (is_array($info->getUserInfo())) { + foreach ($info->getUserInfo() as $err) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err['message'])); + } + } + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage())); + continue; + } + $new_ver = $info->getVersion(); + $downloaderpackage = new PEAR_Downloader_Package($installer); + $err = $downloaderpackage->initialize($instfile); + if (PEAR::isError($err)) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); + continue; + } + if ($reg->packageExists($package)) { + $old_ver = $reg->packageInfo($package, 'version'); + if (version_compare($new_ver, $old_ver, 'gt')) { + $installer->setOptions($options); + $dp = array($downloaderpackage); + $installer->setDownloadedPackages($dp); + $err = $installer->install($downloaderpackage, $options); + if (PEAR::isError($err)) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); + continue; + } + $ui->outputData(sprintf("[PEAR] %-15s- upgraded: %s", $package, $new_ver)); + } else { + if ($force) { + $options['force'] = true; + $installer->setOptions($options); + $dp = array($downloaderpackage); + $installer->setDownloadedPackages($dp); + $err = $installer->install($downloaderpackage, $options); + if (PEAR::isError($err)) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); + continue; + } + $ui->outputData(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver)); + } else { + $ui->outputData(sprintf("[PEAR] %-15s- already installed: %s", $package, $old_ver)); + } + } + } else { + $options['nodeps'] = true; + $installer->setOptions($options); + $dp = array($downloaderpackage); + $installer->setDownloadedPackages($dp); + $err = $installer->install($downloaderpackage, $options); + if (PEAR::isError($err)) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); + continue; + } + $ui->outputData(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver)); + } + if ($package == 'PEAR') { + if (is_file($ufile = $config->getConfFile('user'))) { + $ui->outputData('Warning! a PEAR user config file already exists from ' . + 'a previous PEAR installation at ' . + "'$ufile'. You may probably want to remove it."); + } + $config->set('verbose', 1, 'default'); + if (isset($oldcachedir)) { + $config->set('cache_dir', $oldcachedir); + } + $data = array(); + foreach ($config->getKeys() as $key) { + $data[$key] = $config->get($key); + } + $cnf_file = $config->getConfFile('system'); + if (!empty($install_root)) { + $cnf_file = $install_root . DIRECTORY_SEPARATOR . $cnf_file; + } + $config->writeConfigFile($cnf_file, 'system', $data); + $ui->outputData('Wrote PEAR system config file at: ' . $cnf_file); + $ui->outputData('You may want to add: ' . $config->get('php_dir') . ' to your php.ini include_path'); + } +} +?> diff --git a/pear-downloaddir.patch b/pear-downloaddir.patch new file mode 100644 index 0000000..1ef342d --- /dev/null +++ b/pear-downloaddir.patch @@ -0,0 +1,15 @@ +To avoid error on when "system" download_dir is not writable for normal user. + +See : http://pear.php.net/bugs/bug.php?id=11517 + +--- /usr/share/pear/PEAR/Downloader.php.orig 2007-07-15 12:35:38.000000000 +0200 ++++ /usr/share/pear/PEAR/Downloader.php 2007-07-15 12:34:59.000000000 +0200 +@@ -679,7 +679,7 @@ + return $this->_downloadDir; + } + $downloaddir = $this->config->get('download_dir'); +- if (empty($downloaddir)) { ++ if (empty($downloaddir) || (is_dir($downloaddir) && !is_writable($downloaddir))) { + if (!class_exists('System')) { + require_once 'System.php'; + } diff --git a/pear-peclinstall.patch b/pear-peclinstall.patch new file mode 100644 index 0000000..a177a1b --- /dev/null +++ b/pear-peclinstall.patch @@ -0,0 +1,24 @@ +To Avoid warnings when using pecl (un)install command + +See : http://pear.php.net/bugs/bug.php?id=11420 + +--- /usr/share/pear/PEAR/Command/Install.php.orig 2007-06-24 13:22:19.000000000 +0200 ++++ /usr/share/pear/PEAR/Command/Install.php 2007-06-24 13:30:28.000000000 +0200 +@@ -700,7 +700,7 @@ + break; + } + } +- foreach ($binaries as $pinfo) { ++ if (isset($binaries)) foreach ($binaries as $pinfo) { + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + $ret = $this->enableExtension(array($pinfo[0]), $param->getPackageType()); + PEAR::staticPopErrorHandling(); +@@ -941,7 +941,7 @@ + break; + } + } +- foreach ($binaries as $pinfo) { ++ if (isset($binaries)) foreach ($binaries as $pinfo) { + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + $ret = $this->disableExtension(array($pinfo[0]), $pkg->getPackageType()); + PEAR::staticPopErrorHandling(); diff --git a/php-pear.spec b/php-pear.spec index 136c155..ae40513 100644 --- a/php-pear.spec +++ b/php-pear.spec @@ -2,6 +2,9 @@ %define peardir %{_datadir}/pear %define xmlrpcver 1.5.1 +%define getoptver 1.2.3 +%define arctarver 1.3.2 +%define structver 1.0.2 # Upstream only make the latest .phar available via the following URL, # no archive of each version of the installer archives exists: @@ -9,13 +12,15 @@ Summary: PHP Extension and Application Repository framework Name: php-pear -Version: 1.5.4 -Release: 4 +Version: 1.6.1 +Release: 1%{?dist} Epoch: 1 -License: The PHP License v3.0 +License: PHP License Group: Development/Languages URL: http://pear.php.net/package/PEAR -Source0: install-pear-nozlib-%{version}.phar +Source0: http://download.pear.php.net/package/PEAR-%{version}.tgz +# wget http://cvs.php.net/viewvc.cgi/pear-core/install-pear.php?revision=1.29 -O install-pear.php +Source1: install-pear.php Source2: relocate.php Source3: strip.php Source4: LICENSE @@ -24,13 +29,24 @@ Source11: pecl.sh Source12: peardev.sh Source13: macros.pear Source20: http://pear.php.net/get/XML_RPC-%{xmlrpcver}.tgz +Source21: http://pear.php.net/get/Archive_Tar-%{arctarver}.tgz +Source22: http://pear.php.net/get/Console_Getopt-%{getoptver}.tgz +Source23: http://pear.php.net/get/Structures_Graph-%{structver}.tgz + +# To Avoid warnings when using pecl (un)install command +# see http://pear.php.net/bugs/bug.php?id=11420 +Patch0: pear-peclinstall.patch +# To avoid error when "system" download_dir is not writable for normal user. +# see http://pear.php.net/bugs/bug.php?id=11517 +Patch1: pear-downloaddir.patch + BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: php-cli >= 5.1.0-1, gnupg -Provides: php-pear(Archive_Tar) = 1.3.2 -Provides: php-pear(Console_Getopt) = 1.2.1 +BuildRequires: php-cli >= 5.1.0-1, php-xml, gnupg +Provides: php-pear(Console_Getopt) = %{getoptver} +Provides: php-pear(Archive_Tar) = %{arctarver} Provides: php-pear(PEAR) = %{version} -Provides: php-pear(Structures_Graph) = 1.0.2 +Provides: php-pear(Structures_Graph) = %{structver} Provides: php-pear(XML_RPC) = %{xmlrpcver} Requires: php >= 5.1.0-1, php-cli @@ -39,7 +55,14 @@ PEAR is a framework and distribution system for reusable PHP components. This package contains the basic PEAR components. %prep -%setup -cTn pear-%{version} +%setup -cT + +# Create a usable PEAR directory (used by install-pear.php) +for archive in %{SOURCE0} %{SOURCE21} %{SOURCE22} %{SOURCE23} +do + tar xzf $archive --strip-components 1 +done + %build # This is an empty build section. @@ -47,9 +70,10 @@ components. This package contains the basic PEAR components. %install rm -rf $RPM_BUILD_ROOT -export PHP_PEAR_SYSCONF_DIR=`pwd` -export PHP_PEAR_SIG_KEYDIR=/etc/pearkeys -export PHP_PEAR_SIG_BIN=/usr/bin/gpg +export PHP_PEAR_SYSCONF_DIR=%{_sysconfdir} +export PHP_PEAR_SIG_KEYDIR=%{_sysconfdir}/pearkeys +export PHP_PEAR_SIG_BIN=%{_bindir}/gpg +export PHP_PEAR_INSTALL_DIR=%{peardir} # 1.4.11 tries to write to the cache directory during installation # so it's not possible to set a sane default via the environment. @@ -57,42 +81,40 @@ export PHP_PEAR_SIG_BIN=/usr/bin/gpg export PHP_PEAR_CACHE_DIR=${PWD}%{_localstatedir}/cache/php-pear export PHP_PEAR_TEMP_DIR=/var/tmp -%{_bindir}/php -n -dshort_open_tag=0 -dsafe_mode=0 \ - -derror_reporting=E_ALL -ddetect_unicode=0 \ - %{SOURCE0} -d $RPM_BUILD_ROOT%{peardir} \ - -b $RPM_BUILD_ROOT%{_bindir} \ - %{SOURCE20} - -# Replace /usr/bin/* with simple scripts: -for f in pecl pear peardev; do - install -m 755 $RPM_SOURCE_DIR/${f}.sh $RPM_BUILD_ROOT%{_bindir}/${f} -done - -install -d $RPM_BUILD_ROOT%{_sysconfdir} \ +install -d $RPM_BUILD_ROOT%{peardir} \ $RPM_BUILD_ROOT%{_localstatedir}/cache/php-pear \ $RPM_BUILD_ROOT%{peardir}/.pkgxml \ $RPM_BUILD_ROOT%{_sysconfdir}/rpm -# Relocate everything: -sed -si "s,$RPM_BUILD_ROOT,,g" \ - $RPM_BUILD_ROOT%{peardir}/*.php \ - $RPM_BUILD_ROOT%{peardir}/*/*.php \ - $RPM_BUILD_ROOT%{peardir}/*/*/*.php +export INSTALL_ROOT=$RPM_BUILD_ROOT + +%{_bindir}/php -n -dshort_open_tag=0 -dsafe_mode=0 \ + -derror_reporting=E_ALL -ddetect_unicode=0 \ + %{SOURCE1} -d %{peardir} \ + -b %{_bindir} \ + %{SOURCE0} %{SOURCE21} %{SOURCE22} %{SOURCE23} %{SOURCE20} + +# Replace /usr/bin/* with simple scripts: +install -m 755 %{SOURCE10} $RPM_BUILD_ROOT%{_bindir}/pear +install -m 755 %{SOURCE11} $RPM_BUILD_ROOT%{_bindir}/pecl +install -m 755 %{SOURCE12} $RPM_BUILD_ROOT%{_bindir}/peardev # Sanitize the pear.conf -%{_bindir}/php -n %{SOURCE2} pear.conf $RPM_BUILD_ROOT | +%{_bindir}/php -n %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/pear.conf $RPM_BUILD_ROOT | %{_bindir}/php -n %{SOURCE2} php://stdin $PWD > new-pear.conf %{_bindir}/php -n %{SOURCE3} new-pear.conf ext_dir > $RPM_BUILD_ROOT%{_sysconfdir}/pear.conf -for f in $RPM_BUILD_ROOT%{peardir}/.registry/*.reg; do - %{_bindir}/php -n %{SOURCE2} ${f} $RPM_BUILD_ROOT > ${f}.new - mv ${f}.new ${f} -done +install -m 644 -c %{SOURCE4} LICENSE -install -m 644 -c $RPM_SOURCE_DIR/LICENSE . +install -m 644 -c %{SOURCE13} \ + $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.pear -install -m 644 -c $RPM_SOURCE_DIR/macros.pear \ - $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.pear +cd $RPM_BUILD_ROOT%{peardir} +patch -p4 <%{PATCH0} +patch -p4 <%{PATCH1} + +# Why this file here ? +rm -rf $RPM_BUILD_ROOT/.depdb* $RPM_BUILD_ROOT/.lock $RPM_BUILD_ROOT/.channels $RPM_BUILD_ROOT/.filemap %check # Check that no bogus paths are left in the configuration, or in @@ -105,7 +127,7 @@ grep -rl $RPM_BUILD_ROOT $RPM_BUILD_ROOT && exit 1 %clean rm -rf $RPM_BUILD_ROOT -rm pear.conf +rm new-pear.conf %files %defattr(-,root,root,-) @@ -117,6 +139,12 @@ rm pear.conf %doc LICENSE %changelog +* Thu Jul 19 2007 Remi Collet 1:1.6.1-1 +- update to PEAR-1.6.1 and Console_Getopt-1.2.3 + +* Thu Jul 19 2007 Remi Collet 1:1.5.4-5 +- new SPEC using install-pear.php instead of install-pear-nozlib-1.5.4.phar + * Mon Jul 16 2007 Remi Collet 1:1.5.4-4 - update macros.pear (without define) diff --git a/sources b/sources index 287157d..f57045f 100644 --- a/sources +++ b/sources @@ -1,2 +1,5 @@ +1476f0ec3917d68e3d7af1346a9a7b89 PEAR-1.6.1.tgz 1b516162ad65971b5fd04a7c279627ec XML_RPC-1.5.1.tgz -93a4b2d66d2b950fbc4dcbc864c6a8b8 install-pear-nozlib-1.5.4.phar +17d49e837b64df4e8f9124f829b22cd1 Archive_Tar-1.3.2.tgz +d7618327f9302a7191893768982de823 Console_Getopt-1.2.3.tgz +2664e2d024048f982e12fad4d1bfbb87 Structures_Graph-1.0.2.tgz