]> git.pld-linux.org Git - packages/rpm.git/blobdiff - rpm.macros
- %_clean_env: no need to quote : . _ -
[packages/rpm.git] / rpm.macros
index 6cc93182eba565ca1afab4f012d6cdab01c50f16..7af014527f529a920426d75aad467ee9a2485646 100644 (file)
@@ -57,8 +57,8 @@
 %_dependency_whiteout  %{nil}
 
 %_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\
-       && RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
-       [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-j$RPM_BUILD_NCPUS")
+       && RPM_BUILD_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); \\\
+       [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-j$(($RPM_BUILD_NCPUS * 2))")
 
 #-----------------------------------------------------------------
 #
         };
 }')
 
+#-----------------------------------------------------------------
+#
+#  Generate a command which cleans environment, leaving only the
+# most important variables.
+#  If any spec requires any additional environment it should
+# redefine %_preserve_env in following manner:
+#
+#      # ADDITIONAL_VAR is required because [a good reason here]
+#      %{expand:%%define _preserve_env %_preserve_env ADDITIONAL_VAR}
+
+%_preserve_env PATH HOME TMP TMPDIR
+
+%_clean_env            env -i %(awk -vq="'" -vqq="\\"'\\"" -vq2q="'\\"'" 'BEGIN {
+       split("%{?_preserve_env:%_preserve_env}", P);
+       for (i in P) {
+               p = P[i];
+               if (ENVIRON[p]) {
+                       split( ENVIRON[p], V, "" );
+                       val = p "=";
+                       for ( j = 1; j in V; j++ ) {
+                               v = V[j];
+                               if ( v == q )
+                                       v = qq;
+                               else if ( v == "\\"" )
+                                       v = q2q;
+                               else if ( v == "\\\\" )
+                                       v = "\\\\\\\\";
+                               else
+                                       gsub( "[^a-zA-Z0-9/:._-]", "\\"&\\"", v );
+                               val = val "" v;
+                       }
+                       printf( val " " );
+               }
+       }
+}')
+
 #-----------------------------------------------------------------
 %configure2_13 { \
  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
@@ -487,6 +523,21 @@ if [ -d "$RPM_BUILD_ROOT" ]; then \
        fi; \
 fi; }; __spec_install_post_chrpath } } }
 
+#-----------------------------------------------------------------
+# Find all shared object files with unresolved symbols. Warn
+# and terminate if any found (termination can be turned off by define).
+#%no_install_post_check_so 1
+%__spec_install_post_check_so { \
+ __spec_install_post_check_so() { \
+    fail=0; \
+    printf "Searching for shared objects with unresolved symbols..."; \
+    for f in $(find $RPM_BUILD_ROOT -type f -name '*.so.*' -print); do \
+        LC_ALL=C objdump -T $f 2> /dev/null | LC_ALL=C awk -v "file=$f" 'BEGIN { found=0; skip["program_name"]=1; symbols = "" } /^[0-9a-z]+ +D +\*UND\*/ { if ($NF in skip) { next; }; found = 1; symbols = symbols "\n\t" $NF } END { if (found) { print "\nUnresolved symbols found in: " file symbols; exit(1); } } ' || fail=1 ; \
+    done ; \
+    echo " DONE"; \
+    %{!?no_install_post_check_so:[ $fail -eq 1 ] && : || :;} \
+}; __spec_install_post_check_so }}
+
 #-----------------------------------------------------------------
 # Find and gzip all kernel modules
 #
@@ -634,6 +685,7 @@ fi; \
 %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_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_ver_requires_eq  Requires:       ruby(ver) = %ruby_version
 %ruby_mod_ver_requires_eq      Requires:       ruby-modules(ver) = %ruby_version
@@ -756,19 +808,25 @@ fi \
 %pyrequires_eq() Requires:     %1
 
 # Hardlink binary identical .pyc and .pyo files
-# (idea by glen <at> pld-linux <dot> org)
 %__spec_install_post_py_hardlink {\
 %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
-[ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
-       b="${a%.pyc}.pyo"; \
-       if cmp -s "$a" "$b"; then \
-               ln -f "$a" "$b"; \
-       fi; \
-done \
+local a b c=0 t=0; \
+if [ -d "$RPM_BUILD_ROOT" ]; then \
+       find "$RPM_BUILD_ROOT" -name '*.pyc' > __rpm_pyc; \
+       while read a; do \
+               b="${a%.pyc}.pyo"; \
+               if cmp -s "$a" "$b"; then \
+                       ln -f "$a" "$b"; \
+                       c=$((c + 1)); \
+               fi; \
+               t=$((t + 1)); \
+       done < __rpm_pyc; \
+       [ $t -gt 0 ] && printf "Hardlink Python files: %d/%d files hardlinked\n" $c $t; \
+       rm -f __rpm_pyc; \
+fi; \
 }; __spec_install_post_py_hardlink } }
 
 # remove python sources, so that check-files won't complain
-# (idea by glen <at> pld-linux <dot> org)
 %py_postclean() \
 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;\
@@ -911,7 +969,7 @@ fi;
 %groupadd(g:P:rfo)     \
 %{!-g:%{error:groupadd: Required argument -g missing}} \
 %{!?1:%{error:groupadd: Required parameter group missing}} \
-if /usr/bin/getgid %{1} > /dev/null 2>&1; then \
+if /usr/bin/getgid %{1} > /dev/null 2>&1; then \
        if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
                echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
                exit 1 \
@@ -1307,7 +1365,7 @@ for cfg in ${cfgs:-dist}; do                                        \
        [ -r "%{_kernelsrcdir}/config-$cfg" ] || exit 1                                 \
                                                                                                                                        \
        rm -rf o                                                                                                                \
-       install -d o/include/linux                                                                              \
+       install -d o/include/linux 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 \
@@ -1323,6 +1381,7 @@ for cfg in ${cfgs:-dist}; do                                        \
        %else                                                                                                                   \
                install -d o/include/config                                                                     \
                touch o/include/config/MARKER                                                           \
+               ln -sf %{_kernelsrcdir}/include/config/auto-$cfg.conf o/include/config/auto.conf        \
                ln -sf %{_kernelsrcdir}/scripts o/scripts                                       \
        %endif                                                                                                                  \
                                                                                                                                        \
This page took 0.042942 seconds and 4 git commands to generate.