From 189cced957f35ab0d86356420efdec7c0af7c9d9 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Jun 13 2016 21:52:52 +0000 Subject: multilib-fix: initial commit Macro and is taken from actual Fedora's postgresql.spec. --- diff --git a/.gitignore b/.gitignore index e69de29..484fa89 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +noarch diff --git a/db-rpm-config.spec b/db-rpm-config.spec new file mode 100644 index 0000000..c2d0f59 --- /dev/null +++ b/db-rpm-config.spec @@ -0,0 +1,53 @@ +# https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_of_Additional_RPM_Macros +%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) + +%global rrcdir /usr/lib/rpm + +%global namespace db +%global macro_ns %{?namespace:%{namespace}_} +%global script_ns %{?namespace:%{namespace}-} +%global macrofn_ns %{?namespace:%{namespace}-} + +Summary: More or less DB related rpm configuration files +Name: %{?script_ns}rpm-config +Version: 1 +Release: 1%{?dist} +License: GPL+ +Group: Development/System +URL: https://github.com/devexp-db/db-rpm-config + +Source0: multilib-fix +Source1: macros.ml + +BuildArch: noarch + +# Most probably we want to have everything moved to this package! +Provides: redhat-rpm-config = %{version}-%{release} + +%description +RPM configuration files used by DB team (but others might be interested too). + +%prep +%setup -c -T + +%build +%global ml_fix %rrcdir/%{?script_ns}multilib-fix +sed \ + -e 's|@ML_MACRO_PFX@|%{?macro_ns}|g' \ + -e 's|@ML_FIX@|%ml_fix|g' \ + %{SOURCE1} > macros.%{?macrofn_ns}ml + +%install +mkdir -p %{buildroot}%{rrcdir} +mkdir -p %{buildroot}%{macrosdir} +# Multi-lib kludge. +install -m 644 -p macros.%{?macrofn_ns}ml %{buildroot}/%{macrosdir} +install -m 755 -p %{SOURCE0} %{buildroot}/%{ml_fix} + +%files +%{rrcdir} +%{macrosdir} + +%changelog +* Wed Nov 18 2015 Pavel Raiskup - 1-1 +- initial packaging diff --git a/macros.ml b/macros.ml new file mode 100644 index 0000000..53a1bcf --- /dev/null +++ b/macros.ml @@ -0,0 +1 @@ +%@ML_MACRO_PFX@ml_fix_c_header @ML_FIX@ --buildroot "$RPM_BUILD_ROOT" diff --git a/multilib-fix b/multilib-fix new file mode 100755 index 0000000..ff39117 --- /dev/null +++ b/multilib-fix @@ -0,0 +1,170 @@ +#! /bin/sh + +# Replace the multilib-unclean header file with multilib-clean stub, while the +# original file is moved to unique architecture-specific location. +# +# The solution is taken from Fedora PostgreSQL RPM package. +# +# Pavel Raiskup +# +# This file is to be moved into redhat-rpm-config (or something like this). + +progname=$(basename "$0") + +opt_arch=$(uname -i) +# See rhbz#1242873 for more info. +test "$opt_arch" = ppc64p7 && opt_arch=ppc64 + +opt_destdir= +opt_basename= +opt_buildroot=$(pwd) +opt_verbose=: +opt_additional_suffix= + +# TODO: we could pretty easily implement other then 'cpp-header' stubs, if the +# target file type allows some kind of "transparent" file inclusion. For +# example shell scripts might use '. "${opt_destdir}/${opt_basename}_x86_64.sh'. +print_stub () +{ +cat <' are unchanged. + +To allow us to do incompatible changes in this script, packagers should use this +script only through %ml_fix_c_header wrapping macro. + +--destdir absolute path name where the old header file is stored, e.g. + /some/pat +--basename when you deal with '/some/path/test.h', specify 'test' +--buildroot prefix (directory where we play with installed files, usually + after 'make install DESTDIR=buildroot') +--additional-suffix we usually move 'test.h' to 'test_\$ARCH.h'. However + this file could already exit. With this option the multilib + file will be named 'test_\$ARCH\$SUFFIX.h' +--verbose print some useful information +--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 + case $_opt in + --destdir) + opt_destdir=$1 ; shift || die "$_opt requires argument" + ;; + --basename) + opt_basename=$1 ; shift || die "$_opt require argument" + ;; + --buildroot) + opt_buildroot=$1 ; shift || die "$_opt require argument" + ;; + --arch) + opt_arch=$1 ; shift || die "$_opt require argument" + ;; + --additional-suffix) + opt_additional_suffix=$1 ; shift || die "$_opt require argument" + ;; + --help) + print_help 0 + ;; + *) + error "unexpected '$_opt' program argument" + ;; + esac +done +$error_occurred && print_help 1 + +for i in arch buildroot destdir basename +do + eval "test -z \"\$opt_$i\"" && error "--$i needs to be set" +done +$error_occurred && print_help 1 + +original_file="$opt_buildroot$opt_destdir/$opt_basename".h +multilib_file="$opt_buildroot$opt_destdir/$opt_basename${opt_additional_suffix}_$opt_arch".h + +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 + +verbose "moving: '$original_file' to '$multilib_file'" + +mv "$original_file" "$multilib_file" || exit 1 +if print_stub > "$original_file" && chmod 644 "$original_file"; then + : +else + die "can't write into '$original_file'" +fi + +: