diff options
author | Remi Collet <fedora@famillecollet.com> | 2016-08-05 18:58:15 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2016-08-05 18:58:15 +0200 |
commit | 35a4d072c7b6ff0242911a5f8db19251a52f39cc (patch) | |
tree | d7c0a659e12bcafec84118cd105a3608c69ac181 | |
parent | c09c659844def14cf1602ccc847b0688f978ae69 (diff) |
php-pear: improve default configuration (avoid change in scriplet)
-rw-r--r-- | cleanup.php | 33 | ||||
-rw-r--r-- | php-pear.spec | 26 | ||||
-rw-r--r-- | strip.php | 35 |
3 files changed, 49 insertions, 45 deletions
diff --git a/cleanup.php b/cleanup.php new file mode 100644 index 0000000..9dde7c8 --- /dev/null +++ b/cleanup.php @@ -0,0 +1,33 @@ +<?php + +# +# Usage: php cleanup.php /path/to/pear.conf /usr/share +# +$file = $_SERVER['argv'][1]; +$data = $_SERVER['argv'][2]; + +# Keys to be removed if exists +$remove = [ + 'ext_dir', + 'http_proxy', +]; +# Keys to be added +$add = [ + '__channels' => [ + 'pecl.php.net' => [ + 'doc_dir' => "$data/doc/pecl", + 'test_dir' => "$data/tests/pecl", + ] + ] +]; + +$input = file_get_contents($file); +list($header, $config) = explode("\n", $input); +$config = unserialize($config); + +foreach ($remove as $key) unset($config[$key]); +$config = array_merge($config, $add); +$config = serialize($config); + +file_put_contents($file, "$header\n$config"); + diff --git a/php-pear.spec b/php-pear.spec index 12870ff..5c467c8 100644 --- a/php-pear.spec +++ b/php-pear.spec @@ -37,7 +37,7 @@ Summary: PHP Extension and Application Repository framework Name: %{?scl_prefix}php-pear Version: 1.10.1 -Release: 5%{?dist} +Release: 6%{?dist} Epoch: 1 # PEAR, PEAR_Manpages, Archive_Tar, XML_Util, Console_Getopt are BSD # Structures_Graph is LGPLv3+ @@ -47,7 +47,7 @@ URL: http://pear.php.net/package/PEAR Source0: http://download.pear.php.net/package/PEAR-%{version}%{?pearprever}.tgz # wget https://raw.githubusercontent.com/pear/pear-core/stable/install-pear.php Source1: install-pear.php -Source3: strip.php +Source3: cleanup.php Source10: pear.sh Source11: pecl.sh Source12: peardev.sh @@ -66,7 +66,7 @@ BuildRequires: %{?scl_prefix}php-cli BuildRequires: %{?scl_prefix}php-xml BuildRequires: gnupg # For pecl_xmldir macro -BuildRequires: php-devel +BuildRequires: %{?scl_prefix}php-devel %if %{with_tests} BuildRequires: %{_bindir}/phpunit %endif @@ -225,9 +225,9 @@ for exe in pear pecl peardev; do done # Sanitize the pear.conf -%{_bindir}/php %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/pear.conf ext_dir >new-pear.conf -%{_bindir}/php %{SOURCE3} new-pear.conf http_proxy > $RPM_BUILD_ROOT%{_sysconfdir}/pear.conf +%{_bindir}/php %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/pear.conf %{_datadir} +# Display configuration for debug %{_bindir}/php -r "print_r(unserialize(substr(file_get_contents('$RPM_BUILD_ROOT%{_sysconfdir}/pear.conf'),17)));" @@ -320,11 +320,7 @@ done %endif -%clean -rm -rf $RPM_BUILD_ROOT -rm new-pear.conf - - +%if 0%{?fedora} < 25 %pre # Manage relocation of metadata, before update to pear if [ -d %{peardir}/.registry -a ! -d %{metadir}/.registry ]; then @@ -371,6 +367,8 @@ if [ "$current" != "%{_datadir}/tests/pecl" ]; then test_dir %{_datadir}/tests/pecl \ system >/dev/null || : fi +%endif + %postun if [ $1 -eq 0 -a -d %{metadir}/.registry ] ; then @@ -378,6 +376,10 @@ if [ $1 -eq 0 -a -d %{metadir}/.registry ] ; then fi +%clean +rm -rf $RPM_BUILD_ROOT + + %files %defattr(-,root,root,-) %{peardir} @@ -420,6 +422,10 @@ fi %changelog +* Fri Aug 5 2016 Remi Collet <remi@fedoraproject.org> 1:1.10.1-6 +- improve default config, to avoid change in scriptlet +- remove unneeded scriplets for Fedora 25 + * Thu Jun 30 2016 Remi Collet <remi@fedoraproject.org> 1:1.10.1-5 - don't own test/doc directories for pecl packages (f24) - fix obsoletes diff --git a/strip.php b/strip.php deleted file mode 100644 index 5c5216b..0000000 --- a/strip.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -# -# strip.php /path/to/file key_name -# -# Takes a file as input and a string prefix; reads -# the file as a serialized data blob and removes a -# key with name key_name from the hash. -# Serializes again and writes output to stdout. -# - -$file = $_SERVER['argv'][1]; -$key = $_SERVER['argv'][2]; - -function remove_key($array, $name) { - if (array_key_exists($name, $array)) { - unset($array[$name]); - } - - return $array; -} - -$input = file_get_contents($file); - -# Special case for /etc/pear.conf. -if (strncmp($input, "#PEAR_Config 0.9\n", 17) == 0) { - echo substr($input, 0, 17); - $s = substr($input, 17); -} else { - $s = $input; -} - -echo serialize(remove_key(unserialize($s), $key)); - -?>
\ No newline at end of file |