-# $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
%__autopoint autopoint --force
# add parallel build flags: -jN
+# jobs macro is available since 1.657
#
# if you want to disable parallel build do:
-# echo '%_smp_mflags %{nil}' >> ~/.rpmmacros
-#
+# echo '%__jobs %{nil}' >> ~/.rpmmacros
+%__jobs %{expand:%%global __jobs %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); [ "$_NCPUS" -gt 3 ] && echo $(($_NCPUS / 2)))%%{nil}}%__jobs
+
+# expands to -jN if %__jobs has a value
+%_smp_mflags %{expand:%%global _smp_mflags %(jobs=%{__jobs}; echo ${jobs:+-j$jobs}%%{nil})}%_smp_mflags
+
%__make /usr/bin/make %{?_smp_mflags}
%__scons /usr/bin/scons %{?_smp_mflags}
%__waf /usr/bin/waf %{?_smp_mflags}
%__cmake /usr/bin/cmake
-%_smp_mflags %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); \\\
- [ "$_NCPUS" -gt 1 ] && echo "-j$(($_NCPUS * 2))")
-
%__gettextize { \
if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
gettextize --copy --force --no-changelog; \
%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
#%no_install_post_compress_docs 1
%__spec_install_post_compress_docs { \
%{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
+ %{!?debug:set +x;} \
for i in /usr/share/man /usr/X11R6/man; do \
if [ -d "$RPM_BUILD_ROOT$i" ]; then \
echo "Compress man pages: $i"; \
find "$RPM_BUILD_ROOT$i" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
find "$RPM_BUILD_ROOT$i" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
find $RPM_BUILD_ROOT$i -type l | while read a; do \
- m=$(readlink $a); \
+ m=$(readlink "$a"); \
+ if [[ "$m" = */* ]]; then \
+ # handle links to different man section \
+ l=$(readlink -f "$a"); \
+ # full/relative paths that resolve symlink \
+ l=${l#$RPM_BUILD_ROOT/usr/share/man/}; \
+ l=${l#$RPM_BUILD_ROOT/usr/X11R6/man/}; \
+ # full paths that do not resolve symlink \
+ l=${l#/usr/share/man/}; \
+ l=${l#/usr/X11R6/man/}; \
+ else \
+ l=${a#$RPM_BUILD_ROOT$i/}; \
+ l=${l%/*}; \
+ l="$l/$m"; \
+ fi; \
rm -f $a; \
- echo .so ${m##*/} > $a; \
- echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: ${m##*/}"; \
+ 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") \
+ # TODO: iterate over all man dirs, but in Th there is only one true man dir \
+ err=$(grep -rl '^\.so ' "$RPM_BUILD_ROOT$i" | while read doc; do \
+ l=$(cat "$doc"); \
+ l=${l#.so }; \
+ d=$(dirname $doc); \
+ 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; \
#
%__spec_install_post_strip {%{!?debug: \
%{!?no_install_post_strip:__spec_install_post_strip() { \
+%{!?debug:set +x;} \
if [ -d "$RPM_BUILD_ROOT" ]; then \
if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
modulelist=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
modulecount=$(echo "$modulelist" | wc -l); \
printf "Stripping %d kernel modules..." $modulecount; \
echo "$modulelist" | xargs -l512 chmod u+w; \
- echo "$modulelist" | xargs -l512 %{__strip} --strip-unneeded --remove-section=.comment --remove-section=.note.GNU-stack; \
+ echo "$modulelist" | xargs -l512 %{__strip} -g --remove-section=.comment --remove-section=.note.GNU-stack; \
echo "DONE"; \
fi; \
fi; \
archiveslist=`echo "$filetypes" | awk -F: '/current ar archive/ {print $1}'`; \
if [ -n "$elfexelist" ]; then \
printf "Stripping %d ELF executables..." $(echo "$elfexelist" | wc -l); \
- chmod u+w $elfexelist; \
- %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
+ echo "$elfexelist" | xargs -r -d'\n' chmod u+w; \
+ echo "$elfexelist" | xargs -r -d'\n' %{__strip} --remove-section=.note --remove-section=.comment; \
echo "DONE"; \
fi; \
if [ -n "$elfsharedlist" ]; then \
printf "Stripping %d ELF shared libraries..." $(echo "$elfsharedlist" | wc -l); \
- chmod u+w $elfsharedlist; \
- %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
+ echo "$elfsharedlist" | xargs -r -d'\n' chmod u+w; \
+ echo "$elfsharedlist" | xargs -r -d'\n' %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment; \
echo "DONE"; \
fi; \
if [ -n "$archiveslist" ]; then \
printf "Stripping %d ar archives..." $(echo "$archiveslist" | wc -l); \
- chmod u+w $archiveslist; \
- %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $archiveslist; \
+ echo "$archiveslist" | xargs -r -d'\n' chmod u+w; \
+ echo "$archiveslist" | xargs -r -d'\n' %{__strip} --strip-debug --remove-section=.note --remove-section=.comment; \
echo "DONE"; \
fi; \
fi; \
fi; }; __spec_install_post_strip } } }
#-----------------------------------------------------------------
-# remove all RPATH from executable binaries and shared object files
+# remove all RPATH/RUNPATH from executable binaries and shared object files
#
# Requires: find, awk, cut, xargs, chrpath, uname
#
#
%__spec_install_post_chrpath {%{!?debug: \
%{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
+%{!?debug:set +x;} \
if [ -d "$RPM_BUILD_ROOT" ]; then \
files=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"}`; \
if [ -n "$files" ]; then \
objs=`echo "$files" | xargs -r -d'\\n' file | awk -F: '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}'`; \
fi; \
if [ -n "$objs" ]; then \
- printf "Remove RPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
+ printf "Remove RPATH/RUNPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
echo "$objs" | \
while read file; do \
rpath= ; \
chmod u+w "$file"; \
- for dir in $(chrpath -l "$file" | awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'); do \
+ for dir in $(chrpath -l "$file" | awk '/R(|UN)PATH=/ { gsub(/.*RPATH=/,""); gsub(/.*RUNPATH=/,""); gsub(/:/," "); print $0 }'); do \
case $dir in \
'$ORIGIN' ) \
if [ "$rpath" = "" ] ; then rpath="$dir" ; \
#
%__spec_install_post_check_so { \
__spec_install_post_check_so() { \
+%{!?debug:set +x;} \
fail=0; \
printf "Searching for shared objects with unresolved symbols..."; \
for f in $(find $RPM_BUILD_ROOT -type f -name '*.so.*' -print); do \
%{!?no_install_post_check_so:return $fail;} \
}; __spec_install_post_check_so }}
+#-----------------------------------------------------------------
+# Verify that for each directory under /var/run package contains
+# tmpfiles.d configuration. Warn and terminate build if config is
+# missing.
+#
+#%no_install_post_check_tmpfiles 1
+#
+%__spec_install_post_check_tmpfiles { \
+__spec_install_post_check_tmpfiles() { \
+%{!?debug:set +x;} \
+ fail=0; \
+ echo "Checking /var/run <-> tmpfiles.d completeness..."; \
+ for d in $RPM_BUILD_ROOT/var/run/*; do \
+ [ -d "$d" ] || continue; \
+ d=${d##$RPM_BUILD_ROOT}; \
+ if ! grep -qsF "$d" $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/*.conf $RPM_BUILD_ROOT/etc/tmpfiles.d/*.conf; then\
+ echo "No tmpfiles configuration for '$d'";\
+ fail=1 ; \
+ fi \
+ done ; \
+ echo " DONE"; \
+ %{!?no_install_post_check_tmpfiles:return $fail;} \
+}; __spec_install_post_check_tmpfiles }}
+
#-----------------------------------------------------------------
# Find and gzip all kernel modules
#
#%no_install_post_compress_modules 1
%__spec_install_post_compress_modules { \
%{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
+%{!?debug:set +x;} \
if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
q=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
if [ "$q" ]; then \
#
%__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_archdir %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir
+%ruby_libdir %{expand:%%global ruby_libdir %(%{__ruby} -r rbconfig -e 'print RbConfig::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_sitelibdir %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
+%ruby_rubylibdir %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir
+%ruby_vendorarchdir %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir
+%ruby_vendorlibdir %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir
+%ruby_sitearchdir %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir
+%ruby_sitedir %{expand:%%global ruby_sitedir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitedir"]' 2>/dev/null || echo ERROR)}%ruby_sitedir
+%ruby_sitelibdir %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
%ruby_rdocdir /usr/share/rdoc
-%ruby_version %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version
+%ruby_vendordir %{expand:%%global ruby_vendordir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendordir"]' 2>/dev/null || echo ERROR)}%ruby_vendordir
+%ruby_version %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print RbConfig::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}
# directories
%py3_prefix %{expand:%%global py3_prefix %(%{__python3} -c "import sys; print(sys.prefix)" 2>/dev/null || echo ERROR)}%py3_prefix
-%py3_libdir %{py3_prefix}/%{_lib}/python%{py3_ver}
+%py3_libdir %{expand:%%global py3_libdir %(%{__python3} -c "import sysconfig; print(sysconfig.get_path('platstdlib'))" 2>/dev/null || echo ERROR)}%py3_libdir
+%py3_incdir %{expand:%%global py3_incdir %(%{__python3} -c "import sysconfig; print(sysconfig.get_path('include'))" 2>/dev/null || echo ERROR)}%py3_incdir
+%py3_sitedir %{expand:%%global py3_sitedir %(%{__python3} -c "import sysconfig; print(sysconfig.get_path('platlib'))" 2>/dev/null || echo ERROR)}%py3_sitedir
+%py3_sitescriptdir %{expand:%%global py3_sitescriptdir %(%{__python3} -c "import sysconfig; print(sysconfig.get_path('purelib'))" 2>/dev/null || echo ERROR)}%py3_sitescriptdir
%py3_scriptdir %{py3_prefix}/share/python%{py3_ver}
-%py3_incdir /usr/include/python%{py3_ver}
-%py3_sitedir %{py3_libdir}/site-packages
-%py3_sitescriptdir %{py3_scriptdir}/site-packages
%py3_dyndir %{py3_libdir}/lib-dynload
# pure python modules compilation
%py3_ocomp %{__python3} -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
+# node.js libdir
+# Requirements:
+# BuildRequires: rpmbuild(macros) >= 1.634
+%nodejs_libdir /usr/lib/node_modules
+
# Hardlink binary identical .pyc and .pyo files
%__spec_install_post_py_hardlink {\
%{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
-local a b c=0 t=0; \
+%{!?debug:set +x;} \
+local a b c=0 t=0 pyc=%{tmpdir}/%{name}-%{version}-%{release}__rpm_pyc; \
if [ -d "$RPM_BUILD_ROOT" ]; then \
- find "$RPM_BUILD_ROOT" -name '*.pyc' > __rpm_pyc; \
+ find "$RPM_BUILD_ROOT" -name '*.pyc' > $pyc; \
while read a; do \
b="${a%.pyc}.pyo"; \
if cmp -s "$a" "$b"; then \
c=$((c + 1)); \
fi; \
t=$((t + 1)); \
- done < __rpm_pyc; \
+ done < $pyc; \
[ $t -gt 0 ] && printf "Hardlink Python files: %d/%d files hardlinked\n" $c $t; \
- rm -f __rpm_pyc; \
+ rm -f $pyc; \
fi; \
}; __spec_install_post_py_hardlink } }
-# remove python sources, so that check-files won't complain
-%py_postclean() \
+# Remove Python 2.x sources,
+# PLD Linux policy is to package only compiled .py[co] for Python 2.x libraries.
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+# %py_postclean /usr/share/extra -x keepme.py,keeptoo.py
+# Options:
+# -x - comma separated of file basenames to preserve
+# ARGS - extra directories to clean for .py sources
+#
+%py_postclean(x:) \
for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
- [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
-done \
-%{nil}
-
-%py3_postclean() \
-for d in %{py3_sitescriptdir} %{py3_sitedir} %*; do \
- [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
+ [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 %{-x:| grep -ZzvE '/(%(echo '%{-x*}' | tr ',' '|'))$'} | xargs -0r -l512 rm;\
done \
%{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
# Requires: rc-scripts
# -n option:
# BuildRequires: rpmbuild(macros) >= 1.450
-%service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
-
+%service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1} RPM_BUILD_ROOT=%{buildroot}; /usr/lib/rpm/service_generator.sh %{*}) };}
# Java macros. based on jpackage macros.java
#
%__pear_install_log \
tee install.log \
# make post message of optional packages \
-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 \
+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-,' > 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 \
# 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 %__php -doutput_buffering=1 -dopen_basedir="" -dmemory_limit=-1 -ddate.timezone=GMT /usr/share/pear/pearcmd.php
%pear_install(a:d:n:zD) \
%__pear \\\
%{!?-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- \\\
\
%{?-C:cd %{-C*}} \
compile() { \
+ local L="<" PATCH_SH; \
+ [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)" \
+ set -e -x \
+ \
+ [ -r "%{_kernelsrcdir}/.config" ] || exit 1 \
+ rm -rf o \
+ 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 -sf %{_kernelsrcdir}/include/generated/autoconf.h o/include/generated/autoconf.h \
+ 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 \
+ [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell \
+ set -x \
+ \
+ install -d o/include/config \
+ touch o/include/config/MARKER \
+ ln -sf %{_kernelsrcdir}/include/config/auto.conf o/include/config/auto.conf \
+ ln -sf %{_kernelsrcdir}/scripts o/scripts \
+ \
+ %{!?-c:%{__make} -C %{_kernelsrcdir} clean \\\
+ RCS_FIND_IGNORE="-name '*.[ks]o' -o" \\\
+ ${1+"$@"} \\\
+ M=$PWD %{MakeOpts}} \
+ \
+ %{__make} -C %{_kernelsrcdir} modules \\\
+ ${1+"$@"} \\\
+ M=$PWD CONSTIFY_PLUGIN="" %{MakeOpts} \
+%{?-C:cd -} \
+} \
+compile_old() { \
local L="<" PATCH_SH; \
[[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)" \
set -e -x \
%endif \
\
%{!?-c:%{__make} -C %{_kernelsrcdir} clean \\\
- RCS_FIND_IGNORE="-name '*.ko' -o" \\\
+ RCS_FIND_IGNORE="-name '*.[ks]o' -o" \\\
${1+"$@"} \\\
M=$PWD %{MakeOpts}} \
\
%{__make} -C %{_kernelsrcdir} modules \\\
${1+"$@"} \\\
- M=$PWD %{MakeOpts} \
+ M=$PWD CONSTIFY_PLUGIN="" %{MakeOpts} \
\
for MODULE in {%{-m*},}; do \
[ -z "${MODULE}" ] || mv ${MODULE}{,-$cfg}.ko \
done \
%{?-C:cd -} \
} \
-compile %{*}\
+if [ -r "%{_kernelsrcdir}/.config" ]; then \
+ compile %{*} \
+else \
+ compile_old %{*} \
+fi \
%{nil}
%define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \
\
__install_kernel_modules() { \
+%{!?debug:set +x;} \
+ \
+for MODULE in {%{-m*},}; do \
+ [ -n "${MODULE}" ] || continue \
+ MNAME=${MODULE##*/} \
+ install -m 644 -D ${MODULE}.ko %{KernelD}/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko \
+ %{?-s:install -d %{ModprobeD} \
+ echo "alias ${MNAME} ${MNAME}-%{-s*}" >> %{ModprobeD}/%{-n*}.conf} \
+done \
+} \
+__install_kernel_modules_old() { \
+%{!?debug:set +x;} \
local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
\
for MODULE in {%{-m*},}; do \
for cfg in ${cfgs:-dist}; do \
[ "$cfg" = smp ] && suf=smp || suf= \
MNAME=${MODULE##*/} \
- install -D ${MODULE}-$cfg.ko \\\
+ install -m 644 -D ${MODULE}-$cfg.ko \\\
%{KernelD}$suf/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko \
%{?-s:install -d %{ModprobeD}$suf \
echo "alias ${MNAME} ${MNAME}-%{-s*}" \\\
done \
done \
} \
-__install_kernel_modules \
+if [ -r "%{_kernelsrcdir}/.config" ]; then \
+ __install_kernel_modules \
+else \
+ __install_kernel_modules_old \
+fi \
%{nil}
# patchset macros
) \
%{nil}
+# return EXPANDED source url N from current spec
+%sourceurl(n:) %(test "$IN_RPM" = 1 && exit 1; export IN_RPM=1; rpmbuild --nodigest --nosignature --nobuild -D "prep %%dump" %{_specdir}/%{name}.spec 2>&1 | awk '$2 ~ /^SOURCEURL%{-n*}/ {print $3}')
+
# browser plugins v2
# Author: Elan Ruusamäe <glen@pld-linux.org>
#
%py_lint() \
__py_lint() { \
+%{!?debug:set +x;} \
find "$@" -type f -name '*.py' | python -c ' \
import sys \
import compiler \
\
found = err = 0\
for f in sys.stdin: \
- fd = open(f.strip()) \
+ fd = open(f.rstrip()) \
c = fd.read() \
fd.close() \
+ found = found + 1 \
try: \
compiler.parse(c) \
except SyntaxError, e: \
- print "py_lint: %s: %s" % (f.strip(), e) \
+ print "py_lint: %s: %s" % (f.rstrip(), e) \
err = err + 1\
\
if not found:\
print >> sys.stderr, "\\npy_lint: ERROR: Syntax errors in %d files.\\n" % err \
sys.exit(1) \
else: \
- print >> sys.stderr, "py_lint: Found no syntax errors." \
+ print >> sys.stderr, "py_lint: %d files scanned, found no syntax errors." % found \
' \
}; __py_lint %* \
%{nil}
# %cacti_import_template %{resourcedir}/cacti_host_template_varnish.xml
#
# Requires: cacti >= 0.8.7e-8
-# BuildRequires: rpmbuild(macros) >= 1.554
+# BuildRequires: rpmbuild(macros) >= 1.630
+# Note: 1.1 (cacti-0.8.7h) adds requirement for --with-template-rras or --with-user-rras option
%cacti_import_template() {\
-/usr/share/cacti/cli/import_template.php --filename=%1 || :; \
+v=$(%{__sed} -rne 's/.+Add Graphs Script ([0-9\.]+).+/\1/p' /usr/share/cacti/cli/import_template.php); \
+if [ "$v" != "1.0" ]; then \
+ rra="--with-template-rras"; \
+fi; \
+/usr/share/cacti/cli/import_template.php --filename=%1 $rra || :; \
}%{nil}
# pre/post script for -upstart subpackages
[ -f /etc/rc.d/init.d/%1 -o -f /etc/init/%1.conf ] && { echo -n "Re-"; /sbin/service %1 start; }; \
fi
+# Haskell Macros
+# BuildRequires: rpmbuild(macros) >= 1.608
+%ghcdir ghc-%(/usr/bin/ghc --numeric-version 2>/dev/null || echo ERROR)
+
+# update /usr/lib*/ghc-*/package.conf.d/package.cache
+# Requires: ghc
+# BuildRequires: rpmbuild(macros) >= 1.607
+#
+%ghc_pkg_recache() {{ \
+ umask 022; \
+ /usr/bin/ghc-pkg recache; \
+};} \
+%{nil}
+
+
+# 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
+# %systemd_trigger service_name1.service service_name2.service
+#
+# Sample:
+# %post
+# %systemd_post %{name}.service
+#
+# %preun
+# %systemd_preun %{name}.service
+#
+# %postun
+# %systemd_reload
+#
+# %triggerpostun -- %{name} < first-version-with-systemd-units
+# %systemd_trigger %{name}.service
+#
+# Requirements:
+# 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 \
+ [ ${RPM_ENABLE_SYSTEMD_SERVICE:-yes} = no ] && return 1 \
+ /sbin/chkconfig --list ${1%.service} 2>/dev/null | grep -qsv "[0-6]:on" && return 1 \
+ return 0 \
+}\
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ for s in %{*}; do \
+ if want_enable_service $s; then \
+ /bin/systemctl --quiet enable $s || : \
+ fi \
+ done \
+%{nil}
+
+%systemd_post() \
+ export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+ /bin/systemd_booted && /bin/systemctl --quiet daemon-reload || : \
+ if [ $1 -eq 1 ]; then \
+ /bin/systemctl --quiet enable %{*} || : \
+ /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/systemd_booted && /bin/systemctl --quiet stop %{*} || : \
+ /bin/systemctl --quiet disable %{*} || : \
+ fi \
+%{nil}
+
+%systemdunitdir /lib/systemd/system
+%systemdtmpfilesdir /usr/lib/tmpfiles.d
+
# EOF