%epoch 0
%x8664 x86_64 amd64 ia32e
+%arm armv3l armv4b armv4l armv5teb armv5tel
# kernel compiler
%kgcc %{__cc}
CXXFLAGS="%{rpmcxxflags}" \
LDFLAGS="%{rpmldflags}" \
%{__cmake} \
+-DCMAKE_INSTALL_PREFIX=%{_prefix} \
+-DCMAKE_BUILD_TYPE=%{!?debug:Release}%{?debug:Debug} \
}
%scons { \
%{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
# 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
# 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
%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
#
# -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
%__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 \
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 \\\
-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 \\\
# 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 \
fi \
%{nil}
+# Print optional package info for pear packages
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Usage:
+# %post -p <lua>
+# %%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 <glen@pld-linux.org>
# Undos files
#
# Author: Paweł Zuzelski <pawelz@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
#
# 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.
#
# %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); \
/usr/share/cacti/cli/import_template.php --filename=%1 || :; \
}%{nil}
+# pre/post script for -upstart subpackages
+#
+# Author: Jacek Konieczny <jajcus@jajcus.net>
+#
+# 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