Clean up $1=$prefix
[oweals/busybox.git] / applets / install.sh
1 #!/bin/sh
2
3 set -e
4 set -x
5 prefix=$1
6 if [ "$prefix" = "" ]; then
7     echo "No installation directory, aborting."
8     exit 1;
9 fi
10 if [ "$2" = "--hardlinks" ]; then
11     linkopts="-f"
12 else
13     linkopts="-fs"
14 fi
15 h=`sort busybox.links | uniq`
16
17
18 rm -f $prefix/bin/busybox
19 mkdir -p $prefix/bin
20 install -m 755 busybox $prefix/bin/busybox
21
22 for i in $h ; do
23         appdir=`dirname $i`
24         mkdir -p $prefix/$appdir
25         if [ "$2" = "--hardlinks" ]; then
26             bb_path="$prefix/bin/busybox"
27         else
28             case "$appdir" in
29                 /)
30                     bb_path="bin/busybox"
31                 ;;
32                 /bin)
33                     bb_path="busybox"
34                 ;;
35                 /sbin)
36                     bb_path="../bin/busybox"
37                 ;;
38                 /usr/bin|/usr/sbin)
39                     bb_path="../../bin/busybox"
40                 ;;
41                 *)
42                 echo "Unknown installation directory: $appdir"
43                 exit 1
44                 ;;
45             esac
46         fi
47         echo "  $prefix$i -> /bin/busybox"
48         ln $linkopts $bb_path $prefix$i
49 done
50
51 exit 0