7 if [ -z "$prefix" ]; then
8 echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--binaries/--scriptwrapper]"
12 # Source the configuration
15 h=`sort busybox.links | uniq`
25 --hardlinks) linkopts="-f";;
26 --symlinks) linkopts="-fs";;
27 --binaries) binaries="y";;
28 --scriptwrapper) scriptwrapper="y";swrapall="y";;
29 --sw-sh-hard) scriptwrapper="y";linkopts="-f";;
30 --sw-sh-sym) scriptwrapper="y";linkopts="-fs";;
31 --cleanup) cleanup="1";;
32 --noclobber) noclobber="1";;
34 *) echo "Unknown install option: $2"; exit 1;;
37 if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
38 # get the target dir for the libs
39 # assume it starts with lib
40 libdir=$($CC -print-file-name=libc.so | \
41 sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p')
42 if test -z "$libdir"; then
46 mkdir -p "$prefix/$libdir" || exit 1
47 for i in $DO_INSTALL_LIBS; do
48 rm -f "$prefix/$libdir/$i" || exit 1
50 echo " Installing $i to the target at $prefix/$libdir/"
51 cp -pPR "$i" "$prefix/$libdir/" || exit 1
52 chmod 0644 "$prefix/$libdir/`basename $i`" || exit 1
57 if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
58 inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
61 for d in usr/sbin usr/bin sbin bin; do
65 ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f
73 rm -f "$prefix/bin/busybox" || exit 1
74 mkdir -p "$prefix/bin" || exit 1
75 install -m 755 busybox "$prefix/bin/busybox" || exit 1
80 mkdir -p "$prefix/$appdir" || exit 1
81 if [ "$scriptwrapper" = "y" ]; then
82 if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
83 ln $linkopts busybox "$prefix/$i" || exit 1
86 echo "#!/bin/busybox" >"$prefix/$i"
90 elif [ "$binaries" = "y" ]; then
91 # Copy the binary over rather
92 if [ -e $sharedlib_dir/$app ]; then
93 if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
94 echo " Copying $sharedlib_dir/$app to $prefix/$i"
95 cp -pPR $sharedlib_dir/$app $prefix/$i || exit 1
97 echo " $prefix/$i already exists"
100 echo "Error: Could not find $sharedlib_dir/$app"
104 if [ "$2" = "--hardlinks" ]; then
105 bb_path="$prefix/bin/busybox"
109 bb_path="bin/busybox"
115 bb_path="../bin/busybox"
117 /usr/bin | /usr/sbin)
118 bb_path="../../bin/busybox"
121 echo "Unknown installation directory: $appdir"
126 if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
127 echo " $prefix/$i -> $bb_path"
128 ln $linkopts "$bb_path" "$prefix/$i" || exit 1
130 echo " $prefix/$i already exists"