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 |
Mike Frysinger | dcbad60 | 2006-02-20 19:28:34 +0000 | [diff] [blame] | 23 | x86_64|ppc64*|sparc64*|ia64*|hppa*64*|s390x*) libdir=/lib64 ;; |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 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 |
Bernhard Reutner-Fischer | 5d26126 | 2006-03-01 22:54:48 +0000 | [diff] [blame] | 31 | cp -a $i $prefix/$libdir/ || exit 1 |
| 32 | chmod 0644 $prefix/$libdir/$i || exit 1 |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 33 | fi |
| 34 | done |
| 35 | fi |
Pavel Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 36 | rm -f $prefix/bin/busybox || exit 1 |
| 37 | mkdir -p $prefix/bin || exit 1 |
| 38 | install -m 755 busybox $prefix/bin/busybox || exit 1 |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 39 | |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 40 | for i in $h ; do |
| 41 | appdir=`dirname $i` |
Pavel Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 42 | mkdir -p $prefix/$appdir || exit 1 |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 43 | 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 Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 65 | echo " $prefix$i -> $bb_path" |
| 66 | ln $linkopts $bb_path $prefix$i || exit 1 |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 67 | done |
| 68 | |
Eric Andersen | cb41c2e | 1999-11-22 07:41:00 +0000 | [diff] [blame] | 69 | exit 0 |