automagically choose correct preload library on biarch systems Uses "file" to check whether called program is a 32bit or 64bit ELF file. If that cannot be determined it checks the uname. Signed-off-by: Ludwig Nussel Index: mumble-1.1.3/scripts/mumble-overlay =================================================================== --- mumble-1.1.3.orig/scripts/mumble-overlay +++ mumble-1.1.3/scripts/mumble-overlay @@ -1,9 +1,47 @@ -#! /bin/sh +#!/bin/bash -if [ -d /usr/lib/mumble ]; then - MUMBLE_OVERLAY_PATH=/usr/lib/mumble +libdir=/usr/lib +if [ -z "$1" -o "$1" = '--help' ]; then + echo "USAGE: $0 [args...]" + exit 1 +fi + +# biarch system? +if [ -d /usr/lib64 ]; then + binary="$1" + # no slashes? search in $PATH + if [ "${binary/\/}" = "$binary" ]; then + found= + for i in ${PATH//:/ }; do + if [ -x "$i/$binary" ]; then + found="$i/$binary" + break + fi + done + binary="$found" + fi + if [ -z "$binary" ]; then + echo "$1 not found" >&2 + exit 1 + fi + case `file "$binary"` in + *64-bit*) libdir=/usr/lib64 ;; + *32-bit*) ;; + *) + # target is no ELF binary, fall back to machine + # architecture. User has to use e.g. linux32 or + # setarch to change to 32bit on 64bit archs then + case "`uname -m`" in + x86_64|s390x|ppc64) libdir=/usr/lib64 ;; + esac + ;; + esac +fi + +if [ -d $libdir/mumble ]; then + MUMBLE_OVERLAY_PATH=$libdir/mumble else - MUMBLE_OVERLAY_PATH=/usr/lib + MUMBLE_OVERLAY_PATH=$libdir fi if [ -f /etc/sysconfig/mumble ]; then