-# $Revision$, $Date$
# vim:ts=4 sw=4 noet ft=spec
#
# PLD Linux rpm macros.
# <http://www.pld-linux.org/>
# can be used by builder script to check for version
-%rpm_build_macros %(R="$Revision$"; RR="${R##: }"; echo ${RR%%?})
+%rpm_build_macros {Revision}
%epoch 0
%x8664 x86_64 amd64 ia32e
%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
-%releq_kernel_smp(n:) %{expand:%%global releq_kernel_smp %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}}-smp = %|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_smp
+%releq_kernel(n:) %{expand:%%global releq_kernel %(R=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}} = %|E?{%{E}:}|%{V}-%{R}' -f 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=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}}-up = %|E?{%{E}:}|%{V}-%{R}' -f include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_up
+%releq_kernel_smp(n:) %{expand:%%global releq_kernel_smp %(R=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}}-smp = %|E?{%{E}:}|%{V}-%{R}' -f include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_smp
# -s post to generate Requires(post) dependency
%requires_releq_kernel(s:n:) Requires%{-s:(%{-s*})}: %releq_kernel
# 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)}}
+# \helper for renaming packages
+# %rename old-package
+%rename() \
+Obsoletes: %{1} < %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}} \
+Provides: %{1} = %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}}
+
%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
echo ${Z:-ERROR}; \\
)}%__kernel_ver
-%__kernel_rel %{expand:%%global __kernel_rel %(Z=$(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rel
-%__kernel_rpmvr %{expand:%%global __kernel_rpmvr %(Z=$(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{V}-%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rpmvr
+%__kernel_rel %{expand:%%global __kernel_rel %(Z=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -qf include/linux/fs.h 2>/dev/null --qf "%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rel
+%__kernel_rpmvr %{expand:%%global __kernel_rpmvr %(Z=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -qf include/linux/fs.h 2>/dev/null --qf "%{V}-%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rpmvr
%_kernel_ver %{expand:%%global _kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}}%_kernel_ver
%_kernel_ver_str %{expand:%%global _kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')}%_kernel_ver_str
l=${l#/usr/share/man/}; \
l=${l#/usr/X11R6/man/}; \
else \
- l=$m; \
+ l=${a#$RPM_BUILD_ROOT$i/}; \
+ l=${l%/*}; \
+ l="$l/$m"; \
fi; \
rm -f $a; \
echo ".so $l" > $a; \
echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: $l"; \
done; \
+ # verify that .so links point to existing files (not allowed to point to "other package")
+ err=$(grep -rl '^\.so ' "$RPM_BUILD_ROOT$i" | while read doc; do \
+ l=$(cat "$doc"); \
+ l=${l#.so }; \
+ d=$(dirname $doc); \
+ # TODO: iterate over all man dirs, but in Th there\'s only one true man dir \
+ test -e $RPM_BUILD_ROOT$i/$l || test -e $d/$l || echo " ${doc#$RPM_BUILD_ROOT} points to inexistent manpage: $l"; \
+ done); \
+ test "$err" != "" && { echo >&2 "Man page link errors:"; echo >&2 "$err"; exit 1; }; \
find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
fi; \
done; \
#
%__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
%__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
-%__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
%__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
%__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
+%__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq) \
+ %{?_noautoreq: %{_noautoreq}} \
+ %{?_noautoreq_pear: %{__noauto_regexp_helper -p pear %{_noautoreq_pear}}} \
+ %{?_noautoreq_perl: %{__noauto_regexp_helper -p perl %{_noautoreq_perl}}} \
+ %{nil}
+
+# helper for wrapping _noautoreq between perl() or pear()
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Usage:
+# BuildRequires: rpmbuild(macros) >= 1.654
+# %define _noautoreq_pear Excluded.php PEAR/Something.php
+# %define _noautoreq_perl Apache::.*
+%__noauto_regexp_helper(p:) %(echo "%*" | awk 'BEGIN{RS=" "}{printf("%{-p*}\\\\\\(%%s\\\\\\) ", $1)}')
#%_noautocompressdoc %{nil}
#
# Ruby
%__ruby /usr/bin/ruby
+
%ruby_archdir %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir
+%ruby_libdir %{expand:%%global ruby_libdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_libdir
%ruby_ridir %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)}%ruby_ridir
%ruby_rubylibdir %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir
%ruby_vendorarchdir %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir
%ruby_vendorlibdir %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir
%ruby_sitearchdir %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir
+%ruby_sitedir %{expand:%%global ruby_sitedir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitedir"]' 2>/dev/null || echo ERROR)}%ruby_sitedir
%ruby_sitelibdir %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
%ruby_rdocdir /usr/share/rdoc
+%ruby_vendordir %{expand:%%global ruby_vendordir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendordir"]' 2>/dev/null || echo ERROR)}%ruby_vendordir
%ruby_version %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version
+
%ruby_ver_requires_eq Requires: ruby(ver) = %ruby_version
%ruby_mod_ver_requires_eq Requires: ruby-modules(ver) = %ruby_version
# "_ts" if ZTS enabled, empty otherwise
%zend_zts %{expand:%%global _zend_zts_%{?_zend_zts} 1}%{?_zend_zts_1:_ts}
+# name of php package
+%php_name php%{?php_suffix}
+# use rpmbuild -D 'php_suffix 54' to build php extension for php 5.4
+# NOTE: error output must be empty. otherwise can't build pecl packages if no php*-devel is installed
+%php_suffix %(c=$(php-config --sysconfdir 2>/dev/null) || echo '' && echo ${c#/etc/php})
+
# helper macro
-%__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
+%__php_api_requires(v:) Requires: %{php_name}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
# macros for public use
# for php extensions (php-pecl)
%requires_php_extension %{__php_api_requires modules_api php_api_version} \
%{__php_api_requires zend_module_api} \
-%{__php_api_requires -v %php_major_version debug php_debug} \
-%{__php_api_requires -v %php_major_version thread-safety _zend_zts}
+%{__php_api_requires debug php_debug} \
+%{__php_api_requires thread-safety _zend_zts}
# for zend extensions
%requires_zend_extension %{__php_api_requires zend_module_api} \
%{__php_api_requires zend_extension_api} \
-%{__php_api_requires -v %php_major_version debug php_debug} \
-%{__php_api_requires -v %php_major_version thread-safety _zend_zts}
+%{__php_api_requires debug php_debug} \
+%{__php_api_requires thread-safety _zend_zts}
# for php pdo modules (php-pecl-PDO_*)
%requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
%service -q php-fcgi restart \
fi \
fi \
-if [ -x /etc/rc.d/init.d/php-fpm ]; then \
- %service -q php-fpm restart \
+if [ -x /etc/rc.d/init.d/%{php_name}-fpm ]; then \
+ %service -q %{php_name}-fpm restart \
fi \
%{nil}
%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
+%_host_base_arch %{expand:%%global _host_base_arch %(echo %{_host_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/')}%_host_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
%{!?-m:%{error:%{0}: Required module name/list missing} exit 1} \
\
%define Opts \\\\\\\
-%if "%{_target_base_arch}" != "%{_arch}" \\\
- %if "%{_arch}" == "x86_64" && "%{_target_base_arch}" == "i386" \\\
+%if "%{_target_base_arch}" != "%{_host_base_arch}" \\\
+ %if "%{_host_base_arch}" == "x86_64" && "%{_target_base_arch}" == "i386" \\\
CC="%{kgcc}" ARCH=%{_target_base_arch} \\\
%else \\\
ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\
\
[ -r "%{_kernelsrcdir}/.config" ] || exit 1 \
rm -rf o \
- install -d o/include/linux o/include/generated o/arch/powerpc/lib \
+ install -d o/include/linux o/include/generated o/arch/x86/include o/arch/powerpc/lib \
ln -sf %{_kernelsrcdir}/.config o/.config \
ln -sf %{_kernelsrcdir}/Module.symvers o/Module.symvers \
if [ -f %{_kernelsrcdir}/include/generated/autoconf.h ]; then \
ln -s ../generated/autoconf.h o/include/linux/autoconf.h \
else \
ln -sf %{_kernelsrcdir}/include/linux/autoconf.h o/include/linux/autoconf.h \
+ fi \
+ if [ -d %{_kernelsrcdir}/arch/x86/include/generated ]; then \
+ ln -s %{_kernelsrcdir}/arch/x86/include/generated o/arch/x86/include \
fi \
\
set +x \
# pre/post script for packages supporting systemd units
#
# Author: Bartlomiej Zimon <uzi18@o2.pl>
+# Jan Rękorajski <baggins@mimuw.edu.pl>
#
# Usage:
# %systemd_reload
+# %systemd_service <unit command> service_name1.service service_name2.service
+# %systemd_service_enable service_name1.service service_name2.service
+# %systemd_service_disable service_name1.service service_name2.service
+# %systemd_service_start service_name1.service service_name2.service
+# %systemd_service_stop service_name1.service service_name2.service
+# %systemd_service_restart service_name1.service service_name2.service
+# %systemd_service_reload service_name1.service service_name2.service
+#
# %systemd_post service_name1.service service_name2.service
# %systemd_preun service_name1.service service_name2.service
-# %systend_trigger service_name1.service service_name2.service
+# %systemd_trigger service_name1.service service_name2.service
#
# Sample:
# %post
# %systemd_trigger %{name}.service
#
# Requirements:
-# BuildRequires: rpmbuild(macros) >= 1.627
-# Requires: systemd-units >= 37-0.10
+# BuildRequires: rpmbuild(macros) >= 1.647
+# Requires: systemd-units >= 38
%systemd_reload /bin/systemd_booted && SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog /bin/systemctl --quiet daemon-reload || :
+%systemd_service_enable() \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemctl --quiet enable %{*} || : \
+ /bin/systemd_booted && echo 'Run "/bin/systemctl start %{*}" to start %{*}.' || : \
+%{nil}
+
+%systemd_service_disable() \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemctl --quiet disable %{*} || : \
+%{nil}
+
+%systemd_service() \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemd_booted && /bin/systemctl --quiet %{*} || : \
+%{nil}
+
+%systemd_service_start() \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemd_booted && /bin/systemctl --quiet start %{*} || : \
+%{nil}
+
+%systemd_service_stop() \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemd_booted && /bin/systemctl --quiet stop %{*} || : \
+%{nil}
+
+%systemd_service_restart() \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemd_booted && /bin/systemctl --quiet try-restart %{*} || : \
+%{nil}
+
+%systemd_service_reload() \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemd_booted && /bin/systemctl --quiet reload %{*} || : \
+%{nil}
+
%systemd_trigger() \
want_enable_service() { \
[ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
/bin/systemd_booted && /bin/systemctl --quiet daemon-reload || : \
if [ $1 -eq 1 ]; then \
/bin/systemctl --quiet enable %{*} || : \
- fi \
- if [ $1 -gt 1 ] && [ -z "$NORESTART" ]; then \
- /bin/systemctl --quiet try-restart %{*} || : \
+ /bin/systemd_booted && echo 'Run "/bin/systemctl start %{*}" to start %{*}.' || : \
+ elif [ -z "$NORESTART" ]; then \
+ /bin/systemd_booted && /bin/systemctl --quiet try-restart %{*} || : \
+ else \
+ /bin/systemd_booted && echo 'Run "/bin/systemctl restart %{*}" to restart %{*}.' || : \
fi \
%{nil}
%systemd_preun() \
if [ $1 -eq 0 ]; then \
- export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog; \
- /bin/systemctl --no-reload --quiet disable %{*} || : \
- if /bin/systemd_booted; then \
- /bin/systemctl --quiet stop %{*} || : \
- fi \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemd_booted && /bin/systemctl --quiet stop %{*} || : \
+ /bin/systemctl --quiet disable %{*} || : \
fi \
%{nil}