Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Eric Andersen | 39eea89 | 2001-03-08 21:42:11 +0000 | [diff] [blame] | 3 | export LC_ALL=POSIX |
| 4 | export LC_CTYPE=POSIX |
| 5 | |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 6 | prefix=${1} |
| 7 | if [ -z "$prefix" ]; then |
Rob Landley | c8e4115 | 2006-01-19 21:22:37 +0000 | [diff] [blame] | 8 | echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]" |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 9 | exit 1; |
| 10 | fi |
Eric Andersen | a9c95ea | 1999-11-15 17:33:30 +0000 | [diff] [blame] | 11 | h=`sort busybox.links | uniq` |
Rob Landley | e0c418e | 2005-12-15 07:25:54 +0000 | [diff] [blame] | 12 | case "$2" in |
| 13 | --hardlinks) linkopts="-f";; |
| 14 | --symlinks) linkopts="-fs";; |
| 15 | "") h="";; |
| 16 | *) echo "Unknown install option: $2"; exit 1;; |
| 17 | esac |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 18 | |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 19 | if [ "$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 |
| 23 | x86_64|ppc64*|sparc64*|ia64*|hppa*64*) libdir=/lib64 ;; |
| 24 | *) libdir=/lib ;; |
| 25 | esac |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 26 | |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 27 | 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 |
| 34 | fi |
Pavel Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 35 | rm -f $prefix/bin/busybox || exit 1 |
| 36 | mkdir -p $prefix/bin || exit 1 |
| 37 | install -m 755 busybox $prefix/bin/busybox || exit 1 |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 38 | |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 39 | for i in $h ; do |
| 40 | appdir=`dirname $i` |
Pavel Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 41 | mkdir -p $prefix/$appdir || exit 1 |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 42 | 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 Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 64 | echo " $prefix$i -> $bb_path" |
| 65 | ln $linkopts $bb_path $prefix$i || exit 1 |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 66 | done |
| 67 | |
Eric Andersen | cb41c2e | 1999-11-22 07:41:00 +0000 | [diff] [blame] | 68 | exit 0 |