X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=rpm.macros;h=c66205f763f33d2a4aa698f419b9f239fdde0727;hb=b0daadbc172d3607f78308b108ec821506c32ce3;hp=145641f1b4867f9e0ba18b11bcc5a76a08eab7e6;hpb=5418b502924e7bdbcbbc2e831f970cd8bfff6e13;p=packages%2Frpm.git diff --git a/rpm.macros b/rpm.macros index 145641f..c66205f 100644 --- a/rpm.macros +++ b/rpm.macros @@ -9,16 +9,28 @@ %kgcc_package gcc # compiler version -%cc_version %{expand:%%global cc_version %(%{__cc} -dumpversion || echo ERROR)}%cc_version +%cc_version %{expand:%%global cc_version %(%{__cc} -dumpversion || echo ERROR)}%cc_version %cxx_version %{expand:%%global cxx_version %(%{__cxx} -dumpversion || echo ERROR)}%cxx_version -%__rm /bin/rm --interactive=never +%__rm /bin/rm --interactive=never # Build system path macros. +%__autoconf autoconf %{?debug:-Wall} +%__automake automake -a -c -f --foreign +%__autopoint autopoint --force + +# add parallel build flags: -jN +# +# if you want to disable parallel build do (replace %% with %) +# echo '%%_smp_mflags %%{nil}' >> ~/.rpmmacros # -%__autoconf autoconf %{?debug:-Wall} -%__automake automake -a -c -f --foreign -%__autopoint autopoint --force +%__make make %{?_smp_mflags} +%__scons scons %{?_smp_mflags} +%__waf waf %{?_smp_mflags} +%__cmake cmake %{?_smp_mflags} + +%_smp_mflags %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); \\\ + [ "$_NCPUS" -gt 1 ] && echo "-j$(($_NCPUS * 2))") %__gettextize { \ if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \ @@ -56,10 +68,6 @@ # and that both p and q are package names (i.e. no version/release). %_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 * 2))") - #----------------------------------------------------------------- # # (re)definition of %{rpm*flags} with %filterout_* support @@ -121,6 +129,46 @@ }; }') +#----------------------------------------------------------------- +# +# 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] +# %define _preserve_env ADDITIONAL_VAR + +%_preserve_env_base PATH HOME TMP TMPDIR SSH_AUTH_SOCK + +%_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); + for (i in P) { + p = P[i]; + if (!ENVIRON[p] || d[p]) { + continue; + } + d[p] = 1; + 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; \ @@ -263,7 +311,7 @@ CXXFLAGS="%{rpmcxxflags}" \ %__unsermake /usr/share/unsermake/unsermake # Current date -%date %(LC_ALL="C" date +"%a %b %d %Y") +%date %(LC_ALL=C date +"%a %b %d %Y") # Example files, programs, scripts... %_examplesdir /usr/src/examples @@ -277,8 +325,6 @@ CXXFLAGS="%{rpmcxxflags}" \ # If non-empty "debug" macro defined, add "dbg" suffix to release number %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm -# Requires name = version-release -%requires_releq() %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}-%{R}\\n' | grep -v 'is not') %releq_kernel %{expand:%%global releq_kernel %(R=$(LC_ALL=C rpm -q --qf '%{N} = %|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 %releq_kernel_up %{expand:%%global releq_kernel_up %(R=$(LC_ALL=C rpm -q --qf '%{N}-up = %|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_up @@ -287,9 +333,12 @@ CXXFLAGS="%{rpmcxxflags}" \ %requires_releq_kernel_up(s:) Requires%{-s:(%{-s*})}: %releq_kernel_up %requires_releq_kernel_smp(s:) Requires%{-s:(%{-s*})}: %releq_kernel_smp -# XXX: why epoch 0 is stripped? -%requires_eq() %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}\\n' | sed -e 's/ 0:/ /' | grep -v 'is not') -%requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %|E?{%{E}:}|%{V}' %2 | grep -v "is not") +# Requires name = version-release +%requires_releq() %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to -r %1 %1}}} +# Requires: name = version +%requires_eq() %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to %1 %1}}} +# Requires: name = version (version based on querying package %2) +%requires_eq_to(r) %{!?2:ERROR}%{?3:ERROR}%{?2:%{!?3:%(if ! LC_ALL=C rpm -q --qf 'Requires: %1 = %|E?{%{E}:}|%{V}%{?-r:-%{R}}\\n' %2 | grep '^Requires:'; then echo "BuildRequires: %2"; fi)}} %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 @@ -499,7 +548,7 @@ fi; }; __spec_install_post_chrpath } } } 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 ] && exit 1 || exit 0;} \ + %{!?no_install_post_check_so:[ $fail -eq 1 ] && : || :;} \ }; __spec_install_post_check_so }} #----------------------------------------------------------------- @@ -771,6 +820,25 @@ fi \ # Software written in Python language require Python with main version %pyrequires_eq() Requires: %1 +# Python 3.x +# python main version +%__python3 python3.0 +%py3_ver %{expand:%%global py3_ver %(%{__python3} -c "import sys; print(sys.version[:3])" 2>/dev/null || echo ERROR)}%py3_ver + +# directories +%py3_prefix %{expand:%%global py3_prefix %(%{__python3} -c "import sys; print(sys.prefix)" 2>/dev/null || echo ERROR)}%py3_prefix +%py3_libdir %{py3_prefix}/%{_lib}/python%{py3_ver} +%py3_scriptdir %{py3_prefix}/share/python%{py3_ver} +%py3_incdir /usr/include/python%{py3_ver} +%py3_sitedir %{py3_libdir}/site-packages +%py3_sitescriptdir %{py3_scriptdir}/site-packages +%py3_dyndir %{py3_libdir}/lib-dynload + +# pure python modules compilation +%py3_comp %{__python3} -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])" + +%py3_ocomp %{__python3} -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])" + # Hardlink binary identical .pyc and .pyo files %__spec_install_post_py_hardlink {\ %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \ @@ -797,6 +865,12 @@ for d in %{py_sitescriptdir} %{py_sitedir} %*; do \ done \ %{nil} +%py3_postclean() \ +for d in %{py3_sitescriptdir} %{py3_sitedir} %*; do \ + [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\ +done \ +%{nil} + # depmod macro %depmod() { \ umask 022; \ @@ -1345,6 +1419,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 \ \ @@ -1391,6 +1466,7 @@ compile %{*}\ %define KernelD $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver} \ %define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \ \ +__install_kernel_modules() { \ local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \ \ for MODULE in {%{-m*},}; do \ @@ -1405,6 +1481,8 @@ for MODULE in {%{-m*},}; do \ >> %{ModprobeD}$suf/%{-n*}.conf} \ done \ done \ +} \ +__install_kernel_modules \ %{nil} # patchset macros