-
Notifications
You must be signed in to change notification settings - Fork 0
/
xbps-multilib.sh
executable file
·49 lines (39 loc) · 1.11 KB
/
xbps-multilib.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
die() {
echo ERROR: $@
exit 1
}
# Try to be sensible about the multilib root
if [ -z "$XBPS_MULTILIB_ROOT" ]; then
if [ -d "/multilib" ]; then
XBPS_MULTILIB_ROOT="/multilib"
else
XBPS_MULTILIB_ROOT="/usr"
fi
fi
# XBPS_ARCH and command are derived from the base name
XBPS_CMD="${0##*/}"
# Strip command suffix to arrive at XBPS_ARCH
XBPS_ARCH="${XBPS_CMD%%-xbps-*}"
# Strip the XBPS_ARCH prefix to arrive at command
XBPS_CMD="${XBPS_CMD#${XBPS_ARCH}-}"
if [ "$XBPS_ARCH" = "$0" ] || [ -z "$XBPS_ARCH" ]; then
die "unable to determine XBPS_ARCH"
fi
if [ "$XBPS_CMD" = "$0" ] || [ -z "$XBPS_CMD" ]; then
die "unable to determine XBPS command"
fi
if [ ! command -v "$XBPS_CMD" >/dev/null 2>&1 ]; then
die "unable to execute '$XBPS_CMD'"
fi
if ! xbps_root=$(readlink -f "${XBPS_MULTILIB_ROOT}/${XBPS_ARCH}"); then
die "failed to canonicalize multilib path"
fi
if [ ! -d "$xbps_root" ]; then
die "multilib root '$xbps_root' does not exist"
fi
if [ -d "${xbps_root}/etc/xbps.d" ]; then
xbps_config="${xbps_root}/etc/xbps.d"
fi
export XBPS_ARCH
"$XBPS_CMD" -r "$xbps_root" ${xbps_config+-C "$xbps_config"} "$@"