blob: 2c643f2f229b44d316b106341e4c6a730a82a779 [file] [log] [blame]
Eric Anderseneded54b1999-11-12 08:03:23 +00001#!/bin/sh
2
Eric Andersen39eea892001-03-08 21:42:11 +00003export LC_ALL=POSIX
4export LC_CTYPE=POSIX
5
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +00006prefix=${1}
7if [ -z "$prefix" ]; then
Rob Landleyc8e41152006-01-19 21:22:37 +00008 echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
Eric Anderseneded54b1999-11-12 08:03:23 +00009 exit 1;
10fi
Eric Andersena9c95ea1999-11-15 17:33:30 +000011h=`sort busybox.links | uniq`
Rob Landleye0c418e2005-12-15 07:25:54 +000012case "$2" in
13 --hardlinks) linkopts="-f";;
14 --symlinks) linkopts="-fs";;
15 "") h="";;
16 *) echo "Unknown install option: $2"; exit 1;;
17esac
Eric Anderseneded54b1999-11-12 08:03:23 +000018
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +000019if [ "$DO_INSTALL_LIBS" != "n" ]; then
20 # get the target dir for the libs
21 # This is an incomplete/incorrect list for now
22 case $(uname -m) in
Mike Frysingerdcbad602006-02-20 19:28:34 +000023 x86_64|ppc64*|sparc64*|ia64*|hppa*64*|s390x*) libdir=/lib64 ;;
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +000024 *) libdir=/lib ;;
25 esac
Eric Andersen51154ba2000-07-20 21:57:11 +000026
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +000027 mkdir -p $prefix/$libdir || exit 1
28 for i in $DO_INSTALL_LIBS; do
29 rm -f $prefix/$libdir/$i || exit 1
30 if [ -f $i ]; then
31 install -m 644 $i $prefix/$libdir/ || exit 1
32 fi
33 done
34fi
Pavel Roskin259972e2000-07-28 19:34:02 +000035rm -f $prefix/bin/busybox || exit 1
36mkdir -p $prefix/bin || exit 1
37install -m 755 busybox $prefix/bin/busybox || exit 1
Eric Anderseneded54b1999-11-12 08:03:23 +000038
Eric Andersen51154ba2000-07-20 21:57:11 +000039for i in $h ; do
40 appdir=`dirname $i`
Pavel Roskin259972e2000-07-28 19:34:02 +000041 mkdir -p $prefix/$appdir || exit 1
Eric Andersen51154ba2000-07-20 21:57:11 +000042 if [ "$2" = "--hardlinks" ]; then
43 bb_path="$prefix/bin/busybox"
44 else
45 case "$appdir" in
46 /)
47 bb_path="bin/busybox"
48 ;;
49 /bin)
50 bb_path="busybox"
51 ;;
52 /sbin)
53 bb_path="../bin/busybox"
54 ;;
55 /usr/bin|/usr/sbin)
56 bb_path="../../bin/busybox"
57 ;;
58 *)
59 echo "Unknown installation directory: $appdir"
60 exit 1
61 ;;
62 esac
63 fi
Pavel Roskin259972e2000-07-28 19:34:02 +000064 echo " $prefix$i -> $bb_path"
65 ln $linkopts $bb_path $prefix$i || exit 1
Eric Andersen51154ba2000-07-20 21:57:11 +000066done
67
Eric Andersencb41c2e1999-11-22 07:41:00 +000068exit 0