]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
- bump ver to 1.676
[packages/rpm-build-macros.git] / rpm.macros
index 6602b97b1d02d9637ab9a690ad27963517da3902..f02cb32f5e5069455730bfc07fea09c3e39a207a 100644 (file)
 %x8664         x86_64 amd64 ia32e
 %arm           armv3l armv4b armv4l armv5teb armv5tel
 
-# kernel compiler
-%kgcc          %{__cc}
-%kgcc_package  gcc
-
 # compiler version
 %cc_version    %{expand:%%global cc_version %(%{__cc} -dumpversion 2>/dev/null || echo 0.0)}%cc_version
 %cxx_version   %{expand:%%global cxx_version %(%{__cxx} -dumpversion 2>/dev/null || echo 0.0)}%cxx_version
 %__autopoint   autopoint --force
 
 # add parallel build flags: -jN
+# jobs macro is available since 1.657
 #
 # if you want to disable parallel build do:
-# echo '%_smp_mflags %{nil}' >> ~/.rpmmacros
-#
+# echo '%__jobs %{nil}' >> ~/.rpmmacros
+%__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
+
 %__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 2 ] && echo "-j$(($_NCPUS / 2))")
-
 %__gettextize { \
        if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
                gettextize --copy --force --no-changelog; \
 %_preserve_env_base    PATH HOME TMP TMPDIR SSH_AUTH_SOCK
 
 # "env -i" must end in first line of expaned macros because it's used as first line of shell script (#! env...)
-%_clean_env            %{!?_preserve_env:%global _preserve_env %{nil}}%{expand:%%global _preserve_env %{_preserve_env} %_preserve_env_base} env -i %(awk -vq="'" -vqq="\\"'\\"" -vq2q="'\\"'" 'BEGIN {
-       split("%{?_preserve_env}", P);
+%_clean_env env -i %(awk -vq="'" -vqq="\\"'\\"" -vq2q="'\\"'" 'BEGIN {
+       split("%{?_preserve_env:%_preserve_env %_preserve_env_base}%{!?_preserve_env:%_preserve_env_base}", P);
        for (i in P) {
                p = P[i];
                if (!ENVIRON[p] || d[p]) {
 }
 
 %cmake \
-%{?__cc:CC="%{__cc}"} \\\
-%{?__cxx:CXX="%{__cxx}"} \\\
+%{?__cc:CC="${CC:-%{__cc}}"} \\\
+%{?__cxx:CXX="${CXX:-%{__cxx}}"} \\\
 CPPFLAGS="${CPPFLAGS:-%{rpmcppflags}}" \\\
 %{__cmake} \\\
        -DCMAKE_VERBOSE_MAKEFILE=ON \\\
@@ -406,12 +404,6 @@ CXXFLAGS="%{rpmcxxflags}" \
 # Example files, programs, scripts...
 %_examplesdir  /usr/src/examples
 
-# Alternative kernel type/version
-%_alt_kernel   %{nil}%{?alt_kernel:-%{?alt_kernel}}
-
-# The directory holding Linux kernel sources
-%_kernelsrcdir /usr/src/linux%{_alt_kernel}
-
 # SysV-style initscripts dir
 %_initddir             /etc/rc.d/init.d
 
@@ -427,16 +419,44 @@ CXXFLAGS="%{rpmcxxflags}" \
 # 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}
 
+# Alternative kernel type/version
+%_alt_kernel   %{nil}%{?alt_kernel:-%{?alt_kernel}}
+
+# The directory holding Linux kernel sources
+%_kernelsrcdir /usr/src/linux%{_alt_kernel}
+
+# rpm -qf on kernel version.h file
+%__kernel_qf()         %(R=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -q --qf '%*' -f include/linux/version.h 2>/dev/null | grep -v 'is not'); echo ${R:-ERROR})
+
+# kernel %{name} and kernel %{epoch}:%{version}-%{release} macro respecing alt_kernel
+%kernel_name   %(N=%{__kernel_qf %{N}}; echo ${N%%-headers})
+%kernel_version        %{__kernel_qf %|E?{%{E}:}|%{V}-%{R}}
+
 # -n drm to generate kernel%{_alt_kernel}-drm dependency
-%releq_kernel(n:)              %{expand:%%global releq_kernel %(R=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}} = %|E?{%{E}:}|%{V}-%{R}' -f 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=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}}-up = %|E?{%{E}:}|%{V}-%{R}' -f 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=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-n*}}-smp = %|E?{%{E}:}|%{V}-%{R}' -f include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})}%releq_kernel_smp
+%releq_kernel(n:)              %{kernel_name}%{?-n:-%{-n*}} = %{kernel_version}
+%releq_kernel_up(n:)   %{kernel_name}-up%{?-n:-%{-n*}} = %{kernel_version}
+%releq_kernel_smp(n:)  %{kernel_name}-smp%{?-n:-%{-n*}} = %{kernel_version}
 
 # -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
 
+# kernel version-release handling
+%__kernel_ver   %( \\
+       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_rel  %{__kernel_qf %{R}}
+%__kernel_rpmvr        %{__kernel_qf %{V}-%{R}}
+%_kernel_ver   %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
+%_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
+
+# `uname -r` to be used in @release field
+%_kernel_vermagic      %(echo %{_kernel_ver} | sed -e 's/-/_/g')
+
 # Requires name = version-release
 %requires_releq()      %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to -r %1 %1}}}
 # Requires: name = version
@@ -457,21 +477,6 @@ Provides: %{1} = %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}
 
 %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=$([ -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
-
-%__kernel_rel  %{expand:%%global __kernel_rel %(Z=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -qf include/linux/fs.h 2>/dev/null --qf "%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rel
-%__kernel_rpmvr        %{expand:%%global __kernel_rpmvr %(Z=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -qf include/linux/fs.h 2>/dev/null --qf "%{V}-%{R}" | grep -v "is not"); echo ${Z:-ERROR})}%__kernel_rpmvr
-%_kernel_ver   %{expand:%%global _kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}}%_kernel_ver
-%_kernel_ver_str %{expand:%%global _kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')}%_kernel_ver_str
-
-# `uname -r` to be used in @release field
-%_kernel_vermagic      %{expand:%%global _kernel_vermagic %(echo %{_kernel_ver} | sed -e 's/-/_/g')}%_kernel_vermagic
-
 # sgml macros
 %xmlcat_add()          /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
 %xmlcat_del()          /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
@@ -534,13 +539,13 @@ Provides: %{1} = %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}
                                echo ".so $l" > $a; \
                                echo >&2 "Converted ${a#$RPM_BUILD_ROOT} from symlink to man link: $l"; \
                        done; \
-                       # verify that .so links point to existing files (not allowed to point to "other package")
+                       # verify that .so links point to existing files (not allowed to point to "other package") \
+                       # TODO: iterate over all man dirs, but in Th there is only one true man dir \
                        err=$(grep -rl '^\.so ' "$RPM_BUILD_ROOT$i" | while read doc; do \
-                               l=$(cat "$doc"); \
+                               l=$(grep -r '^\.so ' "$doc"); \
                                l=${l#.so }; \
                                d=$(dirname $doc); \
-                               # TODO: iterate over all man dirs, but in Th there's only one true man dir \
-                               test -e $RPM_BUILD_ROOT$i/$l || test -e $d/$l || echo "  ${doc#$RPM_BUILD_ROOT} points to inexistent manpage: $l"; \
+                               test -e $RPM_BUILD_ROOT$i/$l || test -e $d/$(basename $l) || echo "  ${doc#$RPM_BUILD_ROOT} points to inexistent manpage: $l"; \
                        done); \
                        test "$err" != "" && { echo >&2 "Man page link errors:"; echo >&2 "$err"; exit 1; }; \
                        find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
@@ -629,7 +634,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
 #
@@ -646,12 +651,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|RUN)PATH=/ { gsub(/.*RPATH=/,""); gsub(/.*RUNPATH=/,""); gsub(/:/," "); print $0 }'); do \
                                        case $dir in \
                                        '$ORIGIN' ) \
                                                if [ "$rpath" = "" ] ; then rpath="$dir" ; \
@@ -858,6 +863,7 @@ fi; \
        %{?_noautoreq: %{_noautoreq}} \
        %{?_noautoreq_pear: %{__noauto_regexp_helper -p pear %{_noautoreq_pear}}} \
        %{?_noautoreq_perl: %{__noauto_regexp_helper -p perl %{_noautoreq_perl}}} \
+       %{?_noautoreq_java: %{__noauto_regexp_helper -p java %{_noautoreq_java}}} \
        %{nil}
 
 # helper for wrapping _noautoreq between perl() or pear()
@@ -866,6 +872,8 @@ fi; \
 # BuildRequires:       rpmbuild(macros) >= 1.654
 # %define _noautoreq_pear Excluded.php PEAR/Something.php
 # %define _noautoreq_perl Apache::.*
+# BuildRequires:       rpmbuild(macros) >= 1.672
+# %define _noautoreq_java ClassDataVersion
 %__noauto_regexp_helper(p:) %(echo "%*" | awk 'BEGIN{RS=" "}{printf("%{-p*}\\\\\\(%%s\\\\\\) ", $1)}')
 
 #%_noautocompressdoc   %{nil}
@@ -894,15 +902,24 @@ 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_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_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_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_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
+
+# deprecated, similar functionality autogenerated with rpm5
 %ruby_ver_requires_eq  Requires:       ruby(ver) = %ruby_version
 %ruby_mod_ver_requires_eq      Requires:       ruby-modules(ver) = %ruby_version
 
@@ -928,7 +945,10 @@ fi; \
 %php_name                              php%{?php_suffix}
 # use rpmbuild -D 'php_suffix 54' to build php extension for php 5.4
 # NOTE: error output must be empty. otherwise can't build pecl packages if no php*-devel is installed
-%php_suffix             %(c=$(php-config --sysconfdir 2>/dev/null) || echo '' && echo ${c#/etc/php})
+%php_suffix                            %{expand:%%global php_suffix %(c=$(php-config --sysconfdir 2>/dev/null) || echo '' && echo ${c#/etc/php})%%{nil}}%php_suffix
+
+# php cli. version that php headers are installed for
+%__php                                 /usr/bin/%{php_name}
 
 # helper macro
 %__php_api_requires(v:) Requires: %{php_name}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
@@ -1066,13 +1086,19 @@ fi \
 # BuildRequires: rpmbuild(macros) >= 1.634
 %nodejs_libdir         /usr/lib/node_modules
 
+# bash-completion 2.0 completions dir
+# Requirements:
+# BuildRequires: rpmbuild(macros) >= 1.673
+# Requires:    bash-completion >= 2.0
+%bash_compdir          /usr/share/bash-completion/completions
+
 # Hardlink binary identical .pyc and .pyo files
 %__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 \
@@ -1080,16 +1106,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}
 
@@ -1578,6 +1613,7 @@ fi \
 f = io.open("%{_docdir}/%{name}-%{version}/optional-packages.txt", "r") \
 if f then \
        for l in f:lines() do print(l); end \
+       f:close() \
 end \
 %{nil}
 
@@ -1799,18 +1835,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                                                                                    \
@@ -1818,7 +1854,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*}"                                   \\\
@@ -1826,11 +1862,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
@@ -1938,7 +1974,11 @@ end\
 for _, s in ipairs({%{expand:%%__lua_split %*}}) do\
        if not t[s] then\
                print("Adding "..s.." to /etc/shells")\
-               f = io.open("/etc/shells", "a"); f:write(s.."\\n"); f:close()\
+               f = io.open("/etc/shells", "a")\
+               if f then\
+                       f:write(s.."\\n")\
+                       f:close()\
+               end\
        end\
 end\
 %{nil}
@@ -1958,7 +1998,11 @@ s=""\
 for _, l in pairs(t) do\
        s=s..l.."\\n"\
 end\
-io.open("/etc/shells", "w"):write(s)\
+f = io.open("/etc/shells", "w")\
+if f then\
+       f:write(s)\
+       f:close()\
+end\
 %{nil}
 
 # Backwards compat. Use of %lua_ prefixed macros is preferred as these are cleaner to read.
@@ -2050,11 +2094,11 @@ else: \
 #
 # Requirements:
 # BuildRequires:       sed >= 4.0
-# BuildRequires:       rpmbuild(macros) >= 1.565
+# BuildRequires:       rpmbuild(macros) >= 1.674
 
 # 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$,,' %* \
+%undos(f:i)    %{-f:%{__find} -type f -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.
@@ -2163,7 +2207,7 @@ fi; \
 #
 %ghc_pkg_recache() {{ \
        umask 022; \
-       /usr/bin/ghc-pkg recache; \
+       [ ! -x /usr/bin/ghc-pkg ] || /usr/bin/ghc-pkg recache; \
 };} \
 %{nil}
 
@@ -2201,7 +2245,7 @@ fi; \
 # %systemd_trigger %{name}.service
 #
 # Requirements:
-# BuildRequires:       rpmbuild(macros) >= 1.647
+# BuildRequires:       rpmbuild(macros) >= 1.671
 # Requires:    systemd-units >= 38
 
 %systemd_reload /bin/systemd_booted && SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog /bin/systemctl --quiet daemon-reload || :
@@ -2246,7 +2290,7 @@ fi; \
 want_enable_service() { \
        [ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
        [ ${RPM_ENABLE_SYSTEMD_SERVICE:-yes} = no ] && return 1 \
-       /sbin/chkconfig --list ${1%.service} 2>/dev/null | grep -qsv "[0-6]:on" && return 1 \
+       [ "$(echo /etc/rc.d/rc[0-6].d/S[0-9][0-9]${1%.service})" = "/etc/rc.d/rc[0-6].d/S[0-9][0-9]${1%.service}" ] && return 1 \
        return 0 \
 }\
        export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
This page took 0.091301 seconds and 4 git commands to generate.