blob: 0173e7a445222f5bf606ca3f4f4c7bce5e3d5908 [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
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000031 cp -a $i $prefix/$libdir/ || exit 1
32 chmod 0644 $prefix/$libdir/$i || exit 1
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +000033 fi
34 done
35fi
Pavel Roskin259972e2000-07-28 19:34:02 +000036rm -f $prefix/bin/busybox || exit 1
37mkdir -p $prefix/bin || exit 1
38install -m 755 busybox $prefix/bin/busybox || exit 1
Eric Anderseneded54b1999-11-12 08:03:23 +000039
Eric Andersen51154ba2000-07-20 21:57:11 +000040for i in $h ; do
41 appdir=`dirname $i`
Pavel Roskin259972e2000-07-28 19:34:02 +000042 mkdir -p $prefix/$appdir || exit 1
Eric Andersen51154ba2000-07-20 21:57:11 +000043 if [ "$2" = "--hardlinks" ]; then
44 bb_path="$prefix/bin/busybox"
45 else
46 case "$appdir" in
47 /)
48 bb_path="bin/busybox"
49 ;;
50 /bin)
51 bb_path="busybox"
52 ;;
53 /sbin)
54 bb_path="../bin/busybox"
55 ;;
56 /usr/bin|/usr/sbin)
57 bb_path="../../bin/busybox"
58 ;;
59 *)
60 echo "Unknown installation directory: $appdir"
61 exit 1
62 ;;
63 esac
64 fi
Pavel Roskin259972e2000-07-28 19:34:02 +000065 echo " $prefix$i -> $bb_path"
66 ln $linkopts $bb_path $prefix$i || exit 1
Eric Andersen51154ba2000-07-20 21:57:11 +000067done
68
Eric Andersencb41c2e1999-11-22 07:41:00 +000069exit 0