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
This commit is contained in:
Siddhesh Poyarekar 2025-05-15 11:20:18 -04:00
parent b2b180e27a
commit 6890fadb85
3 changed files with 62 additions and 26 deletions

23
enable.in Normal file
View File

@ -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}}

View File

@ -33,13 +33,15 @@ BuildRequires: scl-utils-build
Summary: Package that installs %scl Summary: Package that installs %scl
Name: %scl_name Name: %scl_name
Version: %{gts_ver}.0 Version: %{gts_ver}.0
Release: 3%{?dist} Release: 4%{?dist}
License: GPLv2+ License: GPLv2+
Group: Applications/File Group: Applications/File
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Source0: README Source0: README
Source2: gts-annobin-plugin-select.sh Source2: gts-annobin-plugin-select.sh
Source3: macros.gts Source3: macros.gts
Source4: enable.in
Source5: gcc-toolset-env.in
%if %have_scl_utils %if %have_scl_utils
Requires: %{scl_prefix}runtime Requires: %{scl_prefix}runtime
@ -125,32 +127,16 @@ help2man -N --section 7 ./h2m_helper -o %{?scl_name}.7
# Enable collection script # Enable collection script
# ======================== # ========================
cat <<EOF >enable cat <<'EOF' | tee enable
# General environment variables %{expand:%(cat %{SOURCE4})}
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}}
EOF EOF
%if %have_scl_utils == 0
cat <<'EOF' | tee gcc-toolset-%{gts_ver}-env
%{expand:%(cat %{SOURCE5})}
EOF
%endif
%install %install
%if %have_scl_utils %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 sed 's/^%%define scl_/%%scl_/' %{SOURCE3} > %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-build
%endif %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. # This allows users to build packages using DTS/GTS.
cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-enable << EOF 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 EOF
%if %have_scl_utils %if %have_scl_utils
@ -193,6 +185,11 @@ install -d -m 755 %{buildroot}%{_libdir}/perl5/vendor_perl/auto
mkdir -p %{buildroot}%{rrcdir} mkdir -p %{buildroot}%{rrcdir}
install -p -m 755 %{SOURCE2} %{buildroot}%{rrcdir}/ install -p -m 755 %{SOURCE2} %{buildroot}%{rrcdir}/
%endif %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 %endif
# Install generated man page. # Install generated man page.
@ -221,6 +218,8 @@ install -p -m 644 %{?scl_name}.7 %{buildroot}%{_mandir}/man7/
%{_mandir}/man7/%{?scl_name}.* %{_mandir}/man7/%{?scl_name}.*
%if %have_scl_utils == 0 %if %have_scl_utils == 0
%{_root_sysconfdir}/rpm/macros.%{scl}-enable %{_root_sysconfdir}/rpm/macros.%{scl}-enable
%{_root_bindir}/gcc-toolset-%{gts_ver}-env
%{_root_prefix}/lib/gcc-toolset/%{gts_ver}-env.source
%endif %endif
%if %have_scl_utils %if %have_scl_utils
@ -255,6 +254,9 @@ fi
%endif %endif
%changelog %changelog
* Thu May 15 2025 Siddhesh Poyarekar <siddhesh@redhat.com> - 15.0-4
- New script to replace scl-enable (RHEL-88743).
* Thu May 8 2025 Siddhesh Poyarekar <siddhesh@redhat.com> - 15.0-3 * Thu May 8 2025 Siddhesh Poyarekar <siddhesh@redhat.com> - 15.0-3
- Drop the sudo wrapper script. - Drop the sudo wrapper script.

11
gcc-toolset-env.in Normal file
View File

@ -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