diff --git a/llvm.spec b/llvm.spec index 08e85be..34bcf94 100644 --- a/llvm.spec +++ b/llvm.spec @@ -93,6 +93,16 @@ exec &>> >(/usr/bin/ts) %{_sbindir}/update-alternatives --install %{_bindir}/llvm-config%{exec_suffix} llvm-config%{exec_suffix} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} %{__isa_bits} %if %{without compat_build} %{_sbindir}/update-alternatives --install %{_bindir}/llvm-config-%{maj_ver} llvm-config-%{maj_ver} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} %{__isa_bits} + +# During the upgrade from LLVM 16 (F38) to LLVM 17 (F39), we found out the +# main llvm-devel package was leaving entries in the alternatives system. +# Try to remove them now. +for v in 14 15 16; do + if [[ -e %{_bindir}/llvm-config-$v + && "x$(%{_bindir}/llvm-config-$v --version | awk -F . '{ print $1 }')" != "x$v" ]]; then + %{_sbindir}/update-alternatives --remove llvm-config-$v %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} + fi +done %endif %postun -n %{pkg_name_llvm}-devel @@ -101,12 +111,20 @@ exec &>> >(/usr/bin/ts) %endif if [ $1 -eq 0 ]; then %{_sbindir}/update-alternatives --remove llvm-config%{exec_suffix} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} -%if %{without compat_build} - %{_sbindir}/update-alternatives --remove llvm-config-%{maj_ver} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} -%endif fi +%if %{without compat_build} +# When upgrading between minor versions (i.e. from x.y.1 to x.y.2), we must +# not remove the alternative. +# However, during a major version upgrade (i.e. from 16.x.y to 17.z.w), the +# alternative must be removed in order to give priority to a newly installed +# compat package. +if [[ $1 -eq 0 + || "x$(%{_bindir}/llvm-config-%{maj_ver} --version | awk -F . '{ print $1 }')" != "x%{maj_ver}" ]]; then + %{_sbindir}/update-alternatives --remove llvm-config-%{maj_ver} %{install_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} +fi +%endif %include %{_sourcedir}/files.spec.inc %changelog -%include %{_sourcedir}/changelog.spec.inc \ No newline at end of file +%include %{_sourcedir}/changelog.spec.inc