Adjusted install.sh to use relative symlinks, and to optionally
[platform/upstream/busybox.git] / applets / install.sh
1 #!/bin/sh
2
3 set -e
4 set -x
5 if [ "$1" = "" ]; then
6     echo "No installation directory, aborting."
7     exit 1;
8 fi
9 if [ "$2" = "--hardlinks" ]; then
10     linkopts="-f"
11 else
12     linkopts="-fs"
13 fi
14 prefix=$1
15 h=`sort busybox.links | uniq`
16
17
18 rm -f $1/bin/busybox
19 mkdir -p $1/bin
20 install -m 755 busybox $1/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