c10s: Drop scl dependency

Bundle in a modified version of the SCL macros file and adjust uses.

Resolves: RHEL-88742
This commit is contained in:
Siddhesh Poyarekar 2025-05-05 20:37:30 -04:00 committed by Siddhesh Poyarekar
parent b0073c2605
commit e527cb6052
2 changed files with 189 additions and 11 deletions

View File

@ -1,27 +1,59 @@
%global __python /usr/bin/python3
%global scl gcc-toolset-15
%global scl_prefix gcc-toolset-15-
%global gts_ver 15
%global scl gcc-toolset-%{gts_ver}
%global scl_prefix gcc-toolset-%{gts_ver}-
%global scl_name %scl
# We moved away from scl-utils in RHEL10. Instead, we have bundled in the
# minimal macro hackery necessary to build GTS into the same root to give us
# the necessary isolation and allow an equivalent of `scl enable` since that's
# a common way to use GTS.
#
# Some day we will move away from the 'scl' names, but today is not that day.
%if 0%{?rhel} >= 10
%global have_scl_utils 0
%else
%global have_scl_utils 1
%endif
# GTS only has gcc and binutils in RHEL9 and later.
%if 0%{?rhel} >= 9
%global gts_only_gcc_binutils 1
%else
%global gts_only_gcc_binutils 0
%endif
%if %have_scl_utils
BuildRequires: scl-utils-build
%else
%include %{_sourcedir}/macros.gts
Conflicts: scl-utils-build
%endif
%{?scl_package:%scl_package %scl}
Summary: Package that installs %scl
Name: %scl_name
Version: 15.0
Release: 0%{?dist}
Version: %{gts_ver}.0
Release: 1%{?dist}
License: GPLv2+
Group: Applications/File
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Source0: README
Source1: sudo.sh
Source2: gts-annobin-plugin-select.sh
Source3: macros.gts
%if %have_scl_utils
Requires: %{scl_prefix}runtime
%endif
Requires: %{scl_prefix}gcc %{scl_prefix}gcc-c++ %{scl_prefix}gcc-gfortran
Requires: %{scl_prefix}binutils
# None of these are in GTS in RHEL9 and later.
%if %gts_only_gcc_binutils == 0
Requires: %{scl_prefix}gdb
Requires: %{scl_prefix}dwz
Requires: %{scl_prefix}annobin-plugin-gcc
%endif
Obsoletes: %{name} < %{version}-%{release}
Obsoletes: %{scl_prefix}dockerfiles < %{version}-%{release}
@ -31,11 +63,19 @@ BuildRequires: help2man
BuildRequires: python3-devel
%endif
%if %gts_only_gcc_binutils == 0
%global rrcdir %{_scl_root}/usr/lib/rpm/redhat
%endif
%description
%if %have_scl_utils
This is the main package for %scl Software Collection.
%else
This is the main package installs all of GCC Toolset %gts_ver and related
convenience scripts.
%endif
%if %have_scl_utils
%package runtime
Summary: Package that handles %scl Software Collection.
Group: Applications/File
@ -51,6 +91,7 @@ Requires(postun): libselinux policycoreutils-python
%description runtime
Package shipping essential scripts to work with %scl Software Collection.
%endif
%prep
%setup -c -T
@ -111,23 +152,36 @@ cat <<'EOF' > sudo
EOF
%install
%if %have_scl_utils
(%{scl_install})
# We no longer need this, and it would result in an "unpackaged but
# installed" error.
rm -rf %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-config
%else
mkdir -p %{buildroot}%{_root_sysconfdir}/rpm
# RPM macro weirdness: when it's explicitly included like in this spec file, it
# expects the %%define but when it is installed as a macro file, it cannot
# handle the %%define and instead expects %%<macro name> directly.
sed 's/^%%define scl_/%%scl_/' %{SOURCE3} > %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-build
%endif
# This allows users to build packages using DTS/GTS.
cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-enable << EOF
%%enable_devtoolset15 %%global ___build_pre %%{___build_pre}; source scl_source enable %{scl} || :
%%enable_devtoolset%{gts_ver} %%global ___build_pre %%{___build_pre}; source scl_source enable %{scl} || :
EOF
%if %have_scl_utils
# Without SCL we just let gcc-toolset-*-binutils own this and use the
# --altdir/--admindir mechanism.
mkdir -p %{buildroot}%{_scl_root}/etc/alternatives %{buildroot}%{_scl_root}/var/lib/alternatives
install -d -m 755 %{buildroot}%{_scl_scripts}
install -p -m 755 enable %{buildroot}%{_scl_scripts}/
install -d -m 755 %{buildroot}%{_scl_scripts}
%if %gts_only_gcc_binutils == 0
install -p -m 755 sudo %{buildroot}%{_bindir}/
# Other directories that should be owned by the runtime
@ -137,17 +191,20 @@ install -d -m 755 %{buildroot}%{_libdir}/perl5
install -d -m 755 %{buildroot}%{_libdir}/perl5/vendor_perl
install -d -m 755 %{buildroot}%{_libdir}/perl5/vendor_perl/auto
# Install the plugin selector trigger script.
mkdir -p %{buildroot}%{rrcdir}
install -p -m 755 %{SOURCE2} %{buildroot}%{rrcdir}/
%endif
%endif
# Install generated man page.
install -d -m 755 %{buildroot}%{_mandir}/man7
install -p -m 644 %{?scl_name}.7 %{buildroot}%{_mandir}/man7/
# Install the plugin selector trigger script.
mkdir -p %{buildroot}%{rrcdir}
install -p -m 755 %{SOURCE2} %{buildroot}%{rrcdir}/
# This trigger is used to decide which version of the annobin plugin for gcc
# should be used. See comments in the script for full details.
%if %gts_only_gcc_binutils == 0
%triggerin runtime -- %{scl_prefix}annobin-plugin-gcc %{scl_prefix}gcc-plugin-annobin
%{rrcdir}/gts-annobin-plugin-select.sh %{_scl_root}
%end
@ -159,18 +216,26 @@ install -p -m 755 %{SOURCE2} %{buildroot}%{rrcdir}/
%triggerpostun runtime -- %{scl_prefix}annobin-plugin-gcc
%{rrcdir}/gts-annobin-plugin-select.sh %{_scl_root}
%end
%endif
%files
%doc README
%{_mandir}/man7/%{?scl_name}.*
%if %have_scl_utils == 0
%{_root_sysconfdir}/rpm/macros.%{scl}-enable
%{_root_sysconfdir}/rpm/macros.%{scl}-build
%endif
%if %have_scl_utils
%files runtime
%if %gts_only_gcc_binutils == 0
%attr(0755,-,-) %{rrcdir}/gts-annobin-plugin-select.sh
%dir %{_datadir}/appdata
%endif
%scl_files
%{_root_sysconfdir}/rpm/macros.%{scl}-enable
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) %{_sysconfdir}/selinux-equiv.created
%dir %{_scl_root}/etc/alternatives
%dir %{_datadir}/appdata
%post runtime
if [ ! -f %{_sysconfdir}/selinux-equiv.created ]; then
@ -187,7 +252,11 @@ if [ $1 = 0 ]; then
/usr/sbin/semanage fcontext -d %{_scl_root}
[ -d %{_scl_root} ] && restorecon -R %{_scl_root} || :
fi
%endif
%changelog
* Mon May 5 2025 Siddhesh Poyarekar <siddhesh@redhat.com> - 15.0-1
- Drop scl-utils dependency on c10s and later.
* Wed Apr 30 2025 Siddhesh Poyarekar <siddhesh@redhat.com> - 15.0-0
- new package (RHELPLAN-171631)

109
macros.gts Normal file
View File

@ -0,0 +1,109 @@
# scl-utils RPM macros
#
# Copyright (C) 2012 Red Hat, Inc.
# Written by Jindrich Novy <jnovy@redhat.com>.
%define scl_debug() %{expand:
%define old_debug %{lua:print(rpm.expand("%{debug_package}"):len())}
%undefine _debugsource_packages
%global debug_package %{expand:
%if "%{?old_debug}" == "0"
%{expand: %{nil}}
%else
%if "%{?scl}%{!?scl:0}" == "%{pkg_name}"
%{expand: %{nil}}
%else
%ifnarch noarch
%package debuginfo
Summary: Debug information for package %{name}
Group: Development/Debug
AutoReqProv: 0
%{lua:
debuginfo=tonumber(rpm.expand("%{old_debug}"))
if debuginfo > 0 then
rpm.define("__debug_package 1")
end
}
%description debuginfo
This package provides debug information for package %{name}.
Debug information is useful when developing applications that use this
package or when debugging this package.
%files debuginfo -f debugfiles.list
%defattr(-,root,root)
%endif
%endif
%endif
%{nil}}}
%define scl_prefix() %{?scl:%(if [ "%1" = "%%1" ]; then echo "%{scl}-"; else echo "%1-"; fi)}%{!?scl:%{nil}}
%define scl_package() %{expand:%{!?_root_prefix:
%global pkg_name %1
%global scl_name %{scl}
%global scl_runtime %{scl}-runtime
%global scl_basedir /opt
%{!?scl_vendor: %global scl_vendor rh}
%{!?_scl_prefix: %global _scl_prefix %{scl_basedir}/%{scl_vendor}}
%global _scl_scripts %{_scl_prefix}/%{scl}
%global _scl_root %{_scl_prefix}/%{scl}/root
%global _root_prefix %{_prefix}
%global _root_exec_prefix %{_root_prefix}
%global _root_bindir %{_exec_prefix}/bin
%global _root_sbindir %{_exec_prefix}/sbin
%global _root_libexecdir %{_exec_prefix}/libexec
%global _root_datadir %{_prefix}/share
%global _root_sysconfdir %{_sysconfdir}
%global _root_sharedstatedir %{_sharedstatedir}
%global _root_localstatedir %{_localstatedir}
%global _root_libdir %{_exec_prefix}/%{_lib}
%global _root_includedir %{_prefix}/include
%global _root_infodir %{_datadir}/info
%global _root_mandir %{_datadir}/man
%global _root_initddir %{_sysconfdir}/rc.d/init.d
%global _prefix %{_scl_root}/usr
%global _exec_prefix %{_prefix}
%global _bindir %{_exec_prefix}/bin
%global _sbindir %{_exec_prefix}/sbin
%global _libexecdir %{_exec_prefix}/libexec
%global _datadir %{_prefix}/share
%global _sysconfdir %{_scl_root}/etc
%{?nfsmountable: %global _sysconfdir %{_root_sysconfdir}%{_scl_prefix}/scls/%{scl}}
%{?rh_layout: %global _sysconfdir %{_root_sysconfdir}%{_scl_prefix}/%{scl}}
%global _sharedstatedir %{_scl_root}/var/lib
%{?nfsmountable: %global _sharedstatedir %{_root_localstatedir}%{_scl_prefix}/scls/%{scl}/lib}
%{?rh_layout: %global _sharedstatedir %{_root_localstatedir}%{_scl_prefix}/%{scl}/lib}
%global _localstatedir %{_scl_root}/var
%{?nfsmountable: %global _localstatedir %{_root_localstatedir}%{_scl_prefix}/scls/%{scl}}
%{?rh_layout: %global _localstatedir %{_root_localstatedir}%{_scl_prefix}/%{scl}}
%global _libdir %{_exec_prefix}/%{_lib}
%global _includedir %{_prefix}/include
%global _infodir %{_datadir}/info
%global _mandir %{_datadir}/man
%global _docdir %{_datadir}/doc
%global _defaultdocdir %{_docdir}
}
%{?scl_dependency_generators:%scl_dependency_generators}
%global scl_pkg_name %{scl}-%{pkg_name}
%scl_debug
%global __os_install_post %{expand:
/usr/lib/rpm/brp-compress %{_scl_root}/usr
%{!?__debug_package:/usr/lib/rpm/brp-strip %{__strip}
/usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}
}
/usr/lib/rpm/brp-strip-static-archive %{__strip}
[ -f /usr/lib/rpm/redhat/brp-python-hardlink ] && /usr/lib/rpm/redhat/brp-python-hardlink || /usr/lib/rpm/brp-python-hardlink
%{nil}}
%if "%{?scl}%{!?scl:0}" == "%{pkg_name}"
%endif
%{?scl_package_override:%scl_package_override}
}
%define scl_require() %{_scl_prefix}/%1/enable, %1
%define scl_require_package() %1-%2
%define scl_enable_script() %{expand:
cat >> %{buildroot}%{_scl_scripts}/enable << 'EOF'
eval `/usr/bin/modulecmd bash load %{scl}`
EOF
}