Browse Source

initial package creation

Signed-off-by: Toshaan Bharvani <toshaan@powerel.org>
master
Toshaan Bharvani 6 months ago
commit
973d13ba06
  1. 29
      SOURCES/README
  2. 226
      SOURCES/gts-annobin-plugin-select.sh
  3. 41
      SOURCES/sudo.sh
  4. 222
      SPECS/gcc-toolset-13.spec

29
SOURCES/README

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
Package %{scl_name} is the main package for Red Hat GCC
Toolset 13. By installing the %{scl_name} package, you will get
the working set of packages that are included in Red Hat GCC
Toolset 13, which includes development and debugging tools.

Usage: scl enable %{scl} <command>

Red Hat GCC Toolset allows you to build and execute applications
which are not located in the filesystem root hierarchy, but are
stored in an alternative location, which is %{_scl_root} in case
of the %{scl_name} collection.

Examples:
scl enable %{scl_name} 'command --arg'
Run a specific command with the argument --arg within the %{scl_name}
Red Hat GCC Toolset environment.

scl enable %{scl_name} 'gcc'
Run GCC from the %{scl_name} Red Hat GCC Toolset.

scl enable %{scl_name} 'bash'
Run an interactive shell wherein the %{scl_name} software collection
is enabled.

scl enable %{scl_name} 'man gcc'
Show man pages for the gcc command, which is a part of the
%{scl_name} Red Hat GCC Toolset.

Report bugs to <http://bugzilla.redhat.com>.

226
SOURCES/gts-annobin-plugin-select.sh

@ -0,0 +1,226 @@ @@ -0,0 +1,226 @@
#!/usr/bin/sh
# This is a script to switch the symlinks in a GTS gcc's plugin
# directory so that they select either the GTS-annobin provided
# plugin or the GTS-gcc provided plugin.

# Author: Nick Clifton <nickc@redhat.com>
# Copyright (c) 2021-2022 Red Hat.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2, or (at your
# option) any later version.

# It is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Usage:
# gts-annobin-plugin-select scl_root
#

# Set this variable to non-zero to enable the generation of debugging
# messages.
debug=0

if test "x$1" = "x" ;
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Must provide a root directory"
fi
exit 1
else
scl_root=$1
fi

# This script is similar to the redhat-annobin-plugin-select.sh script which
# is part of the redhat-rpm-config package. That scripts decides between two
# versions of the annobin plugin for the system compiler and stores it choice
# in a symlink in the /usr/lib/rpm/redhat directory. The choice eventually
# resolves into the system gcc attempting to load either a plugin called
# annobin.so or a plugin called gcc-annobin.so.

# In a GTS environment the choice made by redhat-annobin-plugin-select.sh
# might not be appropriate (or even possible). The choice cannot be changed
# because the system compilation environment must remain instact. So instead
# the GTS versions of gcc and annobin install plugins called gts-annobin.so
# and gts-gcc-annobin.so (into the GTS gcc's plugin directory) and this script
# creates a pair of symlinks called annobin.so and gcc-annobin.so. In this
# way the decision made by redhat-annobin-plugin-select.sh is overridden
# without affecting any system files.

# We cannot be sure that this script will run inside a GTS enabled shell,
# so we have to use absolute paths.
gts_gcc=$scl_root/usr/bin/gcc

if [ ! -x $gts_gcc ]
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Could not find gcc. Expected: $gts_gcc"
fi
exit 0
fi

# This is where the annobin package stores the information on the version
# of gcc that built the annobin plugin.
aver=`$gts_gcc --print-file-name=plugin`/annobin-plugin-version-info

# This is where the gcc package stores its version information.
gver=`$gts_gcc --print-file-name=rpmver`

aplugin=`$gts_gcc --print-file-name=plugin`/gts-annobin.so.0.0.0
gplugin=`$gts_gcc --print-file-name=plugin`/gts-gcc-annobin.so.0.0.0

install_annobin_version=0
install_gcc_version=0

if [ -f $aplugin ]
then
if [ -f $gplugin ]
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Both plugins exist, checking version information"
fi

if [ -f $gver ]
then
if [ -f $aver ]
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Both plugin version files exist - comparing..."
fi

# Get the first line from the version info files. This is just in
# case there are extra lines in the files.
avers=`head --lines=1 $aver`
gvers=`head --lines=1 $gver`

if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Annobin plugin built by gcc $avers"
echo " gts-annobin-plugin-select: GCC plugin built by gcc $gvers"
fi

# If both plugins were built by the same version of gcc then select
# the one from the annobin package (in case it is built from newer
# sources). If the plugin builder versions differ, select the gcc
# built version instead. This assumes that the gcc built version
# always matches the installed gcc, which should be true.
if [ $avers = $gvers ]
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Both plugins built by the same compiler - using annobin-built plugin"
fi
install_annobin_version=1
else
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Versions differ - using gcc-built plugin"
fi
install_gcc_version=1
fi
else
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Annobin version file does not exist, using gcc-built plugin"
fi
install_gcc_version=1
fi
else
if [ -f $aver ]
then
# FIXME: This is suspicious. If the installed GCC does not supports plugins
# then enabling the annobin plugin will not work.
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: GCC plugin version file does not exist, using annobin-built plugin"
fi
install_annobin_version=1
else
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Neither version file exists - playing safe and using gcc-built plugin"
echo " gts-annobin-plugin-select: Note: expected to find $aver and/or $gver"
fi
install_gcc_version=1
fi
fi
else
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Only the annobin plugin exists - using that"
fi
install_annobin_version=1
fi
else
if [ -f $gplugin ]
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Only the gcc plugin exists - using that"
fi
install_gcc_version=1
else
aplugin=`$gts_gcc --print-file-name=plugin`/annobin.so.0.0.0

if [ -f $aplugin ]
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Original annobin plugin exists - renaming"
echo " gts-annobin-plugin-select: Using renamed original annobin plugin"
fi
pushd `$gts_gcc --print-file-name=plugin` > /dev/null
mv annobin.so.0.0.0 gts-annobin.so.0.0.0
popd > /dev/null
install_annobin_version=1
else
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Neither plugin exists - playing safe and not changing anything"
echo " gts-annobin-plugin-select: Note: expected to find $aplugin and/or $gplugin"
fi
fi
fi
fi

if [ $install_annobin_version -eq 1 ]
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Setting symlinks for the annobin version of the plugin"
fi
pushd `$gts_gcc --print-file-name=plugin` > /dev/null
rm -f gcc-annobin.so.0.0.0 annobin.so.0.0.0 gcc-annobin.so annobin.so
ln -s gts-annobin.so.0.0.0 annobin.so
ln -s gts-annobin.so.0.0.0 gcc-annobin.so
ln -s gts-annobin.so.0.0.0 annobin.so.0.0.0
ln -s gts-annobin.so.0.0.0 gcc-annobin.so.0.0.0
popd > /dev/null
else if [ $install_gcc_version -eq 1 ]
then
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: Setting symlinks for the gcc version of the plugin"
fi
pushd `$gts_gcc --print-file-name=plugin` > /dev/null
rm -f gcc-annobin.so.0.0.0 annobin.so.0.0.0 gcc-annobin.so annobin.so
ln -s gts-gcc-annobin.so.0.0.0 annobin.so
ln -s gts-gcc-annobin.so.0.0.0 gcc-annobin.so
ln -s gts-gcc-annobin.so.0.0.0 annobin.so.0.0.0
ln -s gts-gcc-annobin.so.0.0.0 gcc-annobin.so.0.0.0
popd > /dev/null
else
if [ $debug -eq 1 ]
then
echo " gts-annobin-plugin-select: NOT CHANGING SYMLINKS"
fi
fi
fi

41
SOURCES/sudo.sh

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
#! /bin/bash

# Emulate /usr/bin/sudo, so that SCL environment variables
# are passed through via an /bin/env wrapper.
# Includes work by Andy Fong <boringuy@gmail.com>

cmd_started=false
is_option_param_next=false
for arg in "$@"
do
case "$arg" in
*\'*)
arg= ;;
esac
if [ "$cmd_started" = true ]; then
cmd_options="$cmd_options '$arg'"
elif [ "$is_option_param_next" = true ]; then
sudo_options="$sudo_options $arg"
is_option_param_next=false
elif [[ $arg == -* ]]; then
sudo_options="$sudo_options $arg"
case "$arg" in
# all the options that take a parameter
"-g" | "-h" | "-p" | "-u" | "-U" | "-C" | "-s" | "-r" | "-t" | "-T")
is_option_param_next=true
;;
"--")
cmd_started=true
;;
esac
elif [[ $arg == *=* ]]; then
sudo_options="$sudo_options $arg"
else
cmd_options="$cmd_options '$arg'"
cmd_started=true
fi
done
if [ "$sudo_options" == "" ]; then
sudo_options="-E"
fi
exec /usr/bin/sudo $sudo_options env LD_LIBRARY_PATH=$LD_LIBRARY_PATH PATH=$PATH scl enable %{scl} "$cmd_options"

222
SPECS/gcc-toolset-13.spec

@ -0,0 +1,222 @@ @@ -0,0 +1,222 @@
%global __python /usr/bin/python3
%global scl gcc-toolset-13
%global scl_prefix gcc-toolset-13-
%global scl_name %scl
BuildRequires: scl-utils-build
%{?scl_package:%scl_package %scl}

Summary: Package that installs %scl
Name: %scl_name
Version: 13.0
Release: 2%{?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 <<EOF >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_devtoolset13 %%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
* Thu Aug 3 2023 Marek Polacek <polacek@redhat.com> - 13.0-2
- require GTS 13 packages (#2217519)

* Thu May 4 2023 Marek Polacek <polacek@redhat.com> - 13.0-1
- don't require other GTS 13 packages yet

* Fri Apr 21 2023 Marek Polacek <polacek@redhat.com> - 13.0-0
- update to GTS 13 (#2188491)
- drop gcc-toolset-13-build

* Mon Dec 05 2022 Nick Clifton <nickc@redhat.com> - 12.0-6
- Use triggers to select which version of the annobin plugin should be used. (#211175)

* Wed Jun 29 2022 Marek Polacek <polacek@redhat.com> - 12.0-5
- require -annobin-plugin-gcc (#2102356)

* Mon Jun 13 2022 Marek Polacek <polacek@redhat.com> - 12.0-4
- NVR bump and rebuild

* Fri May 27 2022 Marek Polacek <polacek@redhat.com> - 12.0-3
- use rpm/macros.%{scl}-enable for %enable_devtoolset12 and put it in
the -runtime subpackage (#2009528)

* Fri May 27 2022 Marek Polacek <polacek@redhat.com> - 12.0-2
- cut down the required packages, remove -toolchain and -perftools

* Mon May 16 2022 Martin Cermak <mcermak@redhat.com> - 12.0-1
- NVR bump and rebuild, introduce CI gating setup

* Tue May 10 2022 Marek Polacek <polacek@redhat.com> - 12.0-0
- new package (#2077277)
Loading…
Cancel
Save