From b0073c26057df2eaeec218ddd7f43acf1c9f0014 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Wed, 30 Apr 2025 10:56:11 -0400 Subject: [PATCH] Initial version Based on commit 91444113e6e598fe55b7002e46f04cd241f75f46, adapted for RHEL10. Resolves: RHEL-81745 --- gating.yaml | 7 ++ gcc-toolset-15.spec | 193 +++++++++++++++++++++++++++++++++ sources | 3 + tests/gts-smoketest/PURPOSE | 3 + tests/gts-smoketest/runtest.sh | 10 ++ tests/tests.yml | 8 ++ 6 files changed, 224 insertions(+) create mode 100644 gating.yaml create mode 100644 gcc-toolset-15.spec create mode 100644 sources create mode 100644 tests/gts-smoketest/PURPOSE create mode 100755 tests/gts-smoketest/runtest.sh create mode 100644 tests/tests.yml diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..af54d4f --- /dev/null +++ b/gating.yaml @@ -0,0 +1,7 @@ +--- !Policy +product_versions: + - rhel-10 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/gcc-toolset-15.spec b/gcc-toolset-15.spec new file mode 100644 index 0000000..240da9d --- /dev/null +++ b/gcc-toolset-15.spec @@ -0,0 +1,193 @@ +%global __python /usr/bin/python3 +%global scl gcc-toolset-15 +%global scl_prefix gcc-toolset-15- +%global scl_name %scl +BuildRequires: scl-utils-build +%{?scl_package:%scl_package %scl} + +Summary: Package that installs %scl +Name: %scl_name +Version: 15.0 +Release: 0%{?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 + +Requires: %{scl_prefix}runtime +Requires: %{scl_prefix}gcc %{scl_prefix}gcc-c++ %{scl_prefix}gcc-gfortran +Requires: %{scl_prefix}binutils +Requires: %{scl_prefix}gdb +Requires: %{scl_prefix}dwz +Requires: %{scl_prefix}annobin-plugin-gcc +Obsoletes: %{name} < %{version}-%{release} +Obsoletes: %{scl_prefix}dockerfiles < %{version}-%{release} + +BuildRequires: iso-codes +BuildRequires: help2man +%if 0%{?rhel} >= 8 +BuildRequires: python3-devel +%endif + +%global rrcdir %{_scl_root}/usr/lib/rpm/redhat + +%description +This is the main package for %scl Software Collection. + +%package runtime +Summary: Package that handles %scl Software Collection. +Group: Applications/File +Requires: scl-utils >= 20120927-11 +Obsoletes: %{name}-runtime < %{version}-%{release} +%if 0%{?rhel} >= 7 +%{?scl_package:Requires(post): %{_root_sbindir}/semanage %{_root_sbindir}/restorecon} +%{?scl_package:Requires(postun): %{_root_sbindir}/semanage %{_root_sbindir}/restorecon} +%else +Requires(post): libselinux policycoreutils-python +Requires(postun): libselinux policycoreutils-python +%endif + +%description runtime +Package shipping essential scripts to work with %scl Software Collection. + +%prep +%setup -c -T + +# This section generates README file from a template and creates man page +# from that file, expanding RPM macros in the template file. +cat <<'EOF' | tee README +%{expand:%(cat %{SOURCE0})} +EOF + +%build + +# Temporary helper script used by help2man. +cat <<\EOF | tee h2m_helper +#!/bin/sh +if [ "$1" = "--version" ]; then + printf '%%s' "%{?scl_name} %{version} Software Collection" +else + cat README +fi +EOF +chmod a+x h2m_helper +# Generate the man page. +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}} +EOF + +# Sudo script +# =========== +cat <<'EOF' > sudo +%{expand:%(cat %{SOURCE1})} +EOF + +%install +(%{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 + +# 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} || : +EOF + +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} +install -p -m 755 sudo %{buildroot}%{_bindir}/ + +# Other directories that should be owned by the runtime +install -d -m 755 %{buildroot}%{_datadir}/appdata +# Otherwise unowned perl directories +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 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. + +%triggerin runtime -- %{scl_prefix}annobin-plugin-gcc %{scl_prefix}gcc-plugin-annobin +%{rrcdir}/gts-annobin-plugin-select.sh %{_scl_root} +%end + +# We also trigger when annobin is uninstalled. This allows us to switch +# over to the gcc generated version of the plugin. It does not matter if +# gcc is uninstalled, since if that happens the plugin cannot be used. + +%triggerpostun runtime -- %{scl_prefix}annobin-plugin-gcc +%{rrcdir}/gts-annobin-plugin-select.sh %{_scl_root} +%end + +%files +%doc README +%{_mandir}/man7/%{?scl_name}.* + +%files runtime +%attr(0755,-,-) %{rrcdir}/gts-annobin-plugin-select.sh +%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 + /usr/sbin/semanage fcontext -a -e / %{_scl_root} + restorecon -R %{_scl_root} + touch %{_sysconfdir}/selinux-equiv.created +fi + +%preun runtime +[ $1 = 0 ] && rm -f %{_sysconfdir}/selinux-equiv.created || : + +%postun runtime +if [ $1 = 0 ]; then + /usr/sbin/semanage fcontext -d %{_scl_root} + [ -d %{_scl_root} ] && restorecon -R %{_scl_root} || : +fi + +%changelog +* Wed Apr 30 2025 Siddhesh Poyarekar - 15.0-0 +- new package (RHELPLAN-171631) diff --git a/sources b/sources new file mode 100644 index 0000000..0438a75 --- /dev/null +++ b/sources @@ -0,0 +1,3 @@ +SHA512 (README) = 213f19a40aa61549f533414e1042ec9d079ec45923953c69bb84007cdba19e54d9baac44422cd6b991f8acacfb13329e4cb027ffd762505d35814603dbb4dcf2 +SHA512 (gts-annobin-plugin-select.sh) = f5e5f4dc054bdd09c6d185bc3c671376ff8b825c8fa3f2969e25e10358405aa105f74154c63b6dc025cbe7e09eb24693664048685aaf481cc2a65d12ad9476b8 +SHA512 (sudo.sh) = 1378412b39b31f1f76b9d7b9fce5ea679e764a2fd85804fbc3b9ce1c8b5e9b1694be854b4407d1b5dba229763127c9cc64bc09bdf87b384c93536b97d001520d diff --git a/tests/gts-smoketest/PURPOSE b/tests/gts-smoketest/PURPOSE new file mode 100644 index 0000000..bdf2003 --- /dev/null +++ b/tests/gts-smoketest/PURPOSE @@ -0,0 +1,3 @@ +Test Name: gts-smoketest +Author: +Short Description: Check the metapackage installability diff --git a/tests/gts-smoketest/runtest.sh b/tests/gts-smoketest/runtest.sh new file mode 100755 index 0000000..bc97b7c --- /dev/null +++ b/tests/gts-smoketest/runtest.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e +set -x + +# This is a metapackage. It's main purpose is to pull other packages +# into play via the rpm deps. +rpm -q gcc-toolset-15 +echo +echo RESULT: PASS diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..f207b0f --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,8 @@ +--- +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + tests: + - gts-smoketest