Spec File: Use the correct alternatives (fixed version).

Resolves: #2209148
This commit is contained in:
Nick Clifton 2023-06-12 13:40:21 +01:00
parent aba99ef14b
commit f640c07c7a

View File

@ -9,7 +9,7 @@ BuildRequires: scl-utils-build
Summary: A GNU collection of binary utilities
Name: %{?scl_prefix}binutils
Version: 2.40
Release: 8%{?dist}
Release: 9%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -344,8 +344,14 @@ BuildRequires: dejagnu, zlib-static, glibc-static, sharutils, bc, libstdc++
BuildRequires: elfutils-debuginfod-client-devel
%endif
Requires(post): alternatives
Requires(preun): alternatives
%{?scl:Requires:%scl_runtime}
%define alternatives_cmd %{!?scl:%{_sbindir}}%{?scl:%{_root_sbindir}}/alternatives
%define alternatives_cmdline %{alternatives_cmd}%{?scl: --altdir %{_sysconfdir}/alternatives --admindir %{_scl_root}/var/lib/alternatives}
Requires(post): %{alternatives_cmd}
Requires(preun): %{alternatives_cmd}
# We also need rm.
Requires(post): coreutils
@ -1101,17 +1107,22 @@ export QA_RPATHS=0x0003
#----------------------------------------------------------------------------
%if %{with gold}
%post gold
%{alternatives_cmdline} --install %{_bindir}/ld ld \
%{_bindir}/ld.gold %{ld_gold_priority}
exit 0
%endif
%post
%__rm -f %{_bindir}/ld
%{_root_sbindir}/alternatives --install %{_bindir}/ld ld \
%{alternatives_cmdline} --install %{_bindir}/ld ld \
%{_bindir}/ld.bfd %{ld_bfd_priority}
%if %{with gold}
%{_root_sbindir}/alternatives --install %{_bindir}/ld ld \
%{_bindir}/ld.gold %{ld_gold_priority}
%endif
# Do not run "alternatives --auto ld" here. Leave the setting to
# however the user previously had it set. See BZ 1592069 for more details.
@ -1121,16 +1132,22 @@ exit 0
#----------------------------------------------------------------------------
%preun
if [ $1 = 0 ]; then
%{_root_sbindir}/alternatives --remove ld %{_bindir}/ld.bfd
fi
# Note: $1 == 0 means that there is an uninstall in progress.
# $1 == 1 means that there is an upgrade in progress.
%if %{with gold}
%preun gold
if [ $1 = 0 ]; then
%{_root_sbindir}/alternatives --remove ld %{_bindir}/ld.gold
%{alternatives_cmdline} --remove ld %{_bindir}/ld.gold
fi
exit 0
%endif
%preun
if [ $1 = 0 ]; then
%{alternatives_cmdline} --remove ld %{_bindir}/ld.bfd
fi
touch %{_bindir}/ld
exit 0
#----------------------------------------------------------------------------
@ -1262,6 +1279,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Mon Jun 12 2023 Nick Clifton <nickc@redhat.com> - 2.40-9
- Spec File: Use the correct alternatives. (#2209148 and #2213913)
* Mon May 22 2023 Marek Polacek <polacek@redhat.com> - 2.40-8
- Spec File: Use the correct alternatives. (#2209148)