macros: add %multilib_capable macro

Version: 1-5
This commit is contained in:
Pavel Raiskup 2016-06-22 11:07:22 +02:00
parent f2fed8528f
commit 657cae1dad
5 changed files with 159 additions and 37 deletions

View File

@ -19,5 +19,11 @@
# Macro multilib_fix_c_header is expected to be called
# from %install (usually after 'make install' call) like:
# multilib_fix_c_header --file %{_includedir}/broken-header.h
# %multilib_fix_c_header --file %{_includedir}/broken-header.h
%multilib_fix_c_header @ML_FIX@ --buildroot "$RPM_BUILD_ROOT"
# Expands to 'true' if the actual architecture should take care to make
# the package multilib-clean. Otherwise expands to 'false'.
# Typically you can use this macro like:
# %multilib_capable && { do_some_multilib_workarounds ; }
%multilib_capable %{expand:%(@ML_INFO@ --multilib-capable)}

View File

@ -1,7 +1,7 @@
#! /bin/sh
# Fix multilib issue for header files.
# Copyright (C) 2015 Red Hat, Inc.
# Copyright (C) 2015-2016 Red Hat, Inc.
# Written by Pavel Raiskup <praiskup@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -22,14 +22,9 @@
# Replace the multilib-unclean file with multilib-clean stub, while the
# original file is moved to unique architecture-specific location.
progname=$(basename "$0")
opt_arch=$(uname -i)
# See rhbz#1242873 for more info.
test "$opt_arch" = ppc64p7 && opt_arch=ppc64
@LIB@
opt_buildroot=$(pwd)
opt_verbose=:
opt_field_separator=-
# TODO: we could pretty easily implement other then 'cpp-header' stubs, if the
@ -97,31 +92,13 @@ script only through available RPM macros.
--field-separator by default we move filename.h to filename<SEP><ARCH>.h; this
option allows you to override the <SEP> part
--verbose print some useful information
--arch override arch detection (mostly for testing purposes)
--help show this help
EOF
$_h_exit && exit "$1"
}
verbose ()
{
$opt_verbose && echo "INFO: $progname: $*"
}
die ()
{
echo >&2 " # $*"
print_help 1
}
error ()
{
error_occurred=:
echo >&2 " ! $*"
}
error_occurred=false
while test $# -gt 0
do
_opt=$1 ; shift
@ -140,6 +117,7 @@ do
esac
done
$error_occurred && print_help 1
fix_arch opt_arch
for i in arch buildroot file
do
@ -167,15 +145,10 @@ multilib_file="$destdir/$filename$opt_field_separator$opt_arch$suffix"
test -f "$original_file" || die "can't find '$original_file'"
case $opt_arch in
# we only apply this to known Red Hat multilib arches, per bug #177564
i386|x86_64|ppc|ppc64|s390|s390x|sparc|sparc64)
;;
*)
verbose "we don't need multilib haeder hack for '$opt_arch' architecture (no-op)"
exit 0
;;
esac
is_multilib "$opt_arch" || {
verbose "we don't need multilib haeder hack for '$opt_arch' architecture (no-op)"
exit 0
}
verbose "moving: '$original_file' to '$multilib_file'"

73
multilib-info Executable file
View File

@ -0,0 +1,73 @@
# Probe system for multilib information.
# Copyright (C) 2016 Red Hat, Inc.
# Written by Pavel Raiskup <praiskup@redhat.com>
#
# This program 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 of the License, or
# (at your option) any later version.
#
# This program 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.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@LIB@
opt_multilib_capable=false
print_help ()
{
_h_exit=false
test -n "$1" && _h_exit=:
cat <<EOF
Usage: $progname [OPTIONS]
Probe system for interesting multilib information.
--multilib-capable could package built on this box play some role on multilib
capable system? Prints 'true' or 'false'.
--arch override arch detection (mostly for testing purposes)
EOF
$_h_exit && exit "$1"
}
while test $# -gt 0
do
_opt=$1 ; shift
case $_opt in
--arch)
_raw_opt=$(echo "$_opt" | sed -e 's/^--//' -e 's/-/_/g')
eval "opt_$_raw_opt=\$1"
shift || die "$_opt requires argument"
;;
--multilib-capable)
_raw_opt=$(echo "$_opt" | sed -e 's/^--//' -e 's/-/_/g')
eval "opt_$_raw_opt=:"
;;
--help)
print_help 0
;;
*)
error "unexpected '$_opt' program argument"
;;
esac
done
$error_occurred && print_help 1
fix_arch opt_arch
$opt_multilib_capable && {
if is_multilib "$opt_arch"; then
echo true
else
echo false
fi
exit 0
}
print_help 1

55
multilib-library Normal file
View File

@ -0,0 +1,55 @@
progname=$(basename "$0")
opt_verbose=:
opt_arch=$(uname -i)
multilib_arches="
i386 x86_64
ppc ppc64
s390 s390x
sparc sparc64
"
verbose ()
{
$opt_verbose && echo >&2 "INFO: $progname: $*"
}
die ()
{
echo >&2 " # $*"
print_help 1
}
error ()
{
error_occurred=:
echo >&2 " ! $*"
}
is_multilib ()
{
_m_result=false
for _m_arch in $multilib_arches
do
if test "$_m_arch" = "$1"; then
_m_result=:
break
fi
done
$_m_result
}
fix_arch ()
{
eval "_arch=\$$1"
case $_arch in
# See rhbz#1242873 for more info.
ppc64p7)
eval "$1=ppc64"
;;
esac
}
error_occurred=false
# vi: ft=sh

View File

@ -19,6 +19,8 @@ Source0: multilib-fix
Source1: macros.ml
Source2: README
Source3: COPYING
Source4: multilib-library
Source5: multilib-info
BuildArch: noarch
@ -37,15 +39,28 @@ install -m 644 %{SOURCE2} %{SOURCE3} .
%build
%global ml_fix %rrcdir/multilib-fix
%global ml_info %rrcdir/multilib-info
lib_sed_pattern='/@LIB@/ {
r %{SOURCE4}
d
}'
sed -e 's|@ML_FIX@|%ml_fix|g' \
-e 's|@ML_INFO@|%ml_info|g' \
%{SOURCE1} > macros.multilib
sed -e "$lib_sed_pattern" \
%{SOURCE0} > multilib-fix
sed -e "$lib_sed_pattern" \
%{SOURCE5} > multilib-info
%install
mkdir -p %{buildroot}%{rrcdir}
mkdir -p %{buildroot}%{macrosdir}
install -m 644 -p macros.multilib %{buildroot}/%{macrosdir}
install -m 755 -p %{SOURCE0} %{buildroot}/%{ml_fix}
install -m 755 -p multilib-fix %{buildroot}/%{ml_fix}
install -m 755 -p multilib-info %{buildroot}/%{ml_info}
%files