blob: b9fdeacd77c167adf28c0e7de1b6eaf1a3af36f7 (
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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#!/bin/sh
usage () {
cat - >&2 <<EOF
fakeroot-like wrapper for pseudo, create a fake root environment.
usage: fakeroot [-l|--lib fakerootlib] [-f|--faked fakedbin]
[-i file] [-s file] [-u|--unknown-is-real]
[-b|--fd-base fd] [-h|--help] [-v|--version]
[--] [command]
EOF
exit 1
}
stderr ()
{
local i
for i
do
echo >&2 "fakeroot: $i"
done
}
fatal ()
{
stderr "$@"
exit 1
}
# strip /bin/fakeroot to find install prefix
FAKEROOT_PREFIX=/usr
FAKEROOT_BINDIR=/usr/bin
KEEPSTATEDIR=0
GETOPTEST=`getopt --version`
case $GETOPTEST in
getopt*) # GNU getopt
FAKE_TEMP=`getopt -l lib: -l faked: -l unknown-is-real -l fd-base: -l version -l help -- +l:f:i:s:ub:vh "$@"`
;;
*) # POSIX getopt ?
FAKE_TEMP=`getopt l:f:i:s:ub:vh "$@"`
;;
esac
if [ "$?" -ne 0 ]
then
usage
fi
eval set -- "$FAKE_TEMP"
while test "X$1" != "X--"; do
case "$1" in
-l|--lib)
shift
;;
-f|--faked)
shift
;;
-i)
shift
if test -d "$1"
then
PSEUDO_LOCALSTATEDIR="$(readlink -m "$1")"
else
stderr "local state dir \`$1' doesn't exist."
fi
;;
-s)
shift
if mkdir -p "$1"
then
PSEUDO_LOCALSTATEDIR="$(readlink -m "$1")"
KEEPSTATEDIR=1
else
stderr "local state dir \`$1' could not be created."
fi
;;
-u|--unknown-is-real)
;;
-b|--fd-base)
shift
;;
-v|--version)
printf "fakeroot wrapper for "
pseudo -V
exit 0
;;
-h|--help)
usage
;;
esac
shift
done
shift #get rid of the '--'
if [ -z "$PSEUDO_LOCALSTATEDIR" ]
then
UID=`id -u`
if [ -d /run/user/$UID -a -w /run/user/$UID ]
then
PSEUDO_LOCALSTATEDIR=/run/user/$UID/pseudo/$$
mkdir -p "$PSEUDO_LOCALSTATEDIR"
else
PSEUDO_LOCALSTATEDIR=/tmp/pseudo.$UID/$$
if ! mkdir -p "$PSEUDO_LOCALSTATEDIR"
then
fatal "Could not find a suitable state dir"
fi
fi
fi
export PSEUDO_PREFIX=/usr
export PSEUDO_LOCALSTATEDIR
pseudo "$@"
RESULT=$?
if [ "$KEEPSTATEDIR" -ne 1 ]
then
rm -rf "$PSEUDO_LOCALSTATEDIR"
fi
exit $RESULT
# Local Variables:
# mode: shell-script
# End:
|