|
|
415ba8 |
#!/usr/bin/sh
|
|
|
415ba8 |
# This is a script to select which GCC spec file fragment
|
|
|
415ba8 |
# should be the destination of the redhat-annobin-cc1 symlink.
|
|
|
415ba8 |
|
|
|
415ba8 |
# Author: Nick Clifton <nickc@redhat.com>
|
|
|
415ba8 |
# Copyright (c) 2021 Red Hat.
|
|
|
415ba8 |
#
|
|
|
415ba8 |
# This is free software; you can redistribute it and/or modify it
|
|
|
415ba8 |
# under the terms of the GNU General Public License as published
|
|
|
415ba8 |
# by the Free Software Foundation; either version 2, or (at your
|
|
|
415ba8 |
# option) any later version.
|
|
|
415ba8 |
|
|
|
415ba8 |
# It is distributed in the hope that it will be useful, but
|
|
|
415ba8 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
415ba8 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
415ba8 |
# GNU General Public License for more details.
|
|
|
415ba8 |
#
|
|
|
415ba8 |
# Usage:
|
|
|
415ba8 |
# redhat-annobin-plugin-select [script-dir]
|
|
|
415ba8 |
#
|
|
|
415ba8 |
# If script-dir is not provided then /usr/lib/rpm/redhat is used
|
|
|
415ba8 |
# as the location where all of the annobin plugin selection files
|
|
|
415ba8 |
# can be found.
|
|
|
415ba8 |
|
|
|
415ba8 |
if test "x$1" = "x" ;
|
|
|
415ba8 |
then
|
|
|
415ba8 |
rrcdir=/usr/lib/rpm/redhat
|
|
|
415ba8 |
else
|
|
|
415ba8 |
rrcdir=$1
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
|
|
|
415ba8 |
# Set this variable to non-zero to enable the generation of debugging
|
|
|
415ba8 |
# messages.
|
|
|
415ba8 |
debug=0
|
|
|
415ba8 |
|
|
|
415ba8 |
# Decide which version of the annobin plugin for gcc should be used.
|
|
|
415ba8 |
# There are two possible versions, one created by the annobin package and one
|
|
|
415ba8 |
# created by the gcc package. The logic selects the gcc version unless both
|
|
|
415ba8 |
# have been built by the same version of the compiler. In that case the
|
|
|
415ba8 |
# annobin version is selected instead.
|
|
|
415ba8 |
#
|
|
|
415ba8 |
# The point of all this is that the annobin plugin is very sensitive to
|
|
|
415ba8 |
# mismatches with the version of gcc that built it. If the plugin is built
|
|
|
415ba8 |
# by version A of gcc, but then run on version B of gcc, it is possible for
|
|
|
415ba8 |
# the plugin to misbehave, which then causes problems if gating tests examine
|
|
|
415ba8 |
# the plugin's output. (This has happened more than once in RHEL...).
|
|
|
415ba8 |
#
|
|
|
415ba8 |
# So the plugin is built both by gcc and by the annobin package. This means
|
|
|
415ba8 |
# that whenever gcc is updated a fresh plugin is built, and the logic below
|
|
|
415ba8 |
# will select that version. But in order to allow annobin development to
|
|
|
415ba8 |
# proceed independtently of gcc, the annobin package can also update its
|
|
|
415ba8 |
# version of the plugin, and the logic will select this new version.
|
|
|
415ba8 |
|
|
|
415ba8 |
# This is where the annobin package stores the information on the version
|
|
|
415ba8 |
# of gcc that built the annobin plugin.
|
|
|
415ba8 |
aver=`gcc --print-file-name=plugin`/annobin-plugin-version-info
|
|
|
415ba8 |
|
|
|
415ba8 |
# This is where the gcc package stores its version information.
|
|
|
415ba8 |
gver=`gcc --print-file-name=rpmver`
|
|
|
415ba8 |
|
|
|
415ba8 |
aplugin=`gcc --print-file-name=plugin`/annobin.so.0.0.0
|
|
|
415ba8 |
gplugin=`gcc --print-file-name=plugin`/gcc-annobin.so.0.0.0
|
|
|
415ba8 |
|
|
|
415ba8 |
# This is the file that needs to be updated when either of those version
|
|
|
415ba8 |
# files changes.
|
|
|
415ba8 |
rac1=redhat-annobin-cc1
|
|
|
415ba8 |
|
|
|
415ba8 |
# This is the GCC spec file fragment that selects the gcc-built version of
|
|
|
415ba8 |
# the annobin plugin
|
|
|
415ba8 |
select_gcc=redhat-annobin-select-gcc-built-plugin
|
|
|
415ba8 |
|
|
|
415ba8 |
# This is the GCC spec file fragment that selects the annobin-built version
|
|
|
415ba8 |
# of the annobin plugin
|
|
|
415ba8 |
select_annobin=redhat-annobin-select-annobin-built-plugin
|
|
|
415ba8 |
|
|
|
415ba8 |
install_annobin_version=0
|
|
|
415ba8 |
install_gcc_version=0
|
|
|
415ba8 |
|
|
|
415ba8 |
if [ -f $aplugin ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
if [ -f $gplugin ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Both plugins exist, checking version information"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
|
|
|
415ba8 |
if [ -f $gver ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
if [ -f $aver ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Both plugin version files exist - comparing..."
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
|
|
|
415ba8 |
# Get the first line from the version info files. This is just in
|
|
|
415ba8 |
# vase there are extra lines in the files.
|
|
|
415ba8 |
avers=`head --lines=1 $aver`
|
|
|
415ba8 |
gvers=`head --lines=1 $gver`
|
|
|
415ba8 |
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Annobin plugin built by gcc $avers"
|
|
|
415ba8 |
echo " redhat-rpm-config: GCC plugin built by gcc $gvers"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
|
|
|
415ba8 |
# If both plugins were built by the same version of gcc then select
|
|
|
415ba8 |
# the one from the annobin package (in case it is built from newer
|
|
|
415ba8 |
# sources). If the plugin builder versions differ, select the gcc
|
|
|
415ba8 |
# built version instead. This assumes that the gcc built version
|
|
|
415ba8 |
# always matches the installed gcc, which should be true.
|
|
|
415ba8 |
if [ $avers = $gvers ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Both plugins built by the same compiler - using annobin-built plugin"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
install_annobin_version=1
|
|
|
415ba8 |
else
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Versions differ - using gcc-built plugin"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
install_gcc_version=1
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
else
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Annobin version file does not exist, using gcc-built plugin"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
install_gcc_version=1
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
else
|
|
|
415ba8 |
if [ -f $aver ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
# FIXME: This is suspicious. If the installed GCC does not supports plugins
|
|
|
415ba8 |
# then enabling the annobin plugin will not work.
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: GCC plugin version file does not exist, using annobin-built plugin"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
install_annobin_version=1
|
|
|
415ba8 |
else
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Neither version file exists - playing safe and using gcc-built plugin"
|
|
|
415ba8 |
echo " redhat-rpm-config: Note: expected to find $aver and/or $gver"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
install_gcc_version=1
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
else
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Only the annobin plugin exists - using that"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
install_annobin_version=1
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
else
|
|
|
415ba8 |
if [ -f $gplugin ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Only the gcc plugin exists - using that"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
else
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Neither plugin exists - playing safe and using gcc-built plugin"
|
|
|
415ba8 |
echo " redhat-rpm-config: Note: expected to find $aplugin and/or $gplugin"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
install_gcc_version=1
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
|
|
|
415ba8 |
if [ $install_annobin_version -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Installing annobin version of $rac1"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
pushd $rrcdir > /dev/null
|
|
|
415ba8 |
rm -f $rac1
|
|
|
415ba8 |
ln -s $select_annobin "$rac1"
|
|
|
415ba8 |
popd > /dev/null
|
|
|
415ba8 |
|
|
|
415ba8 |
else if [ $install_gcc_version -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
if [ $debug -eq 1 ]
|
|
|
415ba8 |
then
|
|
|
415ba8 |
echo " redhat-rpm-config: Installing gcc version of $rac1"
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
pushd $rrcdir > /dev/null
|
|
|
415ba8 |
rm -f $rac1
|
|
|
415ba8 |
ln -s $select_gcc $rac1
|
|
|
415ba8 |
popd > /dev/null
|
|
|
415ba8 |
fi
|
|
|
415ba8 |
fi
|