]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
- terminate macro
[packages/rpm-build-macros.git] / rpm.macros
index ec01bcabc975e5a66c5ae89d1d3868833446e658..e11c8aa3d20d937d9a167210acad0c48d41fecc9 100644 (file)
@@ -7,6 +7,7 @@
 
 %epoch         0
 %x8664         x86_64 amd64 ia32e
+%arm           armv3l armv4b armv4l armv5teb armv5tel
 
 # kernel compiler
 %kgcc          %{__cc}
@@ -245,6 +246,11 @@ CFLAGS="%{rpmcflags}" \
 CXXFLAGS="%{rpmcxxflags}" \
 LDFLAGS="%{rpmldflags}" \
 %{__cmake} \
+       -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+       -DCMAKE_BUILD_TYPE=%{!?debug:Release}%{?debug:Debug} \
+%if "%{_lib}" == "lib64" \
+       -DLIB_SUFFIX=64 \
+%endif \
 }
 
 %scons { \
@@ -426,6 +432,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
@@ -996,7 +1007,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
 #
@@ -1351,6 +1362,7 @@ echo -e "</dependencies>\\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
@@ -1372,7 +1384,7 @@ echo -e "</dependencies>\\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 \
@@ -1380,10 +1392,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 \\\
@@ -1392,6 +1405,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 \\\
@@ -1405,19 +1419,18 @@ 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 \
-find -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
+%undos -f php,html,js,xml \
 %{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \
 %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
 %{nil}
@@ -1434,6 +1447,21 @@ if [ -f _noautoreq ]; then \
 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>
@@ -1816,16 +1844,32 @@ else: \
 # 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.
 #
@@ -1844,7 +1888,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); \
@@ -1882,4 +1927,39 @@ else: \
 /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
This page took 0.050941 seconds and 4 git commands to generate.