-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmer-tooling-chroot
executable file
·71 lines (54 loc) · 1.46 KB
/
mer-tooling-chroot
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# mer-tooling-chroot - chroot into a Mer SDK tooling
set -u
set -e
usage() {
cat <<EOF
usage: $0 [<command> <args>...]
$0 -h
$0 - chroot into a Mer SDK tooling.
Options:
<command> [<args>...] If present the given command will be executed
instead of a login shell
-h Show this help
EOF
return 0
}
while getopts "h" opt; do
case $opt in
h ) usage
exit;;
\? ) usage
exit 1;;
esac
done
shift $(($OPTIND - 1))
if [[ ! -f /etc/MerSDK ]]; then
echo "$0 cannot be run outside the SDK; exiting"
exit 1
fi
if [[ $EUID -ne 0 ]]; then
exec sudo $0 "$@"
echo "$0 must be run as root and sudo failed; exiting"
exit 1
fi
toolingroot=$(dirname $(readlink -f $0))
if [[ ! -f ${toolingroot}/etc/SDKTooling ]] ; then
echo "${toolingroot} does not look like a Mer SDK tooling root."
exit 1
fi
################################################################
prepare_etc() {
cp --remove-destination --dereference /etc/resolv.conf ${toolingroot}/etc/resolv.conf
cat >${toolingroot}/etc/profile.d/90_prompt.sh <<END
# Do not edit! Created by /$(basename $0)
PS1="($(basename ${toolingroot}) tooling) \$PS1"
END
}
################################################################
prepare_etc
if [[ $# -ne 0 ]]; then
setarch i386 chroot ${toolingroot} "${@}"
else
setarch i386 chroot ${toolingroot} /bin/bash --login
fi