7 if [ -z "$prefix" ]; then
8 echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--binaries/--scriptwrapper]"
11 shift # Keep only remaining options
13 # Source the configuration
16 h=`sort busybox.links | uniq`
25 while [ ${#} -gt 0 ]; do
27 --hardlinks) linkopts="-f";;
28 --symlinks) linkopts="-fs";;
29 --binaries) binaries="y";;
30 --scriptwrapper) scriptwrapper="y"; swrapall="y";;
31 --sw-sh-hard) scriptwrapper="y"; linkopts="-f";;
32 --sw-sh-sym) scriptwrapper="y"; linkopts="-fs";;
33 --cleanup) cleanup="1";;
34 --noclobber) noclobber="1";;
36 *) echo "Unknown install option: $1"; exit 1;;
41 if [ -n "$DO_INSTALL_LIBS" ] && [ x"$DO_INSTALL_LIBS" != x"n" ]; then
42 # get the target dir for the libs
43 # assume it starts with lib
44 libdir=$($CC -print-file-name=libc.so | \
45 sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p')
46 if test -z "$libdir"; then
50 mkdir -p "$prefix/$libdir" || exit 1
51 for i in $DO_INSTALL_LIBS; do
52 rm -f "$prefix/$libdir/$i" || exit 1
54 echo " Installing $i to the target at $prefix/$libdir/"
55 cp -pPR "$i" "$prefix/$libdir/" || exit 1
56 chmod 0644 "$prefix/$libdir/`basename $i`" || exit 1
61 if [ x"$cleanup" = x"1" ] && [ -e "$prefix/bin/busybox" ]; then
62 inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
65 for d in usr/sbin usr/bin sbin bin; do
69 ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f
77 rm -f "$prefix/bin/busybox" || exit 1
78 mkdir -p "$prefix/bin" || exit 1
79 install -m 755 busybox "$prefix/bin/busybox" || exit 1
84 if [ x"$noclobber" = x"1" ] && [ -e "$prefix/$i" ]; then
85 echo " $prefix/$i already exists"
88 mkdir -p "$prefix/$appdir" || exit 1
89 if [ x"$scriptwrapper" = x"y" ]; then
90 if [ x"$swrapall" != x"y" ] && [ x"$i" = x"/bin/sh" ]; then
91 ln $linkopts busybox "$prefix/$i" || exit 1
94 echo "#!/bin/busybox" >"$prefix/$i"
98 elif [ x"$binaries" = x"y" ]; then
99 # Copy the binary over rather
100 if [ -e "$sharedlib_dir/$app" ]; then
101 echo " Copying $sharedlib_dir/$app to $prefix/$i"
102 cp -pPR "$sharedlib_dir/$app" "$prefix/$i" || exit 1
104 echo "Error: Could not find $sharedlib_dir/$app"
108 if [ x"$linkopts" = x"-f" ]; then
109 bb_path="$prefix/bin/busybox"
113 bb_path="bin/busybox"
119 bb_path="../bin/busybox"
121 /usr/bin | /usr/sbin)
122 bb_path="../../bin/busybox"
125 echo "Unknown installation directory: $appdir"
130 echo " $prefix/$i -> $bb_path"
131 ln $linkopts "$bb_path" "$prefix/$i" || exit 1