]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
- ver 1.744
[packages/rpm-build-macros.git] / rpm.macros
index 188b0c81186db31b1cf792154e4a1a34528a7750..59712fa5c6a303ee60628af7805d42a59b71c086 100644 (file)
 %__make                /usr/bin/make %{?_make_opts} %{?_smp_mflags}
 %__scons       /usr/bin/scons %{?_smp_mflags}
 %__waf         /usr/bin/waf %{?_smp_mflags}
-%__cmake       /usr/bin/cmake
+%__cmake       /usr/bin/cmake -Wno-dev
 %__meson       /usr/bin/meson
-%__ninja       /usr/bin/ninja %{?_smp_mflags}
+%__meson_wrap_mode     nodownload
+%__ninja       /usr/bin/ninja
+%__ninja_common_opts   -v %{?_smp_mflags}
 
 %__gettextize { \
-       if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
-               gettextize --copy --force --no-changelog; \
-       else \
-               gettextize --copy --force --no-changelog --intl; \
-       fi; \
+       gettextize --copy --force --no-changelog; \
        if [ ! -f po/Makevars ]; then \
                cp -f po/Makevars{.template,}; \
        fi; \
@@ -329,25 +327,34 @@ CFLAGS="${CFLAGS:-%{rpmcflags}}" \
 CPPFLAGS="${CPPFLAGS:-%{rpmcppflags}}" \
 CXXFLAGS="${CXXFLAGS:-%{rpmcxxflags}}" \
 LDFLAGS="${LDFLAGS:-%{rpmldflags}}" \
-%{__meson} \
+LC_ALL=C.UTF-8 %{__meson} \
        --buildtype=plain \
-       --prefix=%{_prefix} \
        --bindir=%{_bindir} \
-       --sbindir=%{_sbindir} \
-       --sysconfdir=%{_sysconfdir} \
        --datadir=%{_datadir} \
        --includedir=%{_includedir} \
+       --infodir=%{_infodir} \
        --libdir=%{_libdir} \
        --libexecdir=%{_libexecdir} \
+       --localedir=%{_localedir} \
        --localstatedir=%{_localstatedir} \
-       --sharedstatedir=%{_sharedstatedir} \
        --mandir=%{_mandir} \
-       --infodir=%{_infodir} \
-       --localedir=%{_localedir} \
+       --prefix=%{_prefix} \
+       --sbindir=%{_sbindir} \
+       --sharedstatedir=%{_sharedstatedir} \
+       --sysconfdir=%{_sysconfdir} \
+       --wrap-mode=%{__meson_wrap_mode} \
+       --default-library='both' \
 }
 
+%___meson_deprecate() {echo >&2 "DEPRECATED: %%%1 must be replaced with %%%2"; %{expand:%%%2} }
+%meson_build %___meson_deprecate meson_build ninja_build
+%meson_install %___meson_deprecate meson_install ninja_install
+%meson_test %___meson_deprecate meson_test ninja_test
+
 # ninja
-%ninja %{__ninja} -v
+%ninja_build LC_ALL=C.UTF-8 %{__ninja} %{__ninja_common_opts}
+%ninja_install LC_ALL=C.UTF-8 DESTDIR=%{buildroot} %{__ninja} install %{__ninja_common_opts}
+%ninja_test LC_ALL=C.UTF-8 %{__ninja} test %{__ninja_common_opts}
 
 #----------------------------------------------------------------
 #%configure_cache 0
@@ -418,6 +425,15 @@ LDFLAGS="${LDFLAGS:-%{rpmldflags}}" \
 %__without_if() %{expand:%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
 %__with_without_not() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
 
+# expands to true or false based on bcond; for use with meson or cmake
+%__true_false() %{expand:%%{?with_%{1}:true}%%{!?with_%{1}:false}}
+%__true_false_not() %{expand:%%{?with_%{1}:false}%%{!?with_%{1}:true}}
+
+# for use with cmake:
+# Usage: cmake_on_off BCOND_NAME [OPTION_NAME]
+# BuildRequires: rpmbuild(macros) >= 1.742
+%cmake_on_off() -D%{?2}%{!?2:%{1}}:BOOL=%{expand:%%{?with_%{1}:ON}%%{!?with_%{1}:OFF}}
+
 #-----------------------------------------------------------------
 
 # overload to insert debuginfo package
@@ -601,7 +617,7 @@ Provides: %{1} = %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}
 %{!?debug:set +x;} \
 if [ -d "$RPM_BUILD_ROOT" ]; then \
        if [ -d $RPM_BUILD_ROOT/lib/modules ]; then \
-               modulelist=$(find $RPM_BUILD_ROOT/lib/modules -name '*o' -type f -print); \
+               modulelist=$(find $RPM_BUILD_ROOT/lib/modules \( -name '*.o' -o -name '*.ko' \) -type f -print); \
                if [ "$modulelist" ]; then \
                        modulecount=$(echo "$modulelist" | wc -l); \
                        printf "Stripping %d kernel modules..." $modulecount; \
@@ -610,7 +626,7 @@ if [ -d "$RPM_BUILD_ROOT" ]; then \
                        echo "DONE"; \
                fi; \
        fi; \
-       filelist=$(find $RPM_BUILD_ROOT -type f ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautostrip:! -regex "%{_noautostrip}"} %{?_autostripall:! -regex "%{_autostripall}"} %{?_autostripunneeded:! -regex "%{_autostripunneeded}"} %{?_autostripdebug:! -regex "%{_autostripdebug}"}); \
+       filelist=$(find $RPM_BUILD_ROOT -type f ! -regex ".*/usr/lib[x0-9]*/debug/.*\.debug" ! -regex ".*/usr/lib[x0-9]*.*/guile/.*\.go" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautostrip:! -regex "%{_noautostrip}"} %{?_autostripall:! -regex "%{_autostripall}"} %{?_autostripunneeded:! -regex "%{_autostripunneeded}"} %{?_autostripdebug:! -regex "%{_autostripdebug}"}); \
        if [ -n "$filelist" ]; then \
                filetypes=`echo "$filelist" | xargs -r -d'\\n' file`; \
                elfexelist=`echo "$filetypes" | awk -F: '/ELF.*executable/ {print $1}'`; \
@@ -726,12 +742,38 @@ __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; %{?skip_post_check_so:split("%{skip_post_check_so}", R); for (i=1; i in R; i++) { if (file ~ "(^|/)" R[i] "$") { print "Library marked with skip_post_check_so, ignoring errors.\n"; exit(0); } } } exit(1); } } ' || fail=1 ; \
+               LC_ALL=C objdump -T $f 2> /dev/null | LC_ALL=C awk -v "file=$f" 'BEGIN { found=0; skip["program_name"]=1; skip["_ZSt15__once_callable"]=1; skip["_ZSt11__once_call"]=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; %{?skip_post_check_so:split("%{skip_post_check_so}", R); for (i=1; i in R; i++) { if (file ~ "(^|/)" R[i] "$") { print "Library marked with skip_post_check_so, ignoring errors.\n"; exit(0); } } } exit(1); } } ' || fail=1 ; \
        done ; \
        echo " DONE"; \
        %{!?no_install_post_check_so:return $fail;} \
 }; __spec_install_post_check_so }}
 
+#-----------------------------------------------------------------
+# Find all ELF files with executable stac. Warn and terminate if any found
+# (termination can be turned off by define).
+# Details: https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart
+#%no_install_post_check_stackexec 1
+#%skip_post_check_stackexec libwithexecstackok.so.*
+#
+# NOTE: define skip_post_check_stackexec only if such program or library
+#       really requires executable stack and always leave a comment why
+#       it is required:
+#      # Programs full of nested functions that cannot be fixed
+#      %define skip_post_check_execstack /bin/foo libwithexecstack.so.*
+#
+%__spec_install_post_check_execstack { \
+__spec_install_post_check_execstack() { \
+%{!?debug:set +x;} \
+       fail=0; \
+       printf "Searching for ELF programs with executable stack..."; \
+       for f in $(find $RPM_BUILD_ROOT -type f -print) ; do \
+               LC_ALL=C readelf -lW $f 2>/dev/null | \
+               LC_ALL=C awk -v "file=$f" 'BEGIN { found=0; } /GNU_STACK/ { if ($7 ~ "E") { found=1 } } END { if (found) { print "\nExecutable stack found in: " file; %{?skip_post_check_execstack:split("%{skip_post_check_execstack}", R); for (i=1; i in R; i++) { if (file ~ "(^|/)" R[i] "$") { print "File marked with skip_post_check_execstack, ignoring errors.\n"; exit(0); } } } exit(1); } }' || fail=1 ; \
+       done ; \
+       echo " DONE"; \
+       %{!?no_install_post_check_execstack:return $fail;} \
+}; __spec_install_post_check_execstack }}
+
 #-----------------------------------------------------------------
 # Verify that for each directory under /var/run package contains
 # tmpfiles.d configuration. Warn and terminate build if config is
@@ -911,12 +953,21 @@ fi; \
 %__noautoreqfiles      %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
 %__noautoprovfiles     %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
 %__noautoreqdep                %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
-%__noautoprov          %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
+%__noautoprov          %(sed -e s'/#.*//' /etc/rpm/noautoprov) \
+       %{?_noautoprov: %{_noautoprov}} \
+       %{?_noautoprov_java: %{__noauto_regexp_helper -p java %{_noautoprov_java}}} \
+       %{?_noautoprov_mono: %{__noauto_regexp_helper -p mono %{_noautoprov_mono}}} \
+       %{?_noautoprov_pear: %{__noauto_regexp_helper -p pear %{_noautoprov_pear}}} \
+       %{?_noautoprov_perl: %{__noauto_regexp_helper -p perl %{_noautoprov_perl}}} \
+       %{?_noautoprov_pyegg: %{__noauto_regexp_helper -p pythonegg %{_noautoprov_pyegg}}} \
+       %{?_noautoprov_py3egg: %{__noauto_regexp_helper -p python3egg %{_noautoprov_py3egg}}} \
+       %{nil}
 %__noautoreq           %(sed -e s'/#.*//' /etc/rpm/noautoreq) \
        %{?_noautoreq: %{_noautoreq}} \
+       %{?_noautoreq_java: %{__noauto_regexp_helper -p java %{_noautoreq_java}}} \
+       %{?_noautoreq_mono: %{__noauto_regexp_helper -p mono %{_noautoreq_mono}}} \
        %{?_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}}} \
        %{?_noautoreq_pyegg: %{__noauto_regexp_helper -p pythonegg %{_noautoreq_pyegg}}} \
        %{?_noautoreq_py3egg: %{__noauto_regexp_helper -p python3egg %{_noautoreq_py3egg}}} \
        %{nil}
@@ -932,6 +983,15 @@ fi; \
 # BuildRequires:       rpmbuild(macros) >= 1.709
 # %define _noautoreq_pyegg argparse
 # %define _noautoreq_py3egg backports.ssl-match-hostname ipaddress
+# BuildRequires:       rpmbuild(macros) >= 1.730
+# %define _noautoreq_mono Gendarme.Framework
+# BuildRequires:       rpmbuild(macros) >= 1.737
+# %define _noautoprov_java Class
+# %define _noautoprov_mono Excluded.Provide
+# %define _noautoprov_pear Excluded.php
+# %define _noautoprov_perl Excluded::Module
+# %define _noautoprov_pyegg excluded
+# %define _noautoprov_py3egg excluded3
 #
 %__noauto_regexp_helper(p:) %(echo "%*" | awk 'BEGIN{RS=" "}{printf("%{-p*}%{__qchar}(%%s%{__qchar}) ", $1)}')
 # detect quote character runtime
@@ -976,7 +1036,7 @@ fi; \
 
 %ruby_archdir          %{expand:%%global ruby_archdir %{__ruby_rbconfig_path 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_ridir                    %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'print File.join(RbConfig::CONFIG["datadir"], "ri", "system")' 2>/dev/null || echo ERROR)}%ruby_ridir
 %ruby_rubylibdir       %{expand:%%global ruby_rubylibdir %{__ruby_rbconfig_path rubylibdir}}%ruby_rubylibdir
 %ruby_vendorarchdir    %{expand:%%global ruby_vendorarchdir %{__ruby_rbconfig vendorarchdir}}%ruby_vendorarchdir
 %ruby_vendorlibdir     %{expand:%%global ruby_vendorlibdir %{__ruby_rbconfig_path vendorlibdir}}%ruby_vendorlibdir
@@ -1448,7 +1508,7 @@ fi;
 #
 %webapp_register(f) \
 %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
-if [ -n "%{-f:1}" ] || [ "$1" = "1" ] && [ "$2" = "1" ]; then\
+if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ]); then\
        /usr/sbin/webapp register %1 %2\
 fi\
 # reload webserver if the config symlink is there and skip reload if webserver is upgraded\
@@ -1463,7 +1523,7 @@ fi\
 %webapp_unregister(f) \
 %{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
 # remove link if either of the packages are gone \
-if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ]; then \
+if [ -n "%{-f:1}" ] || ([ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ]); then \
        /usr/sbin/webapp unregister %1 %2\
        %{expand:%service -q %%1 reload}\
 fi \
This page took 0.059148 seconds and 4 git commands to generate.