blob: 6c5071405651ddd6f339944b363401b9d470b2a3 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#!/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
8export LC_ALL=POSIX
9export LC_CTYPE=POSIX
10
11prefix=$1
12if [ "$prefix" = "" ]; then
13 echo "No installation directory, aborting."
14 exit 1;
15fi
16shift
17
18busybox_links=$1
19if [ ! -f "$busybox_links" ]; then
20 echo "busybox.links: No such file or directory"
21 echo "$busybox_links"
22 exit 1;
23fi
24shift
25
26hardlinks=0
27nosubdir=0
28while [ "$#" -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
38done
39if [ "$hardlinks" = "1" ]; then
40 linkopts="-f"
41else
42 linkopts="-fs"
43fi
44h=`sort $busybox_links | uniq`
45
46for 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
87done
88
89#${ROMFSINST} -a "telnet stream tcp nowait root /bin/telnetd telnetd" /etc/inetd.conf
90
91exit 0