]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
ruby: add %__ruby_rbconfig to simplify other ruby macros
[packages/rpm-build-macros.git] / rpm.macros
index b7370d9b5b6d4b301c69e0e32362cd0e334bbcb1..68441a24747bea42248bd83ec982b574526f6b19 100644 (file)
 %_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
+# BUILD/RPMS/SRPMS are on 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
+# NOTE: readlink fails if some parent dir is not readable (/home/services/builder for example can't read /home/services), therefore 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
@@ -924,18 +924,21 @@ fi; \
 # Ruby
 %__ruby                                /usr/bin/ruby
 
-%ruby_archdir          %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir
-%ruby_libdir           %{expand:%%global ruby_libdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_libdir
-%ruby_ridir                    %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)}%ruby_ridir
-%ruby_rubylibdir       %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir
-%ruby_vendorarchdir    %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir
-%ruby_vendorlibdir     %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir
-%ruby_sitearchdir      %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir
-%ruby_sitedir          %{expand:%%global ruby_sitedir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitedir"]' 2>/dev/null || echo ERROR)}%ruby_sitedir
-%ruby_sitelibdir       %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
+# get rbconfig parameter
+%__ruby_rbconfig()     %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["%1"]' 2>/dev/null || echo ERROR)
+
+%ruby_archdir          %{expand:%%global ruby_archdir %{__ruby_rbconfig archdir}}%ruby_archdir
+%ruby_libdir           %{expand:%%global ruby_libdir %{__ruby_rbconfig rubylibdir}}%ruby_libdir
+%ruby_ridir                    %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'print File.join(RbConfig::CONFIG["datadir"], "ri", RbConfig::CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)}%ruby_ridir
+%ruby_rubylibdir       %{expand:%%global ruby_rubylibdir %{__ruby_rbconfig rubylibdir}}%ruby_rubylibdir
+%ruby_vendorarchdir    %{expand:%%global ruby_vendorarchdir %{__ruby_rbconfig vendorarchdir}}%ruby_vendorarchdir
+%ruby_vendorlibdir     %{expand:%%global ruby_vendorlibdir %{__ruby_rbconfig vendorlibdir}}%ruby_vendorlibdir
+%ruby_sitearchdir      %{expand:%%global ruby_sitearchdir %{__ruby_rbconfig sitearchdir}}%ruby_sitearchdir
+%ruby_sitedir          %{expand:%%global ruby_sitedir %{__ruby_rbconfig sitedir}}%ruby_sitedir
+%ruby_sitelibdir       %{expand:%%global ruby_sitelibdir %{__ruby_rbconfig sitelibdir}}%ruby_sitelibdir
 %ruby_rdocdir          /usr/share/rdoc
-%ruby_vendordir                %{expand:%%global ruby_vendordir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendordir"]' 2>/dev/null || echo ERROR)}%ruby_vendordir
-%ruby_version          %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version
+%ruby_vendordir                %{expand:%%global ruby_vendordir %{__ruby_rbconfig vendordir}}%ruby_vendordir
+%ruby_version          %{expand:%%global ruby_version %{__ruby_rbconfig ruby_version}}%ruby_version
 
 %ruby_gemdir           %{expand:%%global ruby_gemdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["rubylibdir"].sub(RbConfig::CONFIG["ruby_version"], "gems/#{RbConfig::CONFIG["ruby_version"]}")' 2>/dev/null || echo ERROR)}%{ruby_gemdir}
 %ruby_specdir          %{ruby_gemdir}/specifications
@@ -1143,9 +1146,11 @@ fi; \
 # Usage:
 # %py_postclean /usr/share/extra -x keepme.py,keeptoo.py
 # Options:
-# -x - comma separated of file basenames to preserve
+# -x - comma separated of file basenames to preserve (rpmbuild(macros) >= 1.658)
 # ARGS - extra directories to clean for .py sources
 #
+# BuildRequires:       rpmbuild(macros) >= 1.189
+#
 %py_postclean(x:) \
 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
        [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 %{-x:| grep -ZzvE '/(%(echo '%{-x*}' | tr ',' '|'))$'} | xargs -0r -l512 rm;\
@@ -2260,6 +2265,7 @@ fi; \
 # pre/post script for -upstart subpackages
 #
 # Author: Jacek Konieczny <jajcus@jajcus.net>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #      %upstart_post service_name
@@ -2273,15 +2279,16 @@ fi; \
 # %upstart_postun %{name}
 #
 # Requirements:
-# BuildRequires:       rpmbuild(macros) >= 1.560
+# BuildRequires:       rpmbuild(macros) >= 1.690
 # Requires:                    rc-scripts >= 0.4.3
 
 # migrate from init script to upstart job
 %upstart_post() \
-       if [ -f /var/lock/subsys/%1 ]; then \
+       if [ -x /sbin/initctl ] && [ -f /var/lock/subsys/%1 ]; then \
                /sbin/service --no-upstart %1 stop \
                /sbin/service %1 start \
-       fi
+       fi \
+%{nil}
 
 # 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
@@ -2290,7 +2297,8 @@ fi; \
        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
+       fi \
+%{nil}
 
 # Haskell Macros
 # BuildRequires:  rpmbuild(macros) >= 1.608
@@ -2421,4 +2429,15 @@ want_enable_service() { \
 %systemduserunitdir /usr/lib/systemd/user
 %systemdtmpfilesdir /usr/lib/tmpfiles.d
 
+#-----------------------------------------------------------------
+# Update hardware database index
+#
+# Requirements:
+# BuildRequires:       rpmbuild(macros) >= 1.691
+# Requires:            udev-core >= 1:196
+
+%udev_hwdb_update() \
+/sbin/udevadm hwdb --update >/dev/null 2>&1 || : \
+%{nil}
+
 # EOF
This page took 0.042515 seconds and 4 git commands to generate.