]> git.pld-linux.org Git - packages/rpm.git/blobdiff - rpm.macros
- no backslashing needed inside %()
[packages/rpm.git] / rpm.macros
index 197b23e09501170d12386f5e48eb6c81d643b0f4..96ad4d9d9b0d97264e3ad400cc0f90d9278aa5c6 100644 (file)
@@ -91,6 +91,20 @@ fi; \
        %{filter_out}
 }')
 
+# rpmldflags with stripped -Wl, -- in the form flags have to be passed to 'ld'
+# but, don't use it, better use gcc as linker
+%ld_rpmldflags %(awk 'BEGIN {
+        split("%{rpmldflags}",F);
+        for (f in F) {
+                s = F[f];
+                if (s ~ /^-Wl,/) {
+                        s = substr(s,5);
+                        gsub(/,/," ",s);
+                };
+                printf(s FS);
+        };
+}')
+
 #-----------------------------------------------------------------
 %configure2_13 { \
  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
@@ -120,12 +134,32 @@ fi; \
        %{dependencytracking} \
 }
 
+# override __cmake to add -j4 in your ~/.rpmmacros for parallel make
+%__cmake       /usr/bin/cmake
 %cmake { \
 CC="%{__cc}" \
 CXX="%{__cxx}" \
 CFLAGS="%{rpmcflags}" \
 CXXFLAGS="%{rpmcxxflags}" \
-cmake \
+%{__cmake} \
+}
+
+# override __scons to add -j4 in your ~/.rpmmacros for parallel make
+%__scons       /usr/bin/scons
+%scons { \
+%{__scons} \
+}
+
+# waf. see waf.spec
+# override __waf to add -j4 in your ~/.rpmmacros for parallel make
+%__waf /usr/bin/waf
+%waf { \
+CC="%{__cc}" \
+CXX="%{__cxx}" \
+CPP="%{__cpp}" \
+CFLAGS="%{rpmcflags}" \
+CXXFLAGS="%{rpmcxxflags}" \
+%{__waf} \
 }
 
 #----------------------------------------------------------------
@@ -164,17 +198,21 @@ cmake \
 # Overloading of some basic macros
 %prep \
 %%prep\
-LANG=C\
-export LANG\
-unset DISPLAY ||:\
+export LC_ALL=C\
+export LANG=C\
 unset LINGUAS ||:\
+unset LANGUAGE ||:\
+unset LC_MESSAGES ||:\
+unset DISPLAY ||:\
 %{nil}
 
 %build %%build\
-LANG=C\
-export LANG\
-unset DISPLAY ||:\
+export LC_ALL=C\
+export LANG=C\
 unset LINGUAS ||:\
+unset LANGUAGE ||:\
+unset LC_MESSAGES ||:\
+unset DISPLAY ||:\
 %{nil}
 
 %install \
@@ -182,10 +220,12 @@ unset LINGUAS ||:\
 %{?buildsubdir:%{debug_package}}\
 %endif\
 %%install\
-LANG=C\
-export LANG\
-unset DISPLAY ||:\
+export LC_ALL=C\
+export LANG=C\
 unset LINGUAS ||:\
+unset LANGUAGE ||:\
+unset LC_MESSAGES ||:\
+unset DISPLAY ||:\
 %{nil}
 
 # Location of autoconf macros
@@ -312,23 +352,28 @@ unset LINGUAS ||:\
        if [ -d "$RPM_BUILD_ROOT" ]; then \
        echo "Strip executable binaries, archives and shared object files."; \
        filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
-       elfexelist=`echo $filelist | xargs -r file | \
-               awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
-       elfsharedlist=`echo $filelist | xargs -r file | \
-               awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
-       elfarchiveslist=`echo $filelist | xargs -r file | \
-               awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
+       printf "Considering %d files\n" $(echo "$filelist" | wc -l); \
+       filetypes=`echo $filelist | xargs -r file` \
+       elfexelist=`echo "$filetypes" | awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
+       elfsharedlist=`echo "$filetypes" | awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
+       archiveslist=`echo "$filetypes" | awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
        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 "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 "DONE"; \
        fi; \
-       if [ -n "$elfarchiveslist" ]; then \
-               chmod u+w $elfarchiveslist; \
-               %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
+       if [ -n "$archiveslist" ]; then \
+               printf "Stripping %d ar archives..." $(echo "$elfsharedlist" | wc -l); \
+               chmod u+w $archiveslist; \
+               %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $archiveslist; \
+               echo "DONE"; \
        fi; \
 fi; }; __spec_install_post_strip } } }
 
@@ -372,14 +417,13 @@ fi; }; __spec_install_post_chrpath } } }
 #%no_install_post_compress_modules     1
 %__spec_install_post_compress_modules { \
 %{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
-       if [ -d "$RPM_BUILD_ROOT" ]; then \
-               echo "Compress kernel modules if any."; \
-               if test -d $RPM_BUILD_ROOT/lib/modules ; then \
-                       find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
-                       xargs -r %{__gzip} -9nf; \
-                       find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
-                       while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
-               fi; \
+       if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
+               echo "Compress kernel modules"; \
+               q=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
+               echo "$q" | xargs -r %{__gzip} -9nf; \
+               printf "%d modules compressed\n" $(echo "$q" | wc -l); \
+               find $RPM_BUILD_ROOT/lib/modules -name '*o' -type l -printf "%p %l\n" | \
+               while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
        fi; \
 }; __spec_install_post_compress_modules } }
 
@@ -505,6 +549,8 @@ fi \
 %ruby_mod_ver_requires_eq      Requires:       ruby-modules(ver) = %ruby_version
 
 %php_pear_dir          /usr/share/pear
+%php_extensiondir      %(php-config --extension-dir 2>/dev/null || echo ERROR)
+%php_sysconfdir                %(php-config --sysconfdir 2>/dev/null || echo ERROR)
 
 # directory where php includes are installed on system.
 %__php_includedir              /usr/include/php
@@ -536,6 +582,30 @@ fi \
 # for php pdo modules (php-pecl-PDO_*)
 %requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
 
+# for using PHP post scripts. for PHP >= 5.0
+%php_webserver_restart \
+[ ! -f /etc/apache/conf.d/??_mod_php.conf ] || %service -q apache restart \
+[ ! -f /etc/httpd/conf.d/??_mod_php.conf ] || %service -q httpd restart \
+if [ -f /etc/rc.d/init.d/php-fcgi ]; then \
+       PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
+       if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php.fcgi* ]]; then \
+               %service -q php-fcgi restart \
+       fi \
+fi \
+%{nil}
+
+# for using php post scripts. for PHP >= 4.0 && PHP < 5.0
+%php4_webserver_restart \
+[ ! -f /etc/apache/conf.d/??_mod_php4.conf ] || %service -q apache restart \
+[ ! -f /etc/httpd/conf.d/??_mod_php4.conf ] || %service -q httpd restart \
+if [ -f /etc/rc.d/init.d/php-fcgi ]; then \
+       PHP_FCGI_BINARY=; . /etc/sysconfig/php-fcgi 2>/dev/null \
+       if [[ ${PHP_FCGI_BINARY:-php.fcgi} = *php4.fcgi* ]]; then \
+               %service -q php-fcgi restart \
+       fi \
+fi \
+%{nil}
+
 # Python specific macro definitions.
 # python main version
 %py_ver                        %(python -c "import sys; print sys.version[:3]")
@@ -655,8 +725,8 @@ fi \
 eval $CMD %2%{?3: %3} \
 %nil
 
-# useradd/groupadd macros written by glen@pld-linux.org.
-# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
+# useradd/groupadd macros
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
@@ -719,10 +789,11 @@ else \
        [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group || : \
 fi;
 
-# apache_config_{install/uninstall} macros written by glen@pld-linux.org.
-# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
+# apache_config_{install/uninstall} macros *DEPRECATED*
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
-# You should use webapp macros instead. these are here until single piece of them is gone from specs ;)
+# You should use webapp macros instead. these are here until single piece of
+# them is gone from specs ;)
 #
 # The config is installed/removed inside trigger, this means that you can any
 # time install apache1 or apache package and the configuration file is updated.
@@ -788,6 +859,7 @@ fi \
 %{nil}
 
 # webapp macros
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # The config is installed/removed inside trigger, this means that you can any
 # time install apache1/apache/lighttpd package and the configuration file is
@@ -825,7 +897,7 @@ fi \
 %{nil}
 
 # see browser-plugins.spec / template-browser-plugin.spec
-# written by glen@pld-linux.org.
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 %nsplugin_install(d:f) { \
 # create link if it's first install of either of the packages \
 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
@@ -851,14 +923,12 @@ if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
 }
 
 # service macro.
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # calls usual service restart on package %post, but skips the restart if
 # administrator has disabled automatic service restarts in either global
 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
 #
-# written by glen@pld-linux.org.
-# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
-#
 # Usage:
 #   %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
 #
@@ -927,7 +997,7 @@ run "$@"\
 EOF
 
 # PEAR install macros
-# Author: glen@pld-linux.org.
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #      %%pear_package_setup [-a #] [-n FMT]
@@ -1065,13 +1135,15 @@ done \
 # Author: Przemyslaw Iskra <sparky@pld-linux.org>
 #
 # Usage:
-#      %build_kernel_modules -m <modules>
+#      %build_kernel_modules -m <modules> -C <directory>
 #
 #  remember that proper Makefile is still required
 # Options:
-#  -m <modules> (required) -- coma-separated list of modules to save,
+#  -m <modules> (required) -- comma-separated list of modules to save,
 #              without .ko extension, may be placed in subdirectory
+#  -C <directory> -- change to <directory> before doing anything
 #  -p <arg>, -P <arg> -- arguments passeed to make scripts
+#  -c -- do not execute make clean
 #  <additional arguments> -- all additional arguments will be passed to
 #              make modules
 #
@@ -1089,7 +1161,7 @@ done \
 # - in last line \ has to touch arguments so arguments passing
 #   in new lines (using \) will be supported
 
-%build_kernel_modules(p:P:m:)                                                                          \
+%build_kernel_modules(p:P:m:C:c)                                                                       \
 %{!?-m:%{error:%{0}: Required module name/list missing} exit 1}                \
                                                                                                                                        \
 %define Opts                                                                                                           \\\\\\\
@@ -1105,6 +1177,7 @@ done \
 %define        MakeOpts HOSTCC="%{__cc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\
                O=$PWD/o %{?with_verbose:V=1} %{Opts}                                           \
                                                                                                                                        \
+%{?-C:cd %{-C*}}                                                                                                       \
 compile() {                                                                                                                    \
        L="<"; [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)"    \
        set -e -x                                                                                                               \
@@ -1112,10 +1185,18 @@ compile() {                                                                                                                     \
 for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}; do \
        [ -r "%{_kernelsrcdir}/config-$cfg" ] || exit 1                                 \
                                                                                                                                        \
+       rm -rf o                                                                                                                \
        install -d o/include/linux                                                                              \
        ln -sf %{_kernelsrcdir}/config-$cfg o/.config                                   \
        ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers    \
        ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \
+%ifarch ppc ppc64                                                                                                      \
+       install -d o/include/asm                                                                                \
+       [ ! -d %{_kernelsrcdir}/include/asm-powerpc ] || ln -sf %{_kernelsrcdir}/include/asm-powerpc/* o/include/asm    \
+       [ ! -d %{_kernelsrcdir}/include/asm-%{_target_base_arch} ] || ln -snf %{_kernelsrcdir}/include/asm-%{_target_base_arch}/* o/include/asm \
+%else                                                                                                                          \
+       ln -sf %{_kernelsrcdir}/include/asm-%{_target_base_arch} o/include/asm \
+%endif                                                                                                                         \
                                                                                                                                        \
        set +x                                                                                                                  \
        [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell    \
@@ -1131,9 +1212,9 @@ for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}
                ln -sf %{_kernelsrcdir}/scripts o/scripts                                       \
        %endif                                                                                                                  \
                                                                                                                                        \
-       %{__make} -C %{_kernelsrcdir} clean                                                             \\\
+       %{!?-c:%{__make} -C %{_kernelsrcdir} clean                                              \\\
                RCS_FIND_IGNORE="-name '*.ko' -o"                                                       \\\
-               M=$PWD %{MakeOpts}                                                                                      \
+               M=$PWD %{MakeOpts}}                                                                                     \
        %{__make} -C %{_kernelsrcdir} modules                                                   \\\
                ${1+"$@"}                                                                                                       \\\
                M=$PWD %{MakeOpts}                                                                                      \
@@ -1142,6 +1223,7 @@ for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}
                [ -z "${MODULE}" ] || mv ${MODULE}{,-$cfg}.ko                           \
        done                                                                                                                    \
 done                                                                                                                           \
+%{?-C:cd -}                                                                                                                    \
 }                                                                                                                                      \
 compile %{*}\
 %{nil}
@@ -1154,7 +1236,7 @@ compile %{*}\
 #      %install_kernel_modules -m <modules> -d <directory>
 #
 # Options:
-#  -m <modules> (required) -- coma-separated list of modules to install,
+#  -m <modules> (required) -- comma-separated list of modules to install,
 #              without .ko extension, may be placed in subdirectory
 #  -d <directory> (required) -- in what subdirectory modules should be
 #              installed (eg. misc, kernel/drivers/net)
@@ -1190,4 +1272,43 @@ for MODULE in {%{-m*},}; do                                                                                      \
 done                                                                                                                           \
 %{nil}
 
+# patchset macros
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+#   %patchset_source -f <seq(1) format> <start> [<end>]
+#   %patchset_patch <start> [<end>]
+#
+# If <end> is omited, it is assumed to be <start>.
+#
+# For example in preamble:
+#  %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.0/7.0.%03g 33 44
+# and in %prep:
+#  %patchset_patch 33 44
+
+# generate SourceX urls from range START STOP
+# Format can be SINGLE format char of %e, %f, %g, see seq(1)
+# The sources start from 10000
+%patchset_source(f:b:) %(
+       base=%{-b*}%{!-b*:10000};
+       start=$((%1 + $base));
+       end=$((%{?2}%{!?2:%{1}} + $base));
+       # we need to call seq twice as it doesn't allow two formats
+       seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
+       seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
+       paste %{tmpdir}/__ps{1,2};
+       rm -f %{tmpdir}/__ps{1,2};
+) %{nil}
+
+# apply sources from %patchset_source
+# -p specify -pX for %patch line
+# -b base offset: defaults to 10000
+%patchset_patch(f:p:b:) %(
+       base=%{-b*}%{!-b*:10000};
+       start=$((%1 + $base));
+       end=$((%{?2}%{!?2:%{1}} + $base));
+       echo ": patchset_patch %1%{?2: to %2}";
+       seq -f 'patch%g %{-p*:-p%{-p*}}' $start $end | sed -e s,^,%%,;
+) %{nil}
+
 # vim:ts=4 sw=4 noet syn=spec
This page took 0.038091 seconds and 4 git commands to generate.