--- rpm-5.4.15/configure.ac~ 2014-12-20 16:50:32.000000000 +0100 +++ rpm-5.4.15/configure.ac 2014-12-20 16:54:38.036853187 +0100 @@ -2200,8 +2200,9 @@ case "${target_cpu}" in *86) RPMCANONARCH=i386 ;; ia32e*) RPMCANONARCH=ia32e ;; -amd64*) RPMCANONARCH=amd64 ;; -x86_64*) RPMCANONARCH=x86_64 ;; +amd64*) RPMCANONCOLOR=7; RPMCANONARCH=amd64 ;; +x86_64*) RPMCANONCOLOR=7; RPMCANONARCH=x86_64 ;; +x32) RPMCANONARCH=x32 ;; alpha*) RPMCANONARCH=alpha ;; sparc64*) RPMCANONARCH=sparc64 ;; sparc*) RPMCANONARCH=sparc ;; --- rpm-5.4.15/lib/rpmfc.c.orig 2014-12-20 16:50:32.000000000 +0100 +++ rpm-5.4.15/lib/rpmfc.c 2014-12-20 18:32:11.641808153 +0100 @@ -581,6 +581,7 @@ { "MIPS, N32 MIPS32", RPMFC_ELFMIPSN32|RPMFC_INCLUDE }, { "ELF 32-bit", RPMFC_ELF32|RPMFC_INCLUDE }, { "ELF 64-bit", RPMFC_ELF64|RPMFC_INCLUDE }, +// { "ELF 32-bit", RPMFC_ELFX32|RPMFC_INCLUDE }, { " script", RPMFC_SCRIPT }, { " text", RPMFC_TEXT }, @@ -685,7 +686,11 @@ for (fct = rpmfcTokens; fct->token != NULL; fct++) { if (strstr(fmstr, fct->token) == NULL) continue; - fcolor |= fct->colors; + // This is a nasty hack, but will have to do for now + if ((fct->colors & RPMFC_ELF32) && (strstr(fmstr, "x86-64") != NULL)) + fcolor |= RPMFC_ELFX32|RPMFC_INCLUDE; + else + fcolor |= fct->colors; if (fcolor & RPMFC_INCLUDE) return fcolor; } --- rpm-5.4.15/lib/rpmfc.h.orig 2014-12-20 17:51:48.584934979 +0100 +++ rpm-5.4.15/lib/rpmfc.h 2014-12-20 17:56:14.690160030 +0100 @@ -20,8 +20,9 @@ RPMFC_BLACK = 0, RPMFC_ELF32 = (1 << 0), RPMFC_ELF64 = (1 << 1), + RPMFC_ELFX32 = (1 << 2), RPMFC_ELFMIPSN32 = (1 << 2), -#define RPMFC_ELF (RPMFC_ELF32|RPMFC_ELF64|RPMFC_ELFMIPSN32) +#define RPMFC_ELF (RPMFC_ELF32|RPMFC_ELF64|RPMFC_ELFX32|RPMFC_ELFMIPSN32) /* (1 << 3) leaks into package headers, reserved */ RPMFC_DESKTOP_FILE = (1 << 4), diff -ur rpm-5.4.15/autodeps/linux.prov rpm-5.4.15.x32/autodeps/linux.prov --- rpm-5.4.15/autodeps/linux.prov 2010-03-18 10:54:56.000000000 +0100 +++ rpm-5.4.15.x32/autodeps/linux.prov 2014-12-20 19:18:57.339941715 +0100 @@ -16,8 +16,12 @@ # # --- Alpha does not mark 64bit dependencies +# --- Only x86_64 has x32bit dependencies +markx32="" case `uname -m` in alpha*) mark64="" ;; + x86_64) markx32="()(x32bit)" + mark64="()(64bit)" ;; *) mark64="()(64bit)" ;; esac @@ -28,6 +32,10 @@ lib64=`if file -L $f 2>/dev/null | \ grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` + libx32=`if file -L $f 2>/dev/null | \ + grep "ELF 32-bit.*x86-64" > /dev/null; \ + then echo "$markx32"; fi` + lib64="$lib64$libx32" if [ "$soname" != "" ]; then if [ ! -L $f ]; then echo $soname$lib64 Only in rpm-5.4.15.x32/autodeps: linux.prov.orig diff -ur rpm-5.4.15/autodeps/linux.req rpm-5.4.15.x32/autodeps/linux.req --- rpm-5.4.15/autodeps/linux.req 2010-03-18 10:54:56.000000000 +0100 +++ rpm-5.4.15.x32/autodeps/linux.req 2014-12-20 19:20:04.622910545 +0100 @@ -38,8 +38,12 @@ # # --- Alpha does not mark 64bit dependencies +# --- Only x86_64 has x32bit dependencies +markx32="" case `uname -m` in alpha*) mark64="" ;; + x86_64) markx32="()(x32bit)" + mark64="()(64bit)" ;; *) mark64="()(64bit)" ;; esac @@ -50,6 +54,9 @@ [ -r $f -a -x $f ] || continue lib64=`if file -L $f 2>/dev/null | \ grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` + libx32=`if file -L $f 2>/dev/null | \ + grep "ELF 32-bit.*x86-64" >/dev/null; then echo "$markx32"; fi` + lib64="$lib64$libx32" ldd $f | awk '/=>/ { if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) { gsub(/'\''"/,"\\&",$1); @@ -64,6 +71,9 @@ [ -r $f ] || continue lib64=`if file -L $f 2>/dev/null | \ grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` + libx32=`if file -L $f 2>/dev/null | \ + grep "ELF 32-bit.*x86-64" >/dev/null; then echo "$markx32"; fi` + lib64="$lib64$libx32" ldd $f | awk '/=>/ { if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) { gsub(/'\''"/,"\\&",$1); @@ -98,6 +108,9 @@ [ -r $f ] || continue lib64=`if file -L $f 2>/dev/null | \ grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` + libx32=`if file -L $f 2>/dev/null | \ + grep "ELF 32-bit.*x86-64" >/dev/null; then echo "$markx32"; fi` + lib64="$lib64$libx32" $OBJDUMP -p $f | awk 'BEGIN { START=0; LIBNAME=""; needed='$needed'; } /^$/ { START=0; } /^Dynamic Section:$/ { START=1; } diff -ur rpm-5.4.15/lib/rpmds.c rpm-5.4.15.x32/lib/rpmds.c --- rpm-5.4.15/lib/rpmds.c 2014-12-20 19:35:31.114557975 +0100 +++ rpm-5.4.15.x32/lib/rpmds.c 2014-12-20 19:34:54.958087185 +0100 @@ -2922,19 +2922,26 @@ * @retval t soname dependency * @param s elf string (NULL uses "") * @param isElf64 is this an ELF64 symbol? + * @param isX32 is this an X32 symbol? */ #if defined(HAVE_GELF_H) && defined(HAVE_LIBELF) && !defined(__FreeBSD__) -static char * sonameDep(/*@returned@*/ char * t, const char * s, int isElf64) +static char * sonameDep(/*@returned@*/ char * t, const char * s, int isElf64, int isX32) /*@modifies t @*/ { *t = '\0'; #if !defined(__alpha__) && !defined(__sun) if (isElf64) { if (s[strlen(s)-1] != ')') (void) stpcpy( stpcpy(t, s), "()(64bit)"); else (void) stpcpy( stpcpy(t, s), "(64bit)"); }else + if (isX32) { + if (s[strlen(s)-1] != ')') + (void) stpcpy( stpcpy(t, s), "()(x32bit)"); + else + (void) stpcpy( stpcpy(t, s), "(x32bit)"); + } else #endif (void) stpcpy(t, s); return t; @@ -2967,6 +2975,7 @@ char * t; int xx; int isElf64; + int isX32; int isDSO; int gotSONAME = 0; int gotDEBUG = 0; @@ -3009,6 +3018,7 @@ /*@=evalorder@*/ isElf64 = ehdr->e_ident[EI_CLASS] == ELFCLASS64; + isX32 = (ehdr->e_ident[EI_CLASS] == ELFCLASS32) && (ehdr->e_machine == EM_X86_64); isDSO = ehdr->e_type == ET_DYN; /*@-uniondef @*/ @@ -3110,7 +3120,7 @@ /* Add next provide dependency. */ ds = rpmdsSingle(RPMTAG_PROVIDES, - sonameDep(t, buf, isElf64), + sonameDep(t, buf, isElf64, isX32), "", RPMSENSE_FIND_PROVIDES); xx = add(context, ds); (void)rpmdsFree(ds); @@ -3163,7 +3173,7 @@ /* Add next require dependency. */ ds = rpmdsSingle(RPMTAG_REQUIRENAME, - sonameDep(t, buf, isElf64), + sonameDep(t, buf, isElf64, isX32), "", RPMSENSE_FIND_REQUIRES); xx = add(context, ds); (void)rpmdsFree(ds); @@ -3205,7 +3215,7 @@ assert(s != NULL); buf[0] = '\0'; ds = rpmdsSingle(RPMTAG_REQUIRENAME, - sonameDep(buf, s, isElf64), + sonameDep(buf, s, isElf64, isX32), "", RPMSENSE_FIND_REQUIRES); xx = add(context, ds); (void)rpmdsFree(ds); @@ -3220,7 +3230,7 @@ /* Add next provide dependency. */ buf[0] = '\0'; ds = rpmdsSingle(RPMTAG_PROVIDENAME, - sonameDep(buf, s, isElf64), + sonameDep(buf, s, isElf64, isX32), "", RPMSENSE_FIND_PROVIDES); xx = add(context, ds); (void)rpmdsFree(ds); @@ -3256,7 +3266,7 @@ /* Add next provide dependency. */ buf[0] = '\0'; ds = rpmdsSingle(RPMTAG_PROVIDENAME, - sonameDep(buf, s, isElf64), "", RPMSENSE_FIND_PROVIDES); + sonameDep(buf, s, isElf64, isX32), "", RPMSENSE_FIND_PROVIDES); xx = add(context, ds); (void)rpmdsFree(ds); ds = NULL; diff -ur rpm-5.4.15/build/parseSpec.c rpm-5.4.15-fixed/build/parseSpec.c --- rpm-5.4.15/build/parseSpec.c 2015-04-02 20:52:18.192956656 +0200 +++ rpm-5.4.15-fixed/build/parseSpec.c 2015-04-02 20:49:57.416291008 +0200 @@ -707,10 +708,25 @@ /* Check for description in each package and add arch and os */ { - const char *platform = rpmExpand("%{_target_platform}", NULL); - const char *platformNoarch = NULL; + const char *platform = NULL; const char *arch = rpmExpand("%{_target_cpu}", NULL); const char *os = rpmExpand("%{_target_os}", NULL); +#ifdef RPM_VENDOR_PLD +/* + * This is a hack for x32 compatibility, on x32 _target_platform + * does not use _target_cpu, it must use hardcoded x86-64. + * This results in noarch packages using platform x86_64-pld-linux-gnux32 + * and being unusable on ix86. + */ + const char *platformNoarch = xstrdup("noarch-pld-linux"); + if (strcmp(arch,"noarch")) + platform = rpmExpand("%{_target_platform}", NULL); + else + platform = xstrdup("noarch-pld-linux"); +#else + const char *platformNoarch = NULL; + platform = rpmExpand("%{_target_platform}", NULL); +#endif for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { he->tag = RPMTAG_OS;