blob: d9b56567842c9bf0f9c1a0dece2bb2f59121a5a1 (
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
|
#!/bin/bash
# Grab default values for $CFLAGS and such.
source ./configure
# Parse command line arguments.
[ -z "$PREFIX" ] && PREFIX="."
LONG_PATH=""
while [ ! -z "$1" ]
do
# Create symlinks instead of hardlinks?
[ "$1" == "--symlink" ] && LINK_TYPE="-s"
# Uninstall?
[ "$1" == "--uninstall" ] && UNINSTALL=1
# Delete destination command if it exists?
[ "$1" == "--force" ] && DO_FORCE="-f"
# Use {,usr}/{bin,sbin} paths instead of all files in one directory?
if [ "$1" == "--long" ]
then
LONG_PATH="bin/"
fi
shift
done
echo "Compile instlist..."
$DEBUG $HOSTCC -I . scripts/install.c -o instlist || exit 1
COMMANDS="$(./instlist $LONG_PATH)"
echo "Install commands..."
# Copy toybox itself
if [ -z "$UNINSTALL" ]
then
mkdir -p ${PREFIX}/${LONG_PATH} || exit 1
cp toybox ${PREFIX}/${LONG_PATH} || exit 1
else
rm "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null
rmdir "${PREFIX}/${LONG_PATH}" 2>/dev/null
fi
cd "${PREFIX}"
# Make links to toybox
for i in $COMMANDS
do
# Figure out target of link
if [ -z "$LONG_PATH" ]
then
DOTPATH=""
else
# Create subdirectory for command to go in (if necessary)
DOTPATH="$(echo $i | sed 's@\(.*/\).*@\1@')"
if [ -z "$UNINSTALL" ]
then
mkdir -p "$DOTPATH" || exit 1
else
rmdir "$DOTPATH" 2>/dev/null
fi
if [ -z "$LINK_TYPE" ]
then
dotpath="bin/"
else
if [ "$DOTPATH" != "$LONG_PATH" ]
then
DOTPATH="$(echo $DOTPATH | sed -e 's@[^/]*/@../@g')"$LONG_PATH
else
DOTPATH=""
fi
fi
fi
# Create link
[ -z "$UNINSTALL" ] &&
ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i ||
rm $i 2>/dev/null
done
|