]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
- workaround date.timezone requirement in php 5.3, besides we ensure consistency...
[packages/rpm-build-macros.git] / rpm.macros
index 5c927710dae427470d506fdf396a44894e050912..5602a1485ee79ebfb89387a28c7422830e120490 100644 (file)
@@ -1,8 +1,13 @@
 # $Revision$, $Date$
-# PLD Linux rpm macros
+# 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%%?})
 
 %epoch         0
 %x8664         x86_64 amd64 ia32e
+%arm           armv3l armv4b armv4l armv5teb armv5tel
 
 # kernel compiler
 %kgcc          %{__cc}
 
 # add parallel build flags: -jN
 #
-# if you want to disable parallel build do (replace %% with %)
-# echo '%%_smp_mflags %%{nil}' >> ~/.rpmmacros
+# if you want to disable parallel build do:
+# echo '%_smp_mflags %{nil}' >> ~/.rpmmacros
 #
-%__make                make %{?_smp_mflags}
-%__scons       scons %{?_smp_mflags}
-%__waf         waf %{?_smp_mflags}
-%__cmake       cmake %{?_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))")
 %__intltoolize         intltoolize --copy --force
 %__libtoolize          libtoolize --copy --force --install
 
-#      Path to top of build area.
-%_topdir               %{expand:%%global _topdir %(test -d ../SPECS -a -d ../SOURCES && (cd ..; pwd) || echo $HOME/rpm)}%_topdir
+# topdir is where builder script lives,
+# fallback to old style if SPECS/SOURCES dirs were found.
+%_topdir    %{expand:%%global _topdir %(
+       if [ -d SPECS -a -d SOURCES ]; then
+               # old style rpmdir: in topdir
+               pwd
+       elif [ -d ../SPECS -a -d ../SOURCES ]; then
+               # old style rpmdir: in subdir
+               cd ..; pwd
+       elif [ -d $HOME/rpm/SPECS -a -d $HOME/rpm/SOURCES ]; then \
+               # if old style rpm dir exist, go with it
+               echo $HOME/rpm; \
+       elif [ -x ../builder -a ! -d ../builder ]; then
+               # relative new style rpmdir: in package dir
+               cd ..; pwd
+       elif [ -x builder -a ! -d builder ]; then
+               # relative new style rpmdir: in packages
+               pwd
+       elif [ -x packages/builder -a ! -d packages/builder ]; then
+               # relative new style rpmdir: packages dir in current dir
+               cd packages; pwd
+       else
+               # fallback to new style rpmdir
+               echo $HOME/rpm/packages
+       fi; \
+)}%_topdir
+
+# if %{_topdir}/SPECS exists, it's old style structure
+%_specdir       %{expand:%%global _specdir %([ ! -d %{_topdir}/SPECS ] && echo %{_topdir}/%{name} || echo %{_topdir}/SPECS)}%_specdir
+%_sourcedir            %{expand:%%global _sourcedir %([ ! -d %{_topdir}/SOURCES ] && echo %{_specdir} || echo %{_topdir}/SOURCES)}%_sourcedir
+
+# BUILD/RPMS/SRPMS are one same level by default as packages dir, if these exist
+# if they don't exist assume we are having custom topdir (which is not named as
+# "packages", i.e ~/rpm/kde/{kdelibs,BUILD/RPMS/SRPMS})
+# NOTE: readlink fails if some parent dir is not readable (/home/services/builder for example can't read /home/services), therfore the extra echo
+%_builddir             %{expand:%%global _builddir %(if [ -d %{_topdir}/BUILD ]; then echo %{_topdir}/BUILD; else readlink -m %{_topdir}/../BUILD || echo %{_topdir}/../BUILD; fi)}%_builddir
+%_rpmdir               %{expand:%%global _rpmdir %(if [ -d %{_topdir}/RPMS ]; then echo %{_topdir}/RPMS; else readlink -m %{_topdir}/../RPMS || echo readlink -m %{_topdir}/../RPMS; fi)}%_rpmdir
+%_srcrpmdir            %{expand:%%global _srcrpmdir %(if [ -d %{_topdir}/SRPMS ]; then echo %{_topdir}/SRPMS; else readlink -m %{_topdir}/../SRPMS || echo readlink -m %{_topdir}/../SRPMS; fi)}%_srcrpmdir
 
 #      The number of cvs changelog entries kept when building package.
 %_buildchangelogtruncate 20
        %{dependencytracking} \
 }
 
-%__cmake       /usr/bin/cmake
 %cmake { \
 CC="%{__cc}" \
 CXX="%{__cxx}" \
@@ -206,10 +246,10 @@ CFLAGS="%{rpmcflags}" \
 CXXFLAGS="%{rpmcxxflags}" \
 LDFLAGS="%{rpmldflags}" \
 %{__cmake} \
+-DCMAKE_INSTALL_PREFIX=%{_prefix} \
+-DCMAKE_BUILD_TYPE=%{!?debug:Release}%{?debug:Debug} \
 }
 
-# override __scons to add -j4 in your ~/.rpmmacros for parallel make
-%__scons       /usr/bin/scons
 %scons { \
 %{__scons} \
        LDFLAGS="${LDFLAGS:-%rpmldflags}" \
@@ -224,8 +264,6 @@ LDFLAGS="%{rpmldflags}" \
 }
 
 # waf. see waf.spec
-# override __waf to add -j4 in your ~/.rpmmacros for parallel make
-%__waf /usr/bin/waf
 %waf { \
 CC="%{__cc}" \
 CXX="%{__cxx}" \
@@ -268,6 +306,44 @@ CXXFLAGS="%{rpmcxxflags}" \
        %{?configure_cache:--cache-file=%{configure_cache_file}} \
 }
 
+# Simple macros to simplify adding bconded options to configure scripts.
+#   Each macro requires bcond name and accepts optional option name, if option
+# isn't specified bcond name is used as option name. Options returning
+# --with and --enable also allow third argument which will be added as value
+# ( --with-option=value or --enable-option=value ) in case or positive
+# condition, but won't be added otherwise ( nothing or just --disable-option ).
+
+# Requirements:
+# BuildRequires: rpmbuild(macros) >= 1.527
+
+# Usage example:
+# %{__enable bcond} - returns --enable-bcond iff build condition is set
+# %{__disable bcond option} - returns --enable-option iff bcond is not set
+# %{__enable_disable bcond option value} - returns --enable-option=value if
+#    bcond is set, returns --disable-option otherwise
+
+# expand bconds to --enable-something and --disable-something
+%__enable() %{expand:%%{?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
+%__disable() %{expand:%%{!?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
+%__enable_disable() %{expand:%%{?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{!?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
+
+# same as above, but condition inverted
+%__enable_unless() %{expand:%%{!?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
+%__disable_if() %{expand:%%{?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
+%__enable_disable_not() %{expand:%%{!?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
+
+# expand bconds to --with-something and --without-something
+%__with() %{expand:%%{?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
+%__without() %{expand:%%{!?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
+%__with_without() %{expand:%%{?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{!?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
+
+# same as above, but condition inverted
+%__with_unless() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
+%__without_if() %{expand:%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
+%__with_without_not() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
+
+#-----------------------------------------------------------------
+
 # overload to insert debuginfo package
 %prep \
 %if 0%{?_enable_debug_packages}\
@@ -277,7 +353,7 @@ CXXFLAGS="%{rpmcxxflags}" \
 %{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
@@ -321,16 +397,30 @@ CXXFLAGS="%{rpmcxxflags}" \
 # The directory holding Linux kernel sources
 %_kernelsrcdir /usr/src/linux%{_alt_kernel}
 
+# SysV-style initscripts dir
+%_initddir             /etc/rc.d/init.d
+
 # 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}
 
-%releq_kernel                  %{expand:%%global releq_kernel %(R=$(LC_ALL=C rpm -q --qf '%{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               %{expand:%%global releq_kernel_up %(R=$(LC_ALL=C rpm -q --qf '%{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()            %{expand:%%global releq_kernel_smp %(R=$(LC_ALL=C rpm -q --qf '%{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
-%requires_releq_kernel(s:)             Requires%{-s:(%{-s*})}: %releq_kernel
-%requires_releq_kernel_up(s:)  Requires%{-s:(%{-s*})}: %releq_kernel_up
-%requires_releq_kernel_smp(s:) Requires%{-s:(%{-s*})}: %releq_kernel_smp
+# -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
+
+# -s post to generate Requires(post) dependency
+%requires_releq_kernel(s:n:)           Requires%{-s:(%{-s*})}: %releq_kernel
+%requires_releq_kernel_up(s:n:)                Requires%{-s:(%{-s*})}: %releq_kernel_up
+%requires_releq_kernel_smp(s:n:)       Requires%{-s:(%{-s*})}: %releq_kernel_smp
 
 # Requires name = version-release
 %requires_releq()      %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to -r %1 %1}}}
@@ -339,11 +429,16 @@ 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
 %__kernel_ver   %{expand:%%global __kernel_ver %( \\
-       Z=$(awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/linux/{version,utsrelease}.h 2>/dev/null); \\
+       Z=$([ -f '%{_kernelsrcdir}/include/generated/utsrelease.h' ] && awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/{linux/version,generated/utsrelease}.h 2>/dev/null || awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/linux/{version,utsrelease}.h 2>/dev/null); \\
        Z=${Z:-$(awk -F' = ' '/^VERSION/{v=$2} /^PATCHLEVEL/{p=$2} /^SUBLEVEL/{s=$2} /^EXTRAVERSION/{e=$2} END {printf("%d.%d.%d%s", v, p, s, e)}' %{_kernelsrcdir}/Makefile 2>/dev/null)}; \\
        echo ${Z:-ERROR}; \\
 )}%__kernel_ver
@@ -535,6 +630,8 @@ if [ -d "$RPM_BUILD_ROOT" ]; then \
        fi; \
 fi; }; __spec_install_post_chrpath } } }
 
+# vim: "
+
 #-----------------------------------------------------------------
 # Find all shared object files with unresolved symbols. Warn
 # and terminate if any found (termination can be turned off by define).
@@ -710,6 +807,7 @@ fi; \
 
 # extract php/zend api versions
 %php_major_version             %{expand:%%global php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)}%php_major_version
+%php_minor_version             %{expand:%%global php_minor_version %(awk '/#define PHP_MINOR_VERSION/{print $3}' %{php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)}%php_minor_version
 %php_api_version               %{expand:%%global php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{php_includedir}/main/php.h 2>/dev/null || echo ERROR)}%php_api_version
 %php_pdo_api_version   %{expand:%%global php_pdo_api_version %(awk '/#define PDO_DRIVER_API/{print $3}' %{php_includedir}/ext/pdo/php_pdo_driver.h 2>/dev/null || echo ERROR)}%php_pdo_api_version
 %php_debug                             %{expand:%%global php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)}%php_debug
@@ -772,6 +870,7 @@ fi \
 %xorg_xserver_font_abi         %{expand:%%global xorg_xserver_font_abi %(awk '/#define ABI_FONT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null | echo ERROR)}%xorg_xserver_font_abi
 %xorg_xserver_videodrv_abi     %{expand:%%global xorg_xserver_videodrv_abi %(awk '/#define ABI_VIDEODRV_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_videodrv_abi
 %xorg_xserver_xinput_abi       %{expand:%%global xorg_xserver_xinput_abi %(awk '/#define ABI_XINPUT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_xinput_abi
+# vim: '
 
 %requires_xorg_xserver_extension \
 %{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \
@@ -830,7 +929,7 @@ fi \
 
 # Python 3.x
 # python main version
-%__python3                     python3.0
+%__python3                     python3
 %py3_ver                       %{expand:%%global py3_ver %(%{__python3} -c "import sys; print(sys.version[:3])" 2>/dev/null || echo ERROR)}%py3_ver
 
 # directories
@@ -905,7 +1004,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/')}%_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
 #
@@ -1008,6 +1107,7 @@ else \
                %{expand:%{%{#}}} 1>&2 || exit $? \
        [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : \
 fi;
+# vim: "
 
 # Usage:
 #   %groupadd [-P package] [-g gid] group
@@ -1044,11 +1144,11 @@ fi;
 #
 # Add package's webserver config to webserver webapps dir.
 # Usage:
-#   %webapp_register WEBSERVER WEBAPP
+#   %webapp_register [-f] WEBSERVER WEBAPP
 #
-%webapp_register() \
+%webapp_register(f) \
 %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
-if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
+if [ -n "%{-f:1}" ] || [ "$1" = "1" ] && [ "$2" = "1" ]; then\
        /usr/sbin/webapp register %1 %2\
 fi\
 # reload webserver if the config symlink is there and skip reload if webserver is upgraded\
@@ -1122,11 +1222,25 @@ fi \
 # Directory where arch-specific (JNI) version-independent jars are installed.
 %_jnidir               %{_libdir}/java
 
-%java_home             %{expand:%%global java_home %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVA_HOME; . %{_javadir}-utils/java-functions; set_jvm; echo ${JAVA_HOME:-ERROR})}%java_home
+
+# JDK selection. Set this to name of the JDK implementation to use
+# insead of the system default
+#%use_jdk              icedtea6
+
+# expands to the value with right jdk for BuildRequires header
+# 'jdk' if %%use_jdk is not defined,  jdk(%%use_jdk) otherwise
+# The requirement will not replace current 'default' JDK
+%required_jdk  jdk%{?use_jdk:(%{use_jdk})}
+
+%buildrequires_jdk BuildRequires: %required_jdk
+
+%java_home             %{expand:%%global java_home %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; %{!?use_jdk:unset JAVA_HOME; . %{_javadir}-utils/java-functions; set_jvm}%{?use_jdk:JAVA_HOME=%{_jvmdir}/%{use_jdk}}; echo ${JAVA_HOME:-ERROR})}%java_home
+
+%_javasrcdir   %{_usrsrc}/java
 
 %ant                   JAVA_HOME=%{java_home} CLASSPATH=$CLASSPATH ant
 %jar                   %{java_home}/bin/jar
-%java                  %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd; echo $JAVACMD)}%java
+%java                  %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; %{!?use_jdk:unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd}%{?use_jdk:JAVACMD=%{java_home}/bin/java}; echo $JAVACMD)}%java
 %javac                 %{java_home}/bin/javac
 %javadoc               %{java_home}/bin/javadoc
 
@@ -1215,6 +1329,24 @@ cat %{_mavendepmapfragdir}/* >> %{_mavendepmapdir}/maven2-depmap.xml\
 fi\
 echo -e "</dependencies>\\n" >> %{_mavendepmapdir}/maven2-depmap.xml
 
+# JAVA macros specific for PLD
+
+# Directory for tomcat context configuration files
+%_tomcatconfdir        %{_sharedstatedir}/tomcat/conf/Catalina/localhost
+
+# Tomcat cache path
+%_tomcatcachedir %{_sharedstatedir}/tomcat/work/Catalina/localhost
+
+# Clear tomcat cache
+# Author: Paweł Zuzelski <pawelz@pld-linux.org>
+#
+# Usage:
+# %%tomcat_clear_cache appname
+#
+# Call this script in %postun scriptlet. It will remove compiled jsps related to
+# given app.
+#
+%tomcat_clear_cache() %{!?1:ERROR}%{?2:ERROR} %{__rm} -rf %{_tomcatcachedir}/%1
 
 # PEAR install macros
 # Author: Elan Ruusamäe <glen@pld-linux.org>
@@ -1227,6 +1359,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
@@ -1248,7 +1381,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 \
@@ -1256,10 +1389,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 \\\
@@ -1268,6 +1402,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 \\\
@@ -1281,7 +1416,7 @@ 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} \
@@ -1416,10 +1551,15 @@ for cfg in ${cfgs:-dist}; do                                        \
        [ -r "%{_kernelsrcdir}/config-$cfg" ] || exit 1                                 \
                                                                                                                                        \
        rm -rf o                                                                                                                \
-       install -d o/include/linux o/arch/powerpc/lib                                   \
+       install -d o/include/linux o/include/generated o/arch/powerpc/lib       \
        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 \
+       if [ -f %{_kernelsrcdir}/include/generated/autoconf-$cfg.h ]; then      \
+               ln -sf %{_kernelsrcdir}/include/generated/autoconf-$cfg.h o/include/generated/autoconf.h \
+               ln -s ../generated/autoconf.h o/include/linux/autoconf.h \
+       else                                                                                                                    \
+               ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \
+       fi                                                                                                                              \
                                                                                                                                        \
        set +x                                                                                                                  \
        [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell    \
@@ -1684,4 +1824,125 @@ else: \
 }; __py_lint %* \
 %{nil}
 
-# vim:ts=4 sw=4 noet syn=spec
+# 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.565
+
+# 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.
+#
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+#  -a NAME  -- add command named NAME
+#  -d NAME  -- remove command named NAME
+#  -f FILE  -- specify plugin configuration FILE to extract command definition from
+#
+# Sample:
+# %triggerin -- nagios-nrpe
+# %nagios_nrpe -a %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
+#
+# %triggerun -- nagios-nrpe
+# %nagios_nrpe -d %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
+#
+# Requirements:
+# Requires:                    grep
+# Requires:                    sed >= 4.0
+# BuildRequires:       rpmbuild(macros) >= 1.552
+%nagios_nrpe(a:d:c:f:) {\
+       m=$(md5sum < /etc/nagios/nrpe.cfg); \
+       %{-a:# on -a and config exists \
+       if [ -f /etc/nagios/nrpe.cfg ]; then \
+               if ! %{__grep} -q '^command\[%{-a*}\]' /etc/nagios/nrpe.cfg; then \
+                               %{__sed} -ne 's/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p' %{-f*} >> /etc/nagios/nrpe.cfg; \
+               fi; \
+       fi;} \
+       %{-d:# on package remove, -d and config exists \
+       if [ "$1" = "0" -a -f /etc/nagios/nrpe.cfg ]; then \
+               %{__sed} -i -e '/^[ \t]*command\[%{-d*}\]/d' /etc/nagios/nrpe.cfg; \
+       fi;} \
+       if [ "$m" != "$(md5sum < /etc/nagios/nrpe.cfg)" ]; then \
+               %service -q nrpe restart; \
+       fi; \
+}%{nil}
+
+# Import or update Cacti template.
+#
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+# %cacti_import_template XMLFILE
+#  XMLFILE -- XML template to import
+#
+# Sample:
+# %post
+# %cacti_import_template %{resourcedir}/cacti_host_template_varnish.xml
+#
+# Requires:    cacti >= 0.8.7e-8
+# BuildRequires:       rpmbuild(macros) >= 1.554
+
+%cacti_import_template() {\
+/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.245521 seconds and 4 git commands to generate.