diff --git a/force-as-needed-for-shared-lib-in-libtool b/force-as-needed-for-shared-lib-in-libtool new file mode 100755 index 0000000000000000000000000000000000000000..d2055cb46f031d1c1e9a3278b992ac879db6f5fc --- /dev/null +++ b/force-as-needed-for-shared-lib-in-libtool @@ -0,0 +1,15 @@ +#!/bin/sh + +# replaces +# tmp_sharedflag='-shared' ;; +# with +# tmp_sharedflag='-shared -Wl,--as-needed' ;; +# +# since passing -Wl,--as-needed is not enough because libtool moves it +# after *.o and libs +CONFIGURE_TOP="${1:-.}" + +if [ -e $CONFIGURE_TOP/configure ]; then + echo "Forcing -Wl,--as-needed in configure/libtool to workaround libtool bug (cf http://lists.gnu.org/archive/html/libtool-patches/2004-06/msg00002.html)" + sed -i "s/^\([ \t]*tmp_sharedflag\)='-shared'/\1='-shared -Wl,--as-needed'/" $CONFIGURE_TOP/configure +fi diff --git a/macros b/macros index 4d0a93ddadbf40af72f41195658e77f003f34a65..0bb775d5bfdd77a1d045b614bcc1d984029df087 100644 --- a/macros +++ b/macros @@ -201,8 +201,9 @@ print(result) for i in $(find . -name ltmain.sh) ; do \ %{__sed} -i.backup -e 's~compiler_flags=$~compiler_flags="%{_hardened_ldflags}"~' $i \ done ; \ + %{?_ld_as_needed:/usr/lib/rpm/anolis/force-as-needed-for-shared-lib-in-libtool $(dirname %{_configure}) ;} \ %{__fix_libtool_ltmain_from_overlinking} ; \ - %{__fix_libtool_from_moving_options_after_libs} . ; \ + %{__fix_libtool_from_moving_options_after_libs} $(dirname %{_configure}) ; \ %{__fix_dlsearch_path_in_libtool} . %{_lib} ; \ %{_configure} --build=%{_build} --host=%{_host} \\\ --program-prefix=%{?_program_prefix} \\\ diff --git a/macros.anolis-misc-srpm b/macros.anolis-misc-srpm index d455215dbb716b9014c6a11e4a4ca0b1b3607181..f88e0455a84189da8d77be13867006d6ef305aa8 100644 --- a/macros.anolis-misc-srpm +++ b/macros.anolis-misc-srpm @@ -41,3 +41,26 @@ local source_name = anolis.read("source_name") local first = not ( anolis.read("name") or anolis.read("currentname") ) anolis.new_package(source_name, pkg_name, name_suffix, first, verbose) } + + +# Get version of specific rpm installed at build time +# Default only output %{?epoch:%{epoch}:}%{version} +# -r output release also +# -p query Provides besides name +# (-r is useless when combined with -p, because +# using -p means querying via Provides tag) +# +# Usage example: +# Requires: openssl-libs >= %{installed_version_of openssl-libs} +# Requires: libX11 >= %{installed_version_of -r libX11} +# Requires: bcfversion = %{installed_version_of -p bcfversion} +# will produce following requires on built rpms: +# openssl-libs >= 1:3.0.7 +# libX11 >= 1.1.14-2.an23 +# bcfversion = 3.9 +# +%installed_version_of(rp) %(\ +rpm -q %{-p:--whatprovides} %1 > /dev/null && \ +%{-p: rpm -q --provides $(rpm -q --whatprovides %1) | grep '%1 =' | awk -F' = ' '{print $2}' } \ +%{!-p: rpm -q --queryformat="%%|EPOCH?{%%{EPOCH}:}:{}|%%{VERSION}%{-r:-%%{RELEASE}}" %1} +) diff --git a/system-rpm-config.spec b/system-rpm-config.spec index 62a382fb2bd653096cc8397e10cf1591e3b3ccb1..b84fc634c61e2e3623731e2383479177e5e11bad 100644 --- a/system-rpm-config.spec +++ b/system-rpm-config.spec @@ -1,4 +1,4 @@ -%define anolis_release 25 +%define anolis_release 26 Summary: Anolis OS specific rpm configuration files Name: system-rpm-config @@ -64,6 +64,7 @@ Source407: clean_perl Source408: check_elf_files Source409: fix-libtool-ltmain-from-overlinking Source410: fix-libtool-from-moving-options-after-libs +Source411: force-as-needed-for-shared-lib-in-libtool # 2022-05-25 Snapshots from http://git.savannah.gnu.org/gitweb/?p=config.git Source500: config.guess @@ -100,6 +101,9 @@ Requires: %{_bindir}/grep Requires: %{_bindir}/sed Requires: %{_bindir}/xargs +# for installed_version_of macro +Requires: %{_bindir}/awk + # for brp_check_desktop_files Requires: desktop-file-utils @@ -142,6 +146,7 @@ install -p -m 755 -t %{buildroot}%{rrcdir} remove-info-dir install -p -m 755 -t %{buildroot}%{rrcdir} fix-dlsearch-path-in-libtool install -p -m 755 -t %{buildroot}%{rrcdir} fix-libtool-ltmain-from-overlinking install -p -m 755 -t %{buildroot}%{rrcdir} fix-libtool-from-moving-options-after-libs +install -p -m 755 -t %{buildroot}%{rrcdir} force-as-needed-for-shared-lib-in-libtool install -p -m 755 -t %{buildroot}%{rrcdir} generate-compatibility-deps install -p -m 755 -t %{buildroot}%{rrcdir} relink_symlinks install -p -m 755 -t %{buildroot}%{rrcdir} check-desktop-files @@ -185,6 +190,7 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/anolis/srpm forge.lua %{rrcdir}/fix-dlsearch-path-in-libtool %{rrcdir}/fix-libtool-from-moving-options-after-libs %{rrcdir}/fix-libtool-ltmain-from-overlinking +%{rrcdir}/force-as-needed-for-shared-lib-in-libtool %{rrcdir}/generate-compatibility-deps %{_fileattrsdir}/*.attr %{_rpmconfigdir}/compatibility-deps.sh @@ -204,6 +210,10 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/anolis/srpm forge.lua %license MulanPSL %changelog +* Fri Feb 17 2023 Funda Wang - 1:23-26 +- Add helper macro for packagers to detect installed version of package +- Add helper script forcing as-needed for libtool linking bugs + * Sat Feb 11 2023 Funda Wang - 1:23-25 - Add helper scripts from mageia to fix overlinking of shared libs