]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
ruby: do not use deprecated Config::CONFIG
[packages/rpm-build-macros.git] / rpm.macros
index 61da454de3e65552aade7bb90b90dca3585fd503..7d85bb5e3cad60706558c662d8e8455ae191209f 100644 (file)
@@ -30,7 +30,7 @@
 #
 # if you want to disable parallel build do:
 # echo '%__jobs %{nil}' >> ~/.rpmmacros
-%__jobs                %{expand:%%global __jobs %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); [ "$_NCPUS" -gt 2 ] && echo $(($_NCPUS / 2)))}%__jobs
+%__jobs                %{expand:%%global __jobs %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); [ "$_NCPUS" -gt 3 ] && echo $(($_NCPUS / 2)))%%{nil}}%__jobs
 
 # expands to -jN if %__jobs has a value
 %_smp_mflags   %{expand:%%global _smp_mflags %(jobs=%{__jobs}; echo ${jobs:+-j$jobs}%%{nil})}%_smp_mflags
@@ -631,7 +631,7 @@ if [ -d "$RPM_BUILD_ROOT" ]; then \
 fi; }; __spec_install_post_strip } } }
 
 #-----------------------------------------------------------------
-# remove all RPATH from executable binaries and shared object files
+# remove all RPATH/RUNPATH from executable binaries and shared object files
 #
 # Requires: find, awk, cut, xargs, chrpath, uname
 #
@@ -648,12 +648,12 @@ if [ -d "$RPM_BUILD_ROOT" ]; then \
                objs=`echo "$files" | xargs -r -d'\\n' file | awk -F: '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}'`; \
        fi; \
        if [ -n "$objs" ]; then \
-               printf "Remove RPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
+               printf "Remove RPATH/RUNPATH from %d executable binaries and shared object files.\n" $(echo "$objs" | wc -l); \
                echo "$objs" | \
                while read file; do \
                        rpath= ; \
                        chmod u+w "$file"; \
-                       for dir in $(chrpath -l "$file" | awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'); do \
+                       for dir in $(chrpath -l "$file" | awk '/R(|UN)PATH=/ { gsub(/.*RPATH=/,""); gsub(/.*RUNPATH=/,""); gsub(/:/," "); print $0 }'); do \
                                        case $dir in \
                                        '$ORIGIN' ) \
                                                if [ "$rpath" = "" ] ; then rpath="$dir" ; \
@@ -897,18 +897,18 @@ fi; \
 # Ruby
 %__ruby                                /usr/bin/ruby
 
-%ruby_archdir          %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir
-%ruby_libdir           %{expand:%%global ruby_libdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_libdir
+%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 Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir
-%ruby_vendorarchdir    %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir
-%ruby_vendorlibdir     %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir
-%ruby_sitearchdir      %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir
-%ruby_sitedir          %{expand:%%global ruby_sitedir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitedir"]' 2>/dev/null || echo ERROR)}%ruby_sitedir
-%ruby_sitelibdir       %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir
+%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
 %ruby_rdocdir          /usr/share/rdoc
-%ruby_vendordir                %{expand:%%global ruby_vendordir %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["vendordir"]' 2>/dev/null || echo ERROR)}%ruby_vendordir
-%ruby_version          %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version
+%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_ver_requires_eq  Requires:       ruby(ver) = %ruby_version
 %ruby_mod_ver_requires_eq      Requires:       ruby-modules(ver) = %ruby_version
@@ -1077,9 +1077,9 @@ fi \
 %__spec_install_post_py_hardlink {\
 %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
 %{!?debug:set +x;} \
-local a b c=0 t=0; \
+local a b c=0 t=0 pyc=%{tmpdir}/%{name}-%{version}-%{release}__rpm_pyc; \
 if [ -d "$RPM_BUILD_ROOT" ]; then \
-       find "$RPM_BUILD_ROOT" -name '*.pyc' > __rpm_pyc; \
+       find "$RPM_BUILD_ROOT" -name '*.pyc' > $pyc; \
        while read a; do \
                b="${a%.pyc}.pyo"; \
                if cmp -s "$a" "$b"; then \
@@ -1087,16 +1087,25 @@ if [ -d "$RPM_BUILD_ROOT" ]; then \
                        c=$((c + 1)); \
                fi; \
                t=$((t + 1)); \
-       done < __rpm_pyc; \
+       done < $pyc; \
        [ $t -gt 0 ] && printf "Hardlink Python files: %d/%d files hardlinked\n" $c $t; \
-       rm -f __rpm_pyc; \
+       rm -f $pyc; \
 fi; \
 }; __spec_install_post_py_hardlink } }
 
-# remove python sources, so that check-files won't complain
-%py_postclean() \
+# Remove Python 2.x sources,
+# PLD Linux policy is to package only compiled .py[co] for Python 2.x libraries.
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+# %py_postclean /usr/share/extra -x keepme.py,keeptoo.py
+# Options:
+# -x - comma separated of file basenames to preserve
+# ARGS - extra directories to clean for .py sources
+#
+%py_postclean(x:) \
 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
[ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
      [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 %{-x:| grep -ZzvE '/(%(echo '%{-x*}' | tr ',' '|'))$'} | xargs -0r -l512 rm;\
 done \
 %{nil}
 
@@ -1806,18 +1815,18 @@ fi                                                                                      \
 %define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \
                                                                                                                                        \
 __install_kernel_modules() {                                                                           \
-%{!?debug:set +x;} \
+%{!?debug:set +x;}                                                                                                     \
                                                                                                                                        \
 for MODULE in {%{-m*},}; do                                                                                    \
        [ -n "${MODULE}" ] || continue                                                                  \
-       MNAME=${MODULE##*/}                                                                                     \
-       install -D ${MODULE}.ko %{KernelD}/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko      \
-       %{?-s:install -d %{ModprobeD}                                                   \
+       MNAME=${MODULE##*/}                                                                                             \
+       install -m 644 -D ${MODULE}.ko %{KernelD}/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko       \
+       %{?-s:install -d %{ModprobeD}                                                                   \
                echo "alias ${MNAME} ${MNAME}-%{-s*}" >> %{ModprobeD}/%{-n*}.conf}      \
 done                                                                                                                           \
 }                                                                                                                                      \
 __install_kernel_modules_old() {                                                                       \
-%{!?debug:set +x;} \
+%{!?debug:set +x;}                                                                                                     \
 local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
                                                                                                                                        \
 for MODULE in {%{-m*},}; do                                                                                    \
@@ -1825,7 +1834,7 @@ for MODULE in {%{-m*},}; do                                                                                       \
        for cfg in ${cfgs:-dist}; do                                    \
                [ "$cfg" = smp ] && suf=smp || suf=                                                     \
                MNAME=${MODULE##*/}                                                                                     \
-               install -D ${MODULE}-$cfg.ko                                                            \\\
+               install -m 644 -D ${MODULE}-$cfg.ko                                                     \\\
                        %{KernelD}$suf/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko                  \
                %{?-s:install -d %{ModprobeD}$suf                                                       \
                        echo "alias ${MNAME} ${MNAME}-%{-s*}"                                   \\\
@@ -1833,11 +1842,11 @@ for MODULE in {%{-m*},}; do                                                                                     \
        done                                                                                                                    \
 done                                                                                                                           \
 }                                                                                                                                      \
-if [ -r "%{_kernelsrcdir}/.config" ]; then     \
-       __install_kernel_modules                                \
-else                                                                           \
-       __install_kernel_modules_old                    \
-fi                                                                                     \
+if [ -r "%{_kernelsrcdir}/.config" ]; then                                                     \
+       __install_kernel_modules                                                                                \
+else                                                                                                                           \
+       __install_kernel_modules_old                                                                    \
+fi                                                                                                                                     \
 %{nil}
 
 # patchset macros
This page took 0.069396 seconds and 4 git commands to generate.