7 if [ -z "$prefix" ]; then
8 echo "usage: applets/install.sh DESTINATION TYPE [OPTS ...]"
9 echo " TYPE is one of: --symlinks --hardlinks --binaries --scriptwrapper --none"
10 echo " OPTS is one or more of: --cleanup --noclobber"
13 shift # Keep only remaining options
15 # Source the configuration
18 h=`sort busybox.links | uniq`
27 while [ ${#} -gt 0 ]; do
29 --hardlinks) linkopts="-f";;
30 --symlinks) linkopts="-fs";;
31 --binaries) binaries="y";;
32 --scriptwrapper) scriptwrapper="y"; swrapall="y";;
33 --sw-sh-hard) scriptwrapper="y"; linkopts="-f";;
34 --sw-sh-sym) scriptwrapper="y"; linkopts="-fs";;
35 --cleanup) cleanup="1";;
36 --noclobber) noclobber="1";;
38 *) echo "Unknown install option: $1"; exit 1;;
43 if [ -n "$DO_INSTALL_LIBS" ] && [ x"$DO_INSTALL_LIBS" != x"n" ]; then
44 # get the target dir for the libs
45 # assume it starts with lib
46 libdir=$($CC -print-file-name=libc.so | \
47 sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p')
48 if test -z "$libdir"; then
52 mkdir -p "$prefix/$libdir" || exit 1
53 for i in $DO_INSTALL_LIBS; do
54 rm -f "$prefix/$libdir/$i" || exit 1
56 echo " Installing $i to the target at $prefix/$libdir/"
57 cp -pPR "$i" "$prefix/$libdir/" || exit 1
58 chmod 0644 "$prefix/$libdir/`basename $i`" || exit 1
63 if [ x"$cleanup" = x"1" ] && [ -e "$prefix/bin/busybox" ]; then
64 inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
67 for d in usr/sbin usr/bin sbin bin; do
71 ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f
79 rm -f "$prefix/bin/busybox" || exit 1
80 mkdir -p "$prefix/bin" || exit 1
81 install -m 755 busybox "$prefix/bin/busybox" || exit 1
86 if [ x"$noclobber" = x"1" ] && ([ -e "$prefix/$i" ] || [ -h "$prefix/$i" ]); then
87 echo " $prefix/$i already exists"
90 mkdir -p "$prefix/$appdir" || exit 1
91 if [ x"$scriptwrapper" = x"y" ]; then
92 if [ x"$swrapall" != x"y" ] && [ x"$i" = x"/bin/sh" ]; then
93 ln $linkopts busybox "$prefix/$i" || exit 1
96 echo "#!/bin/busybox" >"$prefix/$i"
100 elif [ x"$binaries" = x"y" ]; then
101 # Copy the binary over rather
102 if [ -e "$sharedlib_dir/$app" ]; then
103 echo " Copying $sharedlib_dir/$app to $prefix/$i"
104 cp -pPR "$sharedlib_dir/$app" "$prefix/$i" || exit 1
106 echo "Error: Could not find $sharedlib_dir/$app"
110 if [ x"$linkopts" = x"-f" ]; then
111 bb_path="$prefix/bin/busybox"
115 bb_path="bin/busybox"
121 bb_path="../bin/busybox"
123 /usr/bin | /usr/sbin)
124 bb_path="../../bin/busybox"
127 echo "Unknown installation directory: $appdir"
132 echo " $prefix/$i -> $bb_path"
133 ln $linkopts "$bb_path" "$prefix/$i" || exit 1