This needs to end-up in mandriva, not rpmbuild, macros. Most of "multiarch" macros are not generally useful imho as well.
You can do whatever you wish, but what is distributed with RPM MUST be vendor/platform neutral. Vendor dialects need to be "opt-in", not "opt-out" and inflicted by RPM itself. 73 de Jeff On Apr 10, 2011, at 9:50 AM, Per Øyvind Karlsen wrote: > RPM Package Manager, CVS Repository > http://rpm5.org/cvs/ > ____________________________________________________________________________ > > Server: rpm5.org Name: Per Øyvind Karlsen > Root: /v/rpm/cvs Email: pkarl...@rpm5.org > Module: rpm Date: 10-Apr-2011 15:50:29 > Branch: HEAD Handle: 2011041013502801 > > Added files: > rpm/scripts check-multiarch-files mkmultiarch > multiarch-dispatch multiarch-dispatch.h > multiarch-platform > Modified files: > rpm CHANGES > rpm/macros macros.rpmbuild.in > rpm/scripts Makefile.am > > Log: > merge multiarch-utils from mandriva. > > Summary: > Revision Changes Path > 1.3610 +1 -0 rpm/CHANGES > 1.6 +20 -2 rpm/macros/macros.rpmbuild.in > 1.80 +7 -1 rpm/scripts/Makefile.am > 1.1 +92 -0 rpm/scripts/check-multiarch-files > 1.1 +91 -0 rpm/scripts/mkmultiarch > 1.1 +31 -0 rpm/scripts/multiarch-dispatch > 1.1 +172 -0 rpm/scripts/multiarch-dispatch.h > 1.1 +14 -0 rpm/scripts/multiarch-platform > ____________________________________________________________________________ > > patch -p0 <<'@@ .' > Index: rpm/CHANGES > ============================================================================ > $ cvs diff -u -r1.3609 -r1.3610 CHANGES > --- rpm/CHANGES 10 Apr 2011 11:19:24 -0000 1.3609 > +++ rpm/CHANGES 10 Apr 2011 13:50:29 -0000 1.3610 > @@ -1,4 +1,5 @@ > 5.4.0 -> 5.4.1: > + - proyvind: merge multiarch-utils from mandriva. > - proyvind: macros: sync with updated python macros from mandriva. > - proyvind: rpmfc: add internel dep generator helper for kernel modules. > - provyind: kmod-deps.sh: add dependency extractor from mandriva. > @@ . > patch -p0 <<'@@ .' > Index: rpm/macros/macros.rpmbuild.in > ============================================================================ > $ cvs diff -u -r1.5 -r1.6 macros.rpmbuild.in > --- rpm/macros/macros.rpmbuild.in 25 Mar 2011 13:17:28 -0000 1.5 > +++ rpm/macros/macros.rpmbuild.in 10 Apr 2011 13:50:28 -0000 1.6 > @@ -1,7 +1,7 @@ > #/*! \page build_macros Default configuration: @USRLIBRPM@/macros.rpmbuild > # \verbatim > # > -# $Id: macros.rpmbuild.in,v 1.5 2011/03/25 13:17:28 devzero2000 Exp $ > +# $Id: macros.rpmbuild.in,v 1.6 2011/04/10 13:50:28 pkarlsen Exp $ > # > # This file contains rpmbuild configuration macros. > # > @@ -214,9 +214,27 @@ > %_filter_GLIBC_PRIVATE 0 > > # > +# multiarch is used to deal with situations where headers that contain > +# ie. architecture specific parts to solve file conflicts between > +# packages of different archs in multilib environments. > +# > +# Note: more details at http://wiki.mandriva.com/en/Policies/Multiarch > +%multiarch_platform multiarch-%{_arch}-%{_target_os} > +%multiarch_bindir %{_bindir}/%{multiarch_platform} > +%multiarch_includedir %{_includedir}/%{multiarch_platform} > +%multiarch_binaries() %{_rpmhome}/rpm/mkmultiarch binaries > %{1} > +%multiarch_includes() %{_rpmhome}/rpm/mkmultiarch includes > %{1} > + > +# Check for need of multiarch, terminate build if needed and not used. > +# > +# Note: The default value should be 0 for legacy compatibility. > +# TODO: fix check script and implement support for using > +#%_multiarch_required_terminate_build 1 > + > +# > # Path to scripts to autogenerate package dependencies, > # > -# Note: Used iff _use_internal_dependency_generator is zero. > +# Note: Used if _use_internal_dependency_generator is zero. > #%__find_provides %{_rpmhome}/rpmdeps --provides > #%__find_requires %{_rpmhome}/rpmdeps --requires > %__find_provides %{_rpmhome}/find-provides > @@ . > patch -p0 <<'@@ .' > Index: rpm/scripts/Makefile.am > ============================================================================ > $ cvs diff -u -r1.79 -r1.80 Makefile.am > --- rpm/scripts/Makefile.am 10 Apr 2011 10:59:20 -0000 1.79 > +++ rpm/scripts/Makefile.am 10 Apr 2011 13:50:28 -0000 1.80 > @@ -23,6 +23,8 @@ > check-java-closure.sh java.prov.sh java.req.sh \ > gstreamer.sh javadeps.sh libtooldeps.sh \ > mono-find-provides mono-find-requires \ > + check-multiarch-files multiarch-platform multiarch-dispatch > + multiarch-dispatch.h mkmultiarch \ > nix_meta \ > osgideps.pl pkgconfigdeps.sh \ > perldeps.pl perl.prov perl.req pythondeps.sh pythoneggs.py \ > @@ -43,7 +45,7 @@ > > all: > > -bin_SCRIPTS = gendiff > +bin_SCRIPTS = gendiff multiarch-dispatch multiarch-platform > > pkglibdir = @USRLIBRPM@ > pkglib_SCRIPTS = \ > @@ -56,6 +58,7 @@ > find-requires.perl getpo.sh http.req \ > javadeps.sh libtooldeps.sh \ > mono-find-provides mono-find-requires \ > + check-multiarch-files mkmultiarch \ > osgideps.pl pkgconfigdeps.sh \ > perldeps.pl perl.prov perl.req pythondeps.sh pythoneggs.py \ > php.prov php.req \ > @@ -86,6 +89,9 @@ > pkgconfigdir = $(libdir)/pkgconfig > pkgconfig_DATA = rpm.pc > > +pkgincdir = $(includedir) > +pkginc_HEADERS = multiarch-dispatch.h > + > install-exec-hook: > if WITH_PATH_VERSIONED > -for p in $(bin_SCRIPTS); do \ > @@ . > patch -p0 <<'@@ .' > Index: rpm/scripts/check-multiarch-files > ============================================================================ > $ cvs diff -u -r0 -r1.1 check-multiarch-files > --- /dev/null 2011-04-10 15:45:30.000000000 +0200 > +++ check-multiarch-files 2011-04-10 15:50:28.736402897 +0200 > @@ -0,0 +1,92 @@ > +#!/usr/bin/perl > +#--------------------------------------------------------------- > +# Original author: Gwenole Beauchesne <gbeauche...@mandriva.com> > +# Created On: Mon Jan 24 18:02:21 CET 2005 > +#--------------------------------------------------------------- > + > +use strict; > +use MDK::Common; > + > +my $RPM_BUILD_ROOT = (shift); > + > +if (! -d $RPM_BUILD_ROOT ) { > + while (<STDIN>) { } # consume all inputs > + exit 1 > +} > + > +while (<STDIN>) { > + chomp; > + > + # File must be located in the usual development directories > + -f $_ or next; > + m,^\Q$RPM_BUILD_ROOT\E/usr(/X11R6)?/(bin|include)/, or next; > + m,/multiarch-.+-\w+/, and next; > + m,/include/asm, and next; > + > + my $multiarch = 0; > + my $multiarch_type; > + > + # Heuristics for binary files > + if (/bin/) { > + my $file_magic = `file $_`; > + $multiarch_type = "binary"; > + > + # check for *-config script files > + if (/.+[-_]config/ && $file_magic =~ /shell script/) { > + my $options; > + foreach (cat_($_)) { > + foreach my $opt (qw(cflags libs ldflags cppflags libdir > libtool)) { > + $options .= " --$opt" if > /(\[--$opt\]|--$opt\s+([\#\[]|display|print))/; > + } > + } > + # run the script to find out any libdir dependent flags > + if ($options) { > + my $output = `$_ $options`; > + $multiarch = 1 if ($output =~ > /(?<!\/include)\/lib(32|64)?/); > + } > + } > + } > + > + # Heuristics for include files > + elsif (/include/) { > + $multiarch_type = "header"; > + my %archdefs; > + foreach (cat_($_)) { > + if (/\#\s*define\s+(\w+)\s+(.+)/) { > + my ($def, $val) = ($1, $2); > + > + # check for typical arch-dependent macro definitions > + my @keywords_with_int = qw(SIZEOF_VOID_P SIZEOF_CHAR_P > SIZEOF_LONG BYTES_PER_LONG BITS_PER_LONG BITS_PER_WORD); > + foreach my $pat (@keywords_with_int) { > + if ($def =~ /$pat/ && int($val)) { > + $archdefs{$def}++; > + last; > + } > + } > + > + # check for libdir references, typically plugins dir > + # XXX check for /DIR/ in $def ? > + if ($val =~ > /"\/usr(\/X11R6)?\/lib(32|64)?\/(?!(X11|font)\/).*"/) { > + $multiarch = 1; > + } > + } > + } > + > + # ignore multiple definitions of the same macro, assume > + # arch-dependence is handled in that case > + if (! $multiarch) { > + foreach my $e (keys %archdefs) { > + my $val = $archdefs{$e}; > + $multiarch = 1 if ($val == 1); > + } > + } > + } > + > + # Multiarch files detected? > + print "$_\n" if $multiarch; > +} > + > +# Local variables: > +# tab-width: 4 > +# indent-tabs-mode: nil > +# End: > @@ . > patch -p0 <<'@@ .' > Index: rpm/scripts/mkmultiarch > ============================================================================ > $ cvs diff -u -r0 -r1.1 mkmultiarch > --- /dev/null 2011-04-10 15:45:30.000000000 +0200 > +++ mkmultiarch 2011-04-10 15:50:28.716400737 +0200 > @@ -0,0 +1,91 @@ > +#!/bin/bash > +#--------------------------------------------------------------- > +# Original author: Gwenole Beauchesne <gbeauche...@mandriva.com> > +# Created On: Wed Jan 12 10:54:10 CET 2005 > +#--------------------------------------------------------------- > + > +usage="Usage: $0 <binaries|includes> <file1> [<file2> ...]" > +mplat=`multiarch-platform` > +type=$1 > +case $type in > + binaries|includes) shift;; > + *) echo $usage; exit 1;; > +esac > + > +function error() { > + echo ${1+"$@"} 1>&2 > + exit 1 > +} > + > +# read link on one level only > +function read_link_1() { > + perl -e 'print readlink(shift)' $1 > +} > + > +function dispatch_binaries() { > + local file=$1 > + local bindir=`dirname $file` > + local archbindir=$bindir/$mplat > + [[ -d $archbindir ]] || mkdir -p $archbindir > + if [[ -L $file ]]; then > + link=`read_link_1 $file` > + case $link in > + /*) > + mv $file $archbindir/ > + ;; > + ../*) > + ln -s ../$link $archbindir/${file##*/} > + rm -f $file > + ;; > + esac > + elif [[ -f $file ]]; then > + mv $file $archbindir/ > + else > + error "Unsupported file type for $file" > + fi > + ln -s `which multiarch-dispatch` $file > +} > + > +function dispatch_includes() { > + local file=$1 > + local incdir=`dirname $file` > + > + # handle circular inclusions > + local tag=$incdir/.multiarch-processing.${file##*/} > + [[ -f "$tag" ]] && return > + touch $tag > + > + # sanity checks, extract path parts > + echo $file | grep -q '/include/' || error "Unsupported includedir > $incdir" > + local prefix=`echo $incdir | sed -n '/\(.*\/include\)\/.*/s//\1/p'` > + [[ -z "$prefix" ]] && prefix="$incdir" > + local suffix=`echo $incdir | sed -n '/.*\/include\/\(.*\)/s//\1/p'` > + [[ -n "$suffix" ]] && suffix="$suffix/" > + > + # dispatch nested includes expected in local directory > + sed -n '/^#[ \t]*include[ \t]*"\([^"][^"]*\)".*/s//\1/p' $file | \ > + while read localfile; do > + [[ -f "$incdir/$localfile" ]] && dispatch_includes $incdir/$localfile > + done > + > + # dispatch selected include file, provided it's not already dispatched > + grep -q _MULTIARCH_HEADER $file || { > + local archincdir=$prefix/$mplat/$suffix > + [[ -d $archincdir ]] || mkdir -p $archincdir > + mv $file $archincdir/ > + cat > $file << EOF > +#define _MULTIARCH_HEADER $suffix${file##*/} > +#include <multiarch-dispatch.h> > +EOF > + } > + > + # done with this file > + rm -f $tag > +} > + > +while [[ $# -gt 0 ]]; do > + file=$1 > + shift 1 > + [[ -f $file ]] || error "$file does not exist!" > + dispatch_$type $file > +done > @@ . > patch -p0 <<'@@ .' > Index: rpm/scripts/multiarch-dispatch > ============================================================================ > $ cvs diff -u -r0 -r1.1 multiarch-dispatch > --- /dev/null 2011-04-10 15:45:30.000000000 +0200 > +++ multiarch-dispatch 2011-04-10 15:50:28.686398895 +0200 > @@ -0,0 +1,31 @@ > +#!/bin/sh > +#--------------------------------------------------------------- > +# Original author: Gwenole Beauchesne <gbeauche...@mandriva.com> > +# Created On: Wed Jan 12 12:38:53 EST 2005 > +#--------------------------------------------------------------- > + > +if [[ "$0" = "/usr/bin/multiarch-dispatch" ]]; then > + echo "Helper script to dispatch a binary under a specific personality" > + exit 0 > +fi > + > +# go through symlinks until multiarch-dispatch leaf is reached > +mprog="$0" > +mcomp="$mprog" > +while [[ -L "$mcomp" ]]; do > + mprog="$mcomp" > + mcomp=`readlink "$mprog"` > + case "$mcomp" in > + /*) ;; > + *) mcomp=`dirname "$mprog"`/"$mcomp";; > + esac > +done > + > +bin=`dirname "$mprog"`/`multiarch-platform`/"${mprog##*/}" > + > +if [[ ! -x "$bin" ]]; then > + echo "Cannot execute $bin" 1>&2 > + exit 1 > +fi > + > +exec $bin ${1+"$@"} > @@ . > patch -p0 <<'@@ .' > Index: rpm/scripts/multiarch-dispatch.h > ============================================================================ > $ cvs diff -u -r0 -r1.1 multiarch-dispatch.h > --- /dev/null 2011-04-10 15:45:30.000000000 +0200 > +++ multiarch-dispatch.h 2011-04-10 15:50:28.636396570 +0200 > @@ -0,0 +1,172 @@ > +/* Undefine some built-ins */ > +#ifdef linux > +#undef linux > +#define _multiarch_defined_linux > +#endif > +#ifdef i386 > +#undef i386 > +#define _multiarch_defined_i386 > +#endif > +#ifdef sparc > +#undef sparc > +#define _multiarch_defined_sparc > +#endif > +#ifdef mips > +#undef mips > +#define _multiarch_defined_mips > +#endif > +#ifdef arm > +#undef arm > +#define _multiarch_defined_arm > +#endif > + > +/* Undefine some interfering definitions (not built-ins) */ > +/* We can only redefine value 1, so we let it fail with other values */ > +#if x86_64 == 1 > +#define _multiarch_defined_x86_64 > +#undef x86_64 > +#endif > +#if ppc64 == 1 > +#define _multiarch_defined_ppc64 > +#undef ppc64 > +#endif > +#if ppc == 1 > +#define _multiarch_defined_ppc > +#undef ppc > +#endif > +#if sparc64 == 1 > +#define _multiarch_defined_sparc64 > +#undef sparc64 > +#endif > +#if s390x == 1 > +#define _multiarch_defined_s390x > +#undef s390x > +#endif > +#if s390 == 1 > +#define _multiarch_defined_s390 > +#undef s390 > +#endif > +#if ia64 == 1 > +#define _multiarch_defined_ia64 > +#undef ia64 > +#endif > +#if alpha == 1 > +#define _multiarch_defined_alpha > +#undef alpha > +#endif > +#if mipsel == 1 > +#define _multiarch_defined_mipsel > +#undef mipsel > +#endif > +#if armeb == 1 > +#define _multiarch_defined_armeb > +#undef armeb > +#endif > + > +/* Dispatch arch dependent header */ > +#if defined(__linux__) > +#define _MULTIARCH_OS linux > +#endif > +#define _MULTIARCH_MAKE_HEADER(arch,header) > <multiarch-arch-_MULTIARCH_OS/header> > +#if defined(__x86_64__) > +#include _MULTIARCH_MAKE_HEADER(x86_64,_MULTIARCH_HEADER) > +#elif defined(__i386__) > +#include _MULTIARCH_MAKE_HEADER(i386,_MULTIARCH_HEADER) > +#elif defined(__powerpc64__) > +#include _MULTIARCH_MAKE_HEADER(ppc64,_MULTIARCH_HEADER) > +#elif defined(__powerpc__) > +#include _MULTIARCH_MAKE_HEADER(ppc,_MULTIARCH_HEADER) > +#elif defined(__sparc__) && defined(__arch64__) > +#include _MULTIARCH_MAKE_HEADER(sparc64,_MULTIARCH_HEADER) > +#elif defined(__sparc__) > +#include _MULTIARCH_MAKE_HEADER(sparc,_MULTIARCH_HEADER) > +#elif defined(__s390x__) > +#include _MULTIARCH_MAKE_HEADER(s390x,_MULTIARCH_HEADER) > +#elif defined(__s390__) > +#include _MULTIARCH_MAKE_HEADER(s390,_MULTIARCH_HEADER) > +#elif defined(__ia64__) > +#include _MULTIARCH_MAKE_HEADER(ia64,_MULTIARCH_HEADER) > +#elif defined(__alpha__) > +#include _MULTIARCH_MAKE_HEADER(alpha,_MULTIARCH_HEADER) > +#elif defined(__mips__) > +#if defined(__BIG_ENDIAN__) > +#include _MULTIARCH_MAKE_HEADER(mips,_MULTIARCH_HEADER) > +#else > +#include _MULTIARCH_MAKE_HEADER(mipsel,_MULTIARCH_HEADER) > +#endif > +#elif defined(__arm__) > +#if defined(__BIG_ENDIAN__) > +#include _MULTIARCH_MAKE_HEADER(armeb,_MULTIARCH_HEADER) > +#else > +#include _MULTIARCH_MAKE_HEADER(arm,_MULTIARCH_HEADER) > +#endif > +#else > +#error "Unknown architecture, please submit bug report" > +#endif > +#undef _MULTIARCH_MAKE_HEADER > +#undef _MULTIARCH_OS > +#undef _MULTIARCH_HEADER > + > +/* Redefine built-ins */ > +#ifdef _multiarch_defined_linux > +#undef _multiarch_defined_linux > +#define linux 1 > +#endif > +#ifdef _multiarch_defined_i386 > +#undef _multiarch_defined_i386 > +#define i386 1 > +#endif > +#ifdef _multiarch_defined_sparc > +#undef _multiarch_defined_sparc > +#define sparc 1 > +#endif > +#ifdef _multiarch_defined_mips > +#undef _multiarch_defined_mips > +#define mips 1 > +#endif > +#ifdef _multiarch_defined_arm > +#undef _multiarch_defined_arm > +#define arm 1 > +#endif > + > +/* Redefine interfering defitions */ > +#ifdef _multiarch_defined_x86_64 > +#undef _multiarch_defined_x86_64 > +#define x86_64 1 > +#endif > +#ifdef _multiarch_defined_ppc64 > +#undef _multiarch_defined_ppc64 > +#define ppc64 1 > +#endif > +#ifdef _multiarch_defined_ppc > +#undef _multiarch_defined_ppc > +#define ppc 1 > +#endif > +#ifdef _multiarch_defined_sparc64 > +#undef _multiarch_defined_sparc64 > +#define sparc64 1 > +#endif > +#ifdef _multiarch_defined_s390x > +#undef _multiarch_defined_s390x > +#define s390x 1 > +#endif > +#ifdef _multiarch_defined_s390 > +#undef _multiarch_defined_s390 > +#define s390 1 > +#endif > +#ifdef _multiarch_defined_ia64 > +#undef _multiarch_defined_ia64 > +#define ia64 1 > +#endif > +#ifdef _multiarch_defined_alpha > +#undef _multiarch_defined_alpha > +#define alpha 1 > +#endif > +#ifdef _multiarch_defined_mipsel > +#undef _multiarch_defined_mipsel > +#define mipsel 1 > +#endif > +#ifdef _multiarch_defined_armeb > +#undef _multiarch_defined_armeb > +#define armeb 1 > +#endif > @@ . > patch -p0 <<'@@ .' > Index: rpm/scripts/multiarch-platform > ============================================================================ > $ cvs diff -u -r0 -r1.1 multiarch-platform > --- /dev/null 2011-04-10 15:45:30.000000000 +0200 > +++ multiarch-platform 2011-04-10 15:50:28.656399847 +0200 > @@ -0,0 +1,14 @@ > +#!/bin/sh > +arch=`uname -m` > +`perl -e '$le = unpack("h*", pack("s", 1)) =~ /^1/; exit $le;'` > +le=$? > +case $arch in > +i?86) arch=i386;; > +mips*) [ $le -eq 1 ] && arch="$arch"el ;; > +arm*) [ $le -eq 0 ] && arch="armeb" || arch="arm" ;; > +esac > +os=`uname -s` > +case $os in > +Linux*) os=linux;; > +esac > +echo multiarch-$arch-$os > @@ . > ______________________________________________________________________ > RPM Package Manager http://rpm5.org > CVS Sources Repository rpm-...@rpm5.org
smime.p7s
Description: S/MIME cryptographic signature