From 6890fadb858a1059a4a7c104c1336d30e97f3d47 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Thu, 15 May 2025 11:20:18 -0400 Subject: [PATCH] New script gcc-toolset-15-env Add a new script to replace the `scl enable` command. Also update the `enable_devtoolset` macro to instead be called `enable_gcctoolset` and have it use a new installed script instead of an SCL snippet. Resolves: RHEL-88743 --- enable.in | 23 +++++++++++++++++++ gcc-toolset-15.spec | 54 +++++++++++++++++++++++---------------------- gcc-toolset-env.in | 11 +++++++++ 3 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 enable.in create mode 100644 gcc-toolset-env.in diff --git a/enable.in b/enable.in new file mode 100644 index 0000000..acdd255 --- /dev/null +++ b/enable.in @@ -0,0 +1,23 @@ +# General environment variables +export PATH=%{_bindir}${PATH:+:${PATH}} +export MANPATH=%{_mandir}${MANPATH:+:${MANPATH}} +export INFOPATH=%{_infodir}${INFOPATH:+:${INFOPATH}} +# ??? We probably don't need this anymore. +export PCP_DIR=%{_scl_root} +# bz847911 workaround: +# we need to evaluate rpm's installed run-time % { _libdir }, not rpmbuild time +# or else /etc/ld.so.conf.d files? +rpmlibdir=$(rpm --eval "%%{_libdir}") +# bz1017604: On 64-bit hosts, we should include also the 32-bit library path. +# bz1873882: On 32-bit hosts, we should include also the 64-bit library path. +# bz2027377: Avoid unbound variables +if [ "$rpmlibdir" != "${rpmlibdir/lib64/}" ]; then + rpmlibdir32=":%{_scl_root}${rpmlibdir/lib64/lib}" + rpmlibdir64= +else + rpmlibdir64=":%{_scl_root}${rpmlibdir/lib/lib64}" + rpmlibdir32= +fi +# Prepend the usual /opt/.../usr/lib{64,}. +export LD_LIBRARY_PATH=%{_scl_root}$rpmlibdir$rpmlibdir64$rpmlibdir32${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} +export PKG_CONFIG_PATH=%{_libdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} diff --git a/gcc-toolset-15.spec b/gcc-toolset-15.spec index 4d5adf6..f2de75b 100644 --- a/gcc-toolset-15.spec +++ b/gcc-toolset-15.spec @@ -33,13 +33,15 @@ BuildRequires: scl-utils-build Summary: Package that installs %scl Name: %scl_name Version: %{gts_ver}.0 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2+ Group: Applications/File BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Source0: README Source2: gts-annobin-plugin-select.sh Source3: macros.gts +Source4: enable.in +Source5: gcc-toolset-env.in %if %have_scl_utils Requires: %{scl_prefix}runtime @@ -125,32 +127,16 @@ help2man -N --section 7 ./h2m_helper -o %{?scl_name}.7 # Enable collection script # ======================== -cat <enable -# General environment variables -export PATH=%{_bindir}\${PATH:+:\${PATH}} -export MANPATH=%{_mandir}\${MANPATH:+:\${MANPATH}} -export INFOPATH=%{_infodir}\${INFOPATH:+:\${INFOPATH}} -# ??? We probably don't need this anymore. -export PCP_DIR=%{_scl_root} -# bz847911 workaround: -# we need to evaluate rpm's installed run-time % { _libdir }, not rpmbuild time -# or else /etc/ld.so.conf.d files? -rpmlibdir=\$(rpm --eval "%%{_libdir}") -# bz1017604: On 64-bit hosts, we should include also the 32-bit library path. -# bz1873882: On 32-bit hosts, we should include also the 64-bit library path. -# bz2027377: Avoid unbound variables -if [ "\$rpmlibdir" != "\${rpmlibdir/lib64/}" ]; then - rpmlibdir32=":%{_scl_root}\${rpmlibdir/lib64/lib}" - rpmlibdir64= -else - rpmlibdir64=":%{_scl_root}\${rpmlibdir/lib/lib64}" - rpmlibdir32= -fi -# Prepend the usual /opt/.../usr/lib{64,}. -export LD_LIBRARY_PATH=%{_scl_root}\$rpmlibdir\$rpmlibdir64\$rpmlibdir32\${LD_LIBRARY_PATH:+:\${LD_LIBRARY_PATH}} -export PKG_CONFIG_PATH=%{_libdir}/pkgconfig\${PKG_CONFIG_PATH:+:\${PKG_CONFIG_PATH}} +cat <<'EOF' | tee enable +%{expand:%(cat %{SOURCE4})} EOF +%if %have_scl_utils == 0 +cat <<'EOF' | tee gcc-toolset-%{gts_ver}-env +%{expand:%(cat %{SOURCE5})} +EOF +%endif + %install %if %have_scl_utils @@ -168,9 +154,15 @@ mkdir -p %{buildroot}%{_root_sysconfdir}/rpm sed 's/^%%define scl_/%%scl_/' %{SOURCE3} > %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-build %endif +%if %have_scl_utils +%define source_cmd source scl_source enable %{scl} +%else +%define source_cmd source %{_root_prefix}/lib/gcc-toolset/%{gts_ver}-env.source +%endif + # This allows users to build packages using DTS/GTS. cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-enable << EOF -%%enable_devtoolset%{gts_ver} %%global ___build_pre %%{___build_pre}; source scl_source enable %{scl} || : +%%enable_gcctoolset%{gts_ver} %%global ___build_pre %%{___build_pre}; %source_cmd || : EOF %if %have_scl_utils @@ -193,6 +185,11 @@ install -d -m 755 %{buildroot}%{_libdir}/perl5/vendor_perl/auto mkdir -p %{buildroot}%{rrcdir} install -p -m 755 %{SOURCE2} %{buildroot}%{rrcdir}/ %endif +%else +install -d -m 755 %{buildroot}%{_root_bindir} +install -p -m 755 gcc-toolset-%{gts_ver}-env %{buildroot}%{_root_bindir}/ +install -d -m 755 %{buildroot}%{_root_prefix}/lib/gcc-toolset +install -p -m 755 enable %{buildroot}%{_root_prefix}/lib/gcc-toolset/%{gts_ver}-env.source %endif # Install generated man page. @@ -221,6 +218,8 @@ install -p -m 644 %{?scl_name}.7 %{buildroot}%{_mandir}/man7/ %{_mandir}/man7/%{?scl_name}.* %if %have_scl_utils == 0 %{_root_sysconfdir}/rpm/macros.%{scl}-enable +%{_root_bindir}/gcc-toolset-%{gts_ver}-env +%{_root_prefix}/lib/gcc-toolset/%{gts_ver}-env.source %endif %if %have_scl_utils @@ -255,6 +254,9 @@ fi %endif %changelog +* Thu May 15 2025 Siddhesh Poyarekar - 15.0-4 +- New script to replace scl-enable (RHEL-88743). + * Thu May 8 2025 Siddhesh Poyarekar - 15.0-3 - Drop the sudo wrapper script. diff --git a/gcc-toolset-env.in b/gcc-toolset-env.in new file mode 100644 index 0000000..7a96adb --- /dev/null +++ b/gcc-toolset-env.in @@ -0,0 +1,11 @@ +# Environment wrapper for GCC Toolset %{gts_ver} + +source %{_root_prefix}/lib/gcc-toolset/%{gts_ver}-env.source + +if [ -z $1 ]; then + cmd="/bin/sh" +else + cmd=$* +fi + +exec $cmd