]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
- added %_tomcatcachedir and %tomcat_clear_cache() macros
[packages/rpm-build-macros.git] / rpm.macros
index ccb48b64f0f97c44d382009c5bd656a746da2706..032ae47943f6c3fb6efb05e585881b2a70ef13d3 100644 (file)
@@ -2,6 +2,9 @@
 # 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
 
 %__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
@@ -367,9 +406,9 @@ CXXFLAGS="%{rpmcxxflags}" \
 %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:)             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
+%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}}}
@@ -751,6 +790,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
@@ -1258,6 +1298,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 tomcat. 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>
@@ -1727,4 +1785,18 @@ else: \
 }; __py_lint %* \
 %{nil}
 
+# Undos files
+#
+# Author: Paweł Zuzelski <pawelz@pld-linux.org>
+#
+# Usage:
+#   %undos list_of_files
+#
+# Requirements:
+# BuildRequires:       sed >= 4.0
+# BuildRequires:       rpmbuild(macros) >= 1.533
+
+%undos \
+%{__sed} -i -e 's,\\r$,,'
+
 # vim:ts=4 sw=4 noet ft=spec
This page took 0.742291 seconds and 4 git commands to generate.