llvm/llvm.spec
Tulio Magno Quites Machado Filho b9e4db6642 Fix rhbz #2248872
Ensure the versioned llvm-config alternative gets removed during major
upgrades of the non-compat package.

Also add code that removes the versioned llvm-config alternatives of
the previous 3 LLVM versions. These versions didn't remove their own
versioned llvm-config alternative, leading to broken output, e.g.
llvm-config-16 points to llvm-config-64 from LLVM 17.
2024-05-21 12:18:51 +00:00

130 lines
3.9 KiB
RPMSpec

%include %{_sourcedir}/version.spec.inc
%include %{_sourcedir}/globals.spec.inc
Name: %{pkg_name_llvm}
Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}
Release: 1%{?dist}
Summary: The Low Level Virtual Machine
License: Apache-2.0 WITH LLVM-exception OR NCSA
URL: http://llvm.org
%include %{_sourcedir}/sources.spec.inc
%include %{_sourcedir}/patches.spec.inc
%if %{undefined rhel}
BuildRequires: moreutils
%endif
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: clang
BuildRequires: cmake
BuildRequires: ninja-build
BuildRequires: zlib-devel
BuildRequires: libffi-devel
BuildRequires: ncurses-devel
BuildRequires: python3-psutil
BuildRequires: python3-sphinx
%if %{undefined rhel}
BuildRequires: python3-myst-parser
%endif
# Needed for %%multilib_fix_c_header
BuildRequires: multilib-rpm-config
%if %{with gold}
BuildRequires: binutils-devel
%endif
%ifarch %{valgrind_arches}
# Enable extra functionality when run the LLVM JIT under valgrind.
BuildRequires: valgrind-devel
%endif
# LLVM's LineEditor library will use libedit if it is available.
BuildRequires: libedit-devel
# We need python3-devel for %%py3_shebang_fix
BuildRequires: python3-devel
BuildRequires: python3-setuptools
# For origin certification
BuildRequires: gnupg2
Requires: %{pkg_name_llvm}-libs%{?_isa} = %{version}-%{release}
Provides: llvm(major) = %{maj_ver}
%description
LLVM is a compiler infrastructure designed for compile-time, link-time,
runtime, and idle-time optimization of programs from arbitrary programming
languages. The compiler infrastructure includes mirror sets of programming
tools as well as libraries with equivalent functionality.
%include %{_sourcedir}/packages.spec.inc
%prep
%if %{undefined rhel}
exec &>> >(/usr/bin/ts)
%endif
%include %{_sourcedir}/prep.spec.inc
%build
%if %{undefined rhel}
exec &>> >(/usr/bin/ts)
%endif
%include %{_sourcedir}/build.spec.inc
%install
%if %{undefined rhel}
exec &>> >(/usr/bin/ts)
%endif
%include %{_sourcedir}/install.spec.inc
%check
%if %{undefined rhel}
exec &>> >(/usr/bin/ts)
%endif
%include %{_sourcedir}/check.spec.inc
%ldconfig_scriptlets -n %{pkg_name-llvm}-libs
%post -n %{pkg_name_llvm}-devel
%if %{undefined rhel}
exec &>> >(/usr/bin/ts)
%endif
%{_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
%if %{undefined rhel}
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}
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