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 |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 8 | echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]" |
| 9 | exit 1; |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 10 | fi |
Eric Andersen | a9c95ea | 1999-11-15 17:33:30 +0000 | [diff] [blame] | 11 | h=`sort busybox.links | uniq` |
Mike Frysinger | 81514ec | 2006-06-07 18:08:25 +0000 | [diff] [blame^] | 12 | cleanup="0" |
Rob Landley | e0c418e | 2005-12-15 07:25:54 +0000 | [diff] [blame] | 13 | case "$2" in |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 14 | --hardlinks) linkopts="-f";; |
| 15 | --symlinks) linkopts="-fs";; |
Mike Frysinger | 81514ec | 2006-06-07 18:08:25 +0000 | [diff] [blame^] | 16 | --cleanup) cleanup="1";; |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 17 | "") h="";; |
| 18 | *) echo "Unknown install option: $2"; exit 1;; |
Rob Landley | e0c418e | 2005-12-15 07:25:54 +0000 | [diff] [blame] | 19 | esac |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 20 | |
Mike Frysinger | 74b29a1 | 2006-06-07 17:27:46 +0000 | [diff] [blame] | 21 | if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 22 | # get the target dir for the libs |
Rob Landley | d196867 | 2006-03-24 02:42:58 +0000 | [diff] [blame] | 23 | # assume it starts with lib |
| 24 | libdir=$($CC -print-file-name=libc.so | \ |
| 25 | sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p') |
| 26 | if test -z "$libdir"; then |
| 27 | libdir=/lib |
| 28 | fi |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 29 | |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 30 | mkdir -p $prefix/$libdir || exit 1 |
| 31 | for i in $DO_INSTALL_LIBS; do |
| 32 | rm -f $prefix/$libdir/$i || exit 1 |
| 33 | if [ -f $i ]; then |
Bernhard Reutner-Fischer | 5d26126 | 2006-03-01 22:54:48 +0000 | [diff] [blame] | 34 | cp -a $i $prefix/$libdir/ || exit 1 |
| 35 | chmod 0644 $prefix/$libdir/$i || exit 1 |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 36 | fi |
| 37 | done |
| 38 | fi |
Mike Frysinger | 81514ec | 2006-06-07 18:08:25 +0000 | [diff] [blame^] | 39 | |
| 40 | if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then |
| 41 | inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'` |
| 42 | sub_shell_it=` |
| 43 | cd "$prefix" |
| 44 | for d in usr/sbin usr/bin sbin bin ; do |
| 45 | pd=$PWD |
| 46 | if [ -d "$d" ]; then |
| 47 | cd $d |
| 48 | ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f |
| 49 | fi |
| 50 | cd "$pd" |
| 51 | done |
| 52 | ` |
| 53 | fi |
| 54 | |
Pavel Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 55 | rm -f $prefix/bin/busybox || exit 1 |
| 56 | mkdir -p $prefix/bin || exit 1 |
| 57 | install -m 755 busybox $prefix/bin/busybox || exit 1 |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 58 | |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 59 | for i in $h ; do |
| 60 | appdir=`dirname $i` |
Pavel Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 61 | mkdir -p $prefix/$appdir || exit 1 |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 62 | if [ "$2" = "--hardlinks" ]; then |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 63 | bb_path="$prefix/bin/busybox" |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 64 | else |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 65 | case "$appdir" in |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 66 | /) |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 67 | bb_path="bin/busybox" |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 68 | ;; |
| 69 | /bin) |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 70 | bb_path="busybox" |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 71 | ;; |
| 72 | /sbin) |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 73 | bb_path="../bin/busybox" |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 74 | ;; |
| 75 | /usr/bin|/usr/sbin) |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 76 | bb_path="../../bin/busybox" |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 77 | ;; |
| 78 | *) |
| 79 | echo "Unknown installation directory: $appdir" |
| 80 | exit 1 |
| 81 | ;; |
Mike Frysinger | 55b1210 | 2006-06-07 17:24:29 +0000 | [diff] [blame] | 82 | esac |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 83 | fi |
Pavel Roskin | 259972e | 2000-07-28 19:34:02 +0000 | [diff] [blame] | 84 | echo " $prefix$i -> $bb_path" |
| 85 | ln $linkopts $bb_path $prefix$i || exit 1 |
Eric Andersen | 51154ba | 2000-07-20 21:57:11 +0000 | [diff] [blame] | 86 | done |
| 87 | |
Eric Andersen | cb41c2e | 1999-11-22 07:41:00 +0000 | [diff] [blame] | 88 | exit 0 |