lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Version of the install script for the SnapGear/uClinux tree. |
| 3 | # We avoid replacing utilities that already exist even if busybox has them |
| 4 | # compiled in when creating symbolic links. There is also a --nosubdir |
| 5 | # option to force absolutely everything to be placed in /bin instead of |
| 6 | # all over the place. |
| 7 | |
| 8 | export LC_ALL=POSIX |
| 9 | export LC_CTYPE=POSIX |
| 10 | |
| 11 | prefix=$1 |
| 12 | if [ "$prefix" = "" ]; then |
| 13 | echo "No installation directory, aborting." |
| 14 | exit 1; |
| 15 | fi |
| 16 | shift |
| 17 | |
| 18 | busybox_links=$1 |
| 19 | if [ ! -f "$busybox_links" ]; then |
| 20 | echo "busybox.links: No such file or directory" |
| 21 | echo "$busybox_links" |
| 22 | exit 1; |
| 23 | fi |
| 24 | shift |
| 25 | |
| 26 | hardlinks=0 |
| 27 | nosubdir=0 |
| 28 | while [ "$#" -gt 0 ]; do |
| 29 | if [ "$1" = "--hardlinks" ]; then |
| 30 | hardlinks=1 |
| 31 | elif [ "$1" = "--nosubdir" ]; then |
| 32 | nosubdir=1 |
| 33 | mkdir -p $prefix || exit 1 |
| 34 | else |
| 35 | echo "Invalid argument: $1" |
| 36 | fi |
| 37 | shift |
| 38 | done |
| 39 | if [ "$hardlinks" = "1" ]; then |
| 40 | linkopts="-f" |
| 41 | else |
| 42 | linkopts="-fs" |
| 43 | fi |
| 44 | h=`sort $busybox_links | uniq` |
| 45 | |
| 46 | for i in $h ; do |
| 47 | if [ "$nosubdir" = "1" ]; then |
| 48 | app=`basename $i` |
| 49 | if [ "$hardlinks" = "1" ]; then |
| 50 | bb_path="$prefix"busybox |
| 51 | else |
| 52 | bb_path=busybox |
| 53 | fi |
| 54 | else |
| 55 | app=$i |
| 56 | appdir=`dirname $i` |
| 57 | mkdir -p $prefix$appdir || exit 1 |
| 58 | if [ "$hardlinks" = "1" ]; then |
| 59 | bb_path="$prefix"bin/busybox |
| 60 | else |
| 61 | case "$appdir" in |
| 62 | /) |
| 63 | bb_path="bin/busybox" |
| 64 | ;; |
| 65 | /bin) |
| 66 | bb_path="busybox" |
| 67 | ;; |
| 68 | /sbin) |
| 69 | bb_path="../bin/busybox" |
| 70 | ;; |
| 71 | /usr/bin|/usr/sbin) |
| 72 | bb_path="../../bin/busybox" |
| 73 | ;; |
| 74 | *) |
| 75 | echo "Unknown installation directory: $appdir" |
| 76 | exit 1 |
| 77 | ;; |
| 78 | esac |
| 79 | fi |
| 80 | fi |
| 81 | if [ "$hardlinks" = "1" -o ! -f $prefix$app ]; then |
| 82 | echo " $prefix$app -> $bb_path" |
| 83 | ln $linkopts $bb_path $prefix$app || exit 1 |
| 84 | else |
| 85 | echo " $prefix$app already exists" |
| 86 | fi |
| 87 | done |
| 88 | |
| 89 | #${ROMFSINST} -a "telnet stream tcp nowait root /bin/telnetd telnetd" /etc/inetd.conf |
| 90 | |
| 91 | exit 0 |