blob: 9b00c63d1cdc3406666f5dad13a2b63a1abd6b4f [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
Mike Frysinger55b12102006-06-07 17:24:29 +00008 echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
9 exit 1;
Eric Anderseneded54b1999-11-12 08:03:23 +000010fi
Eric Andersena9c95ea1999-11-15 17:33:30 +000011h=`sort busybox.links | uniq`
Rob Landleye0c418e2005-12-15 07:25:54 +000012case "$2" in
Mike Frysinger55b12102006-06-07 17:24:29 +000013 --hardlinks) linkopts="-f";;
14 --symlinks) linkopts="-fs";;
15 "") h="";;
16 *) echo "Unknown install option: $2"; exit 1;;
Rob Landleye0c418e2005-12-15 07:25:54 +000017esac
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
Rob Landleyd1968672006-03-24 02:42:58 +000021 # assume it starts with lib
22 libdir=$($CC -print-file-name=libc.so | \
23 sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p')
24 if test -z "$libdir"; then
25 libdir=/lib
26 fi
Eric Andersen51154ba2000-07-20 21:57:11 +000027
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +000028 mkdir -p $prefix/$libdir || exit 1
29 for i in $DO_INSTALL_LIBS; do
30 rm -f $prefix/$libdir/$i || exit 1
31 if [ -f $i ]; then
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000032 cp -a $i $prefix/$libdir/ || exit 1
33 chmod 0644 $prefix/$libdir/$i || exit 1
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +000034 fi
35 done
36fi
Pavel Roskin259972e2000-07-28 19:34:02 +000037rm -f $prefix/bin/busybox || exit 1
38mkdir -p $prefix/bin || exit 1
39install -m 755 busybox $prefix/bin/busybox || exit 1
Eric Anderseneded54b1999-11-12 08:03:23 +000040
Eric Andersen51154ba2000-07-20 21:57:11 +000041for i in $h ; do
42 appdir=`dirname $i`
Pavel Roskin259972e2000-07-28 19:34:02 +000043 mkdir -p $prefix/$appdir || exit 1
Eric Andersen51154ba2000-07-20 21:57:11 +000044 if [ "$2" = "--hardlinks" ]; then
Mike Frysinger55b12102006-06-07 17:24:29 +000045 bb_path="$prefix/bin/busybox"
Eric Andersen51154ba2000-07-20 21:57:11 +000046 else
Mike Frysinger55b12102006-06-07 17:24:29 +000047 case "$appdir" in
Eric Andersen51154ba2000-07-20 21:57:11 +000048 /)
Mike Frysinger55b12102006-06-07 17:24:29 +000049 bb_path="bin/busybox"
Eric Andersen51154ba2000-07-20 21:57:11 +000050 ;;
51 /bin)
Mike Frysinger55b12102006-06-07 17:24:29 +000052 bb_path="busybox"
Eric Andersen51154ba2000-07-20 21:57:11 +000053 ;;
54 /sbin)
Mike Frysinger55b12102006-06-07 17:24:29 +000055 bb_path="../bin/busybox"
Eric Andersen51154ba2000-07-20 21:57:11 +000056 ;;
57 /usr/bin|/usr/sbin)
Mike Frysinger55b12102006-06-07 17:24:29 +000058 bb_path="../../bin/busybox"
Eric Andersen51154ba2000-07-20 21:57:11 +000059 ;;
60 *)
61 echo "Unknown installation directory: $appdir"
62 exit 1
63 ;;
Mike Frysinger55b12102006-06-07 17:24:29 +000064 esac
Eric Andersen51154ba2000-07-20 21:57:11 +000065 fi
Pavel Roskin259972e2000-07-28 19:34:02 +000066 echo " $prefix$i -> $bb_path"
67 ln $linkopts $bb_path $prefix$i || exit 1
Eric Andersen51154ba2000-07-20 21:57:11 +000068done
69
Eric Andersencb41c2e1999-11-22 07:41:00 +000070exit 0