multilib: fix devel subpackage

Remove the templates and add sufficiently general script to
generate the header stub file.  I'll try to propose this to
redhat-rpm-config package inclusion.

Resolves: rhbz#1190346
Version: 9.4.5-2
This commit is contained in:
Pavel Raiskup 2015-10-16 11:35:07 +02:00
parent 4034635788
commit 8a02c71231
4 changed files with 180 additions and 76 deletions

View File

@ -1,29 +0,0 @@
/*
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
* we need to arrange that header files that appear in both RPMs are
* identical. Hence, this file is architecture-independent and calls
* in an arch-dependent file that will appear in just one RPM.
*
* To avoid breaking arches not explicitly supported by Red Hat, we
* use this indirection file *only* on known multilib arches.
*
* Note: this may well fail if user tries to use gcc's -I- option.
* But that option is deprecated anyway.
*/
#if defined(__x86_64__)
#include "ecpg_config_x86_64.h"
#elif defined(__i386__)
#include "ecpg_config_i386.h"
#elif defined(__ppc64__) || defined(__powerpc64__)
#include "ecpg_config_ppc64.h"
#elif defined(__ppc__) || defined(__powerpc__)
#include "ecpg_config_ppc.h"
#elif defined(__s390x__)
#include "ecpg_config_s390x.h"
#elif defined(__s390__)
#include "ecpg_config_s390.h"
#elif defined(__sparc__) && defined(__arch64__)
#include "ecpg_config_sparc64.h"
#elif defined(__sparc__)
#include "ecpg_config_sparc.h"
#endif

170
multilib-fix Executable file
View File

@ -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 <praiskup@redhat.com>
#
# 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 <<EOF
/*
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
* we need to arrange that header files that appear in both RPMs are
* identical. Hence, this file is architecture-independent and calls
* in an arch-dependent file that will appear in just one RPM.
*
* To avoid breaking arches not explicitly supported by Red Hat, we
* use this indirection file *only* on known multilib arches.
*
* Note: this may well fail if user tries to use gcc's -I- option.
* But that option is deprecated anyway.
*/
#if defined(__x86_64__)
#include "${opt_basename}${opt_additional_suffix}_x86_64.h"
#elif defined(__i386__)
#include "${opt_basename}${opt_additional_suffix}_i386.h"
#elif defined(__ppc64__) || defined(__powerpc64__)
#include "${opt_basename}${opt_additional_suffix}_ppc64.h"
#elif defined(__ppc__) || defined(__powerpc__)
#include "${opt_basename}${opt_additional_suffix}_ppc.h"
#elif defined(__s390x__)
#include "${opt_basename}${opt_additional_suffix}_s390x.h"
#elif defined(__s390__)
#include "${opt_basename}${opt_additional_suffix}_s390.h"
#elif defined(__sparc__) && defined(__arch64__)
#include "${opt_basename}${opt_additional_suffix}_sparc64.h"
#elif defined(__sparc__)
#include "${opt_basename}${opt_additional_suffix}_sparc.h"
#endif
EOF
}
print_help ()
{
_h_exit=false
test -n "$1" && _h_exit=:
cat <<EOF
Usage: $progname [OPTIONS]
Replace the multilib-unclean header file with multilib-clean stub, while the
original file is moved to unique architecture-specific location. This should be
absolutely safe operation (effects of '#include <HEADER.h>' 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
:

View File

@ -1,29 +0,0 @@
/*
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
* we need to arrange that header files that appear in both RPMs are
* identical. Hence, this file is architecture-independent and calls
* in an arch-dependent file that will appear in just one RPM.
*
* To avoid breaking arches not explicitly supported by Red Hat, we
* use this indirection file *only* on known multilib arches.
*
* Note: this may well fail if user tries to use gcc's -I- option.
* But that option is deprecated anyway.
*/
#if defined(__x86_64__)
#include "pg_config_x86_64.h"
#elif defined(__i386__)
#include "pg_config_i386.h"
#elif defined(__ppc64__) || defined(__powerpc64__)
#include "pg_config_ppc64.h"
#elif defined(__ppc__) || defined(__powerpc__)
#include "pg_config_ppc.h"
#elif defined(__s390x__)
#include "pg_config_s390x.h"
#elif defined(__s390__)
#include "pg_config_s390.h"
#elif defined(__sparc__) && defined(__arch64__)
#include "pg_config_sparc64.h"
#elif defined(__sparc__)
#include "pg_config_sparc.h"
#endif

View File

@ -94,8 +94,7 @@ Source1: postgresql-%{version}-US.pdf
Source2: generate-pdf.sh Source2: generate-pdf.sh
Source3: ftp://ftp.postgresql.org/pub/source/v%{prevversion}/postgresql-%{prevversion}.tar.bz2 Source3: ftp://ftp.postgresql.org/pub/source/v%{prevversion}/postgresql-%{prevversion}.tar.bz2
Source4: Makefile.regress Source4: Makefile.regress
Source5: pg_config.h Source5: multilib-fix
Source6: ecpg_config.h
Source9: postgresql.tmpfiles.d Source9: postgresql.tmpfiles.d
Source10: postgresql.pam Source10: postgresql.pam
Source11: postgresql-bashprofile Source11: postgresql-bashprofile
@ -679,22 +678,14 @@ echo "%%%{name}_major %{majorversion}" > macros.%{name}
install -D -m 644 macros.%{name} \ install -D -m 644 macros.%{name} \
$RPM_BUILD_ROOT%{macrosdir}/macros.%{name} $RPM_BUILD_ROOT%{macrosdir}/macros.%{name}
# multilib header hack; note pg_config.h is installed in two places! # multilib header hack; some headers are installed in two places!
# we only apply this to known Red Hat multilib arches, per bug #177564 %global ml_fix_c_header %{SOURCE5} --buildroot "$RPM_BUILD_ROOT"
build_arch=`uname -i` for header in pg_config pg_config_ext ecpg_config; do
test "$build_arch" = ppc64p7 && build_arch=ppc64 %ml_fix_c_header --destdir "%{_includedir}" --basename "$header"
case "$build_arch" in done
i386 | x86_64 | ppc | ppc64 | s390 | s390x | sparc | sparc64 ) for header in pg_config pg_config_ext; do
mv $RPM_BUILD_ROOT%{_includedir}/pg_config.h $RPM_BUILD_ROOT%{_includedir}/pg_config_"$build_arch".h %ml_fix_c_header --destdir "%{_includedir}/pgsql/server" --basename "$header"
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_includedir}/ done
mv $RPM_BUILD_ROOT%{_includedir}/pgsql/server/pg_config.h $RPM_BUILD_ROOT%{_includedir}/pgsql/server/pg_config_"$build_arch".h
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_includedir}/pgsql/server/
mv $RPM_BUILD_ROOT%{_includedir}/ecpg_config.h $RPM_BUILD_ROOT%{_includedir}/ecpg_config_"$build_arch".h
install -m 644 %{SOURCE6} $RPM_BUILD_ROOT%{_includedir}/
;;
*)
;;
esac
install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
cp -p src/tutorial/* $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial cp -p src/tutorial/* $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
@ -1195,6 +1186,7 @@ fi
%changelog %changelog
* Fri Oct 16 2015 Pavel Raiskup <praiskup@redhat.com> - 9.4.5-2 * Fri Oct 16 2015 Pavel Raiskup <praiskup@redhat.com> - 9.4.5-2
- devel package should not require the main package (rhbz#1272219) - devel package should not require the main package (rhbz#1272219)
- multilib fix, more general solution (rhbz#1190346)
* Tue Oct 06 2015 Pavel Raiskup <praiskup@redhat.com> - 9.4.5-1 * Tue Oct 06 2015 Pavel Raiskup <praiskup@redhat.com> - 9.4.5-1
- update to 9.4.5 per release notes - update to 9.4.5 per release notes