summaryrefslogtreecommitdiffstats
path: root/multiarch-dispatch
blob: 14ff01d57c84be4845601ce1c91b7b447dddaaf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
#---------------------------------------------------------------
# Module          : multiarch-utils
# File            : multiarch-dispatch
# Version         : $Id: multiarch-dispatch 156136 2005-08-07 15:46:51Z gbeauchesne $
# Author          : Gwenole Beauchesne
# 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" > /dev/stderr
    exit 1
fi

exec $bin ${1+"$@"}