X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=rpm.macros;h=1996cee5e74eddcd56db414b64fdc17fd390e437;hb=a4b4c90f390694b9b593cd147f351bfcef5447f0;hp=988412fa6104450c1b79eea3f9bef0e9b8b48038;hpb=ed644e79ab29babd44305aa0dce93eed675ab214;p=packages%2Frpm-build-macros.git diff --git a/rpm.macros b/rpm.macros index 988412f..1996cee 100644 --- a/rpm.macros +++ b/rpm.macros @@ -7,6 +7,7 @@ %epoch 0 %x8664 x86_64 amd64 ia32e +%arm armv3l armv4b armv4l armv5teb armv5tel # kernel compiler %kgcc %{__cc} @@ -245,6 +246,8 @@ CFLAGS="%{rpmcflags}" \ CXXFLAGS="%{rpmcxxflags}" \ LDFLAGS="%{rpmldflags}" \ %{__cmake} \ +-DCMAKE_INSTALL_PREFIX=%{_prefix} \ +-DCMAKE_BUILD_TYPE=%{!?debug:Release}%{?debug:Debug} \ } %scons { \ @@ -350,7 +353,7 @@ CXXFLAGS="%{rpmcxxflags}" \ %{nil} # Location of autoconf macros -%_aclocaldir %{expand:%%global _aclocaldir %(aclocal --print-ac-dir || echo ERROR)}%_aclocaldir +%_aclocaldir %{expand:%%global _aclocaldir %(aclocal --print-ac-dir 2>/dev/null || echo ERROR)}%_aclocaldir # Location of omf files %_omf_dest_dir %{expand:%%global _omf_dest_dir %(scrollkeeper-config --omfdir || echo ERROR)}%_omf_dest_dir @@ -400,6 +403,15 @@ CXXFLAGS="%{rpmcxxflags}" \ # If non-empty "debug" macro defined, add "dbg" suffix to release number %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm +# Bootstrap release macros. +# Usage: +# %bcond_with bootstrap +# Release: %{bootstrap_release 1} +# +# Package will have release 1 if built normally, +# and release 0.zzz.bootstrap if built with bootstrap +%bootstrap_release() %{!?with_bootstrap:%{1}%{?2:.%{2}}}%{?with_bootstrap:%{!?2:%(expr %{1} - 1)}%{?2:%{1}.%(expr %{2} - 1)}.zzz.bootstrap} + # -n drm to generate kernel%{_alt_kernel}-drm dependency %releq_kernel(n:) %{expand:%%global releq_kernel %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}} = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel %releq_kernel_up(n:) %{expand:%%global releq_kernel_up %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}}-up = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_up @@ -417,6 +429,11 @@ CXXFLAGS="%{rpmcxxflags}" \ # Requires: name = version (version based on querying package %2) %requires_eq_to(r) %{!?2:ERROR}%{?3:ERROR}%{?2:%{!?3:%(if ! LC_ALL=C rpm -q --qf 'Requires: %1 = %|E?{%{E}:}|%{V}%{?-r:-%{R}}\\n' %2 | grep '^Requires:'; then echo "BuildRequires: %2"; fi)}} +# Requires: name >= version +%requires_ge() %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_ge_to %1 %1}}} +# Requires: name >= version (version based on querying package %2) +%requires_ge_to(r) %{!?2:ERROR}%{?3:ERROR}%{?2:%{!?3:%(if ! LC_ALL=C rpm -q --qf 'Requires: %1 >= %|E?{%{E}:}|%{V}%{?-r:-%{R}}\\n' %2 | grep '^Requires:'; then echo "BuildRequires: %2"; fi)}} + %apache_modules_api %{expand:%%global apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)}%apache_modules_api # kernel version-release handling @@ -987,7 +1004,7 @@ fi; \ %xmms_effect_plugindir %{expand:%%global xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null || echo ERROR)}%xmms_effect_plugindir %xmms_general_plugindir %{expand:%%global xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null || echo ERROR)}%xmms_general_plugindir -%_target_base_arch %{expand:%%global _target_base_arch %(echo %{_target_cpu} | sed 's/i.86/i386/;s/athlon/i386/;s/pentium./i386/;s/amd64/x86_64/;s/ia32e/x86_64/;s/sparcv./sparc/')}%_target_base_arch +%_target_base_arch %{expand:%%global _target_base_arch %(echo %{_target_cpu} | sed 's/i.86/i386/;s/athlon/i386/;s/pentium./i386/;s/amd64/x86_64/;s/ia32e/x86_64/;s/sparcv./sparc/;s/arm.*/arm/')}%_target_base_arch # user/group checking macros # @@ -1342,6 +1359,7 @@ echo -e "\\n" >> %{_mavendepmapdir}/maven2-depmap.xml # -z - unpack pear package and let pear use package.xml (not tarball) for install. for PEAR bootstrapping # -D - pass -D to %setup (so the build dir is not removed) # -c - register channel from local channel.xml file +# -d - pass -d arg to pearcmd # # unpack PEAR package to %%{_builddir}/FMT. package is extracted with already # destination hierarchy. you should copy the tree to buildroot after @@ -1363,7 +1381,7 @@ echo -e "\\n" >> %{_mavendepmapdir}/maven2-depmap.xml %__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-,;s,^pear/,php-pear-,;s,^channel://.*/,,' > optional-packages.txt \ +grep -E 'can optionally use|Optional feature' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,;s,^pear/,php-pear-,;s,^channel://.*/,,' > 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 \ @@ -1371,10 +1389,11 @@ else \ fi \ %{nil} -# command invoking pear cli -%__pear /usr/bin/pear +# Command invoking PEAR CLI +# Same as /usr/bin/pear, except we force GMT timezone +%__pear %__php -doutput_buffering=1 -dopen_basedir="" -dmemory_limit=-1 -ddate.timezone=GMT %{php_pear_dir}/pearcmd.php -%pear_install(a:n:zD) \ +%pear_install(a:d:n:zD) \ %__pear \\\ -c %{builddir}/pearrc \\\ -d doc_dir=/docs \\\ @@ -1383,6 +1402,7 @@ fi \ -d bin_dir=%{_bindir} \\\ -d data_dir=%{php_pear_dir}/data \\\ -d test_dir=%{php_pear_dir}/tests \\\ + %{-d:%(echo "%{-d*}" | awk 'BEGIN{RS=","}{printf("-d %%s \\\\\\n\\t", $1)}')} \\\ install \\\ --packagingroot=%{builddir} \\\ --offline \\\ @@ -1396,15 +1416,16 @@ fi \ # 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 ;) -%pear_package_setup(a:n:zDc:) \ +%pear_package_setup(a:d:n:zDc:) \ %define srcdir %{-n*}%{!-n:%{_pearname}-%{version}} \ %define builddir %{_builddir}/%{srcdir} \ %setup -q -c -T %{-D:-D} -n %{srcdir} \ -%{-z:tar zxf %{S:0}; %{-a:tar zxf %{S:%{-a*}}}} \ +%{-z:%{__tar} zxf %{S:0}; %{-a:%{__tar} zxf %{S:%{-a*}}}} \ %{-z:_P=package2.xml; [ -f $_P ] || _P=package.xml; _N=%{srcdir}; mv $_P $_N; cd $_N} \ %{-c:%{__pear} -c pearrc config-set php_dir %{builddir}/%{php_pear_dir}; %__pear -c %{builddir}/pearrc channel-add %{-c*}} \ %pear_install \ %{-z:cd ..} \ +%{__tar} --wildcards -zvxf %{S:0} package*.xml \ cat %{-z:$_N/}.install.log | %__pear_install_log \ \ # undos sources \ @@ -1425,6 +1446,21 @@ if [ -f _noautoreq ]; then \ fi \ %{nil} +# Print optional package info for pear packages +# Author: Elan Ruusamäe +# Usage: +# %post -p +# %%pear_package_print_optionalpackages +# +# Requirements: +# BuildRequires: rpmbuild(macros) >= 1.571 +%pear_package_print_optionalpackages \ +f = io.open("%{_docdir}/%{name}-%{version}/optional-packages.txt", "r") \ +if f then \ + for l in f:lines() do print(l); end \ +end \ +%{nil} + # Register OpenLDAP schema. # Author: Elan Ruusamäe @@ -1807,16 +1843,32 @@ else: \ # Undos files # # Author: Paweł Zuzelski +# Author: Elan Ruusamäe # # Usage: # %undos list_of_files +# %undos -f EXT[,EXT] +# %undos -i -f EXT[,EXT] +# +# -f EXT[,EXT] - find(1) files by extensions +# -i - case insensitive file search +# +# Example: +# Un-DOS all *.js, *.css files +# %undos -f js,css +# Un-DOS all *.js, *.JS files +# %undos -f js -i +# undos all Makefiles +# %{__find} -name Makefile | xargs %undos # # Requirements: # BuildRequires: sed >= 4.0 -# BuildRequires: rpmbuild(macros) >= 1.553 +# BuildRequires: rpmbuild(macros) >= 1.565 -# NB: make sure this command stays on one line -%undos %{__sed} -i -e 's,\\r$,,' +# NB: make sure this macro stays on one line +# NB: make sure it includes newline escape +%undos(f:i) %{-f:%{__find} -regextype posix-extended -%{-i:i}regex '^.+\\.(%(echo %{-f*} | tr ',' '|'))$' -print0 | xargs -0} %{__sed} -i -e 's,\\r$,,' %* \ +%{nil} # Hook to register nagios object based plugins in Nagios NRPE daemon config. # @@ -1835,7 +1887,8 @@ else: \ # %nagios_nrpe -d %{plugin} -f %{_sysconfdir}/%{plugin}.cfg # # Requirements: -# BuildRequires: sed >= 4.0 +# Requires: grep +# Requires: sed >= 4.0 # BuildRequires: rpmbuild(macros) >= 1.552 %nagios_nrpe(a:d:c:f:) {\ m=$(md5sum < /etc/nagios/nrpe.cfg); \ @@ -1873,4 +1926,39 @@ else: \ /usr/share/cacti/cli/import_template.php --filename=%1 || :; \ }%{nil} +# pre/post script for -upstart subpackages +# +# Author: Jacek Konieczny +# +# Usage: +# %upstart_post service_name +# %upstart_postun service_name +# +# Sample: +# %post upstart +# %upstart_post %{name} +# +# %postun upstart +# %upstart_postun %{name} +# +# Requirements: +# BuildRequires: rpmbuild(macros) >= 1.560 +# Requires: rc-scripts >= 0.4.3 + +# migrate from init script to upstart job +%upstart_post() \ + if [ -f /var/lock/subsys/"%1" ] ; then \ + /sbin/service --no-upstart "%1" stop \ + /sbin/service "%1" start \ + fi + +# restart the job after upgrade or migrate to init script on removal +# cannot be stopped with 'service' as /etc/init/$name.conf may be missing +# at this point +%upstart_postun() \ + if [ -x /sbin/initctl ] && /sbin/initctl status "%1" 2>/dev/null | grep -q 'running' ; then \ + /sbin/initctl stop "%1" >/dev/null 2>&1 \ + [ -f "/etc/rc.d/init.d/%1" -o -f "/etc/init/%1.conf" ] && { echo -n "Re-" ; /sbin/service "%1" start ; } ; \ + fi + # vim:ts=4 sw=4 noet ft=spec