From 657cae1dad81e80e07bbfa88deb002baeb734e16 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Jun 22 2016 11:21:40 +0000 Subject: macros: add %multilib_capable macro Version: 1-5 --- diff --git a/macros.ml b/macros.ml index f0fdb02..4416210 100644 --- a/macros.ml +++ b/macros.ml @@ -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)} diff --git a/multilib-fix b/multilib-fix index b1a6898..eafb0b7 100755 --- a/multilib-fix +++ b/multilib-fix @@ -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 # # 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.h; this option allows you to override the 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'" diff --git a/multilib-info b/multilib-info new file mode 100755 index 0000000..21dda24 --- /dev/null +++ b/multilib-info @@ -0,0 +1,73 @@ +# Probe system for multilib information. +# Copyright (C) 2016 Red Hat, Inc. +# Written by Pavel Raiskup +# +# 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 <&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 diff --git a/multilib-rpm-config.spec b/multilib-rpm-config.spec index a05f738..85165e0 100644 --- a/multilib-rpm-config.spec +++ b/multilib-rpm-config.spec @@ -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