# vim:syn=spec:ai # original macros.php macros %define __php_provides /usr/lib/rpm/php.prov %define __php_requires /usr/lib/rpm/php.req # pear install macros written by glen@pld-linux.org. # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada # # Usage: # %%pear_package_setup [-a #] [-n FMT] # # -a # - also unpack SOURCE#. for PEAR bootstrapping # -n FMT - create builddir with FMT, instead of default %%{_pearname}-%%{version} # -z - unpack pear package and let pear use package.xml (not tarball) for install. for PEAR bootstrapping # # unpack PEAR package to %%{_builddir}/FMT. package is extracted with already # destination hierarchy. you should copy the tree to buildroot after # patching/reorganizing with %%pear_package_install. # # additionally BUILDROOT is stripped from files and files are converted to UNIX # line endings. # # the pear install process output is recorded to install.log, you should put it # to %%doc for latter debug or just information. # # additionally additional-packages.txt is produced if it was detected that the # package has optional dependencies. the file format is suitable of displaying # in %%post of a package. you should put this file to %%doc. noautocompressdoc is # automatically added for this file. # records install.log and transforms PEAR names to PLD Linux rpm package names. %define __pear_install_log \ tee install.log \ # make post message of optional packages \ grep 'can optionally use' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,' > optional-packages.txt \ if [ -s optional-packages.txt ]; then \ awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \ else \ rm -f optional-packages.txt \ fi \ # undos sources \ find . -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \ # command invoking pear cli %define __pear /usr/bin/pear # the main macro. # using this macro will append optional-packages.txt to the nocompressdoc list # as it's displayed to user after package install. and adding additional gzip # dep is just waste ;) %define pear_package_setup(a:n:z) \ %setup -q -c -T -n %{-n*}%{!-n:%{_pearname}-%{version}}\ _D=%{_builddir}/%{-n*}%{!-n:%{_pearname}-%{version}} \ %{-z:tar zxf %{S:0}; %{-a:tar zxf %{S:%{-a*}};} _P=package2.xml; [ -f $_P ] || _P=package.xml; _N=%{!-n:%{_pearname}-%{version}}; mv $_P $_N; cd $_N} \ install -d ./%{php_pear_dir} \ %__pear \\\ -c pearrc \\\ -d doc_dir=/docs \\\ -d php_dir=%{php_pear_dir} \\\ -d bin_dir=%{_bindir} \\\ -d data_dir=%{php_pear_dir}/data \\\ -d test_dir=%{php_pear_dir}/tests \\\ install \\\ --packagingroot=${_D} \\\ --offline \\\ --nodeps \\\ %{-f:--force} \\\ %{!-z:%{S:%{-a*}%{!-a:0}}}%{-z:$_P} > .install.log || { c=$?; cat .install.log; exit $c; } \ %{-z:cd ..} \ cat %{-z:$_N/}.install.log | %__pear_install_log \ %{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \ %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \ %{nil} # copies exctracted PEAR package structure to buildroot. # also copies PEAR registry file. # please use this macro, for future extensions being possible. %define pear_package_install() \ cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \ find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \ # help the developer out a little: \ if [ -f _noautoreq ]; then \ echo "AutoReqdep detected:" \ echo "_noautoreq $(cat _noautoreq)" \ fi \ %{nil}