Annotation of /trunk/mkinitrd-magellan/busybox/applets/install.sh
Parent Directory | Revision Log
Revision 816 -
(hide annotations)
(download)
(as text)
Fri Apr 24 18:33:46 2009 UTC (15 years ago) by niro
File MIME type: application/x-sh
File size: 2508 byte(s)
Fri Apr 24 18:33:46 2009 UTC (15 years ago) by niro
File MIME type: application/x-sh
File size: 2508 byte(s)
-updated to busybox-1.13.4
1 | niro | 532 | #!/bin/sh |
2 | |||
3 | export LC_ALL=POSIX | ||
4 | export LC_CTYPE=POSIX | ||
5 | |||
6 | prefix=${1} | ||
7 | if [ -z "$prefix" ]; then | ||
8 | niro | 816 | echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]" |
9 | niro | 532 | exit 1; |
10 | fi | ||
11 | h=`sort busybox.links | uniq` | ||
12 | niro | 816 | scriptwrapper="n" |
13 | niro | 532 | cleanup="0" |
14 | noclobber="0" | ||
15 | case "$2" in | ||
16 | niro | 816 | --hardlinks) linkopts="-f";; |
17 | --symlinks) linkopts="-fs";; | ||
18 | --scriptwrapper) scriptwrapper="y";swrapall="y";; | ||
19 | --sw-sh-hard) scriptwrapper="y";linkopts="-f";; | ||
20 | --sw-sh-sym) scriptwrapper="y";linkopts="-fs";; | ||
21 | --cleanup) cleanup="1";; | ||
22 | --noclobber) noclobber="1";; | ||
23 | "") h="";; | ||
24 | *) echo "Unknown install option: $2"; exit 1;; | ||
25 | niro | 532 | esac |
26 | |||
27 | if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then | ||
28 | # get the target dir for the libs | ||
29 | # assume it starts with lib | ||
30 | libdir=$($CC -print-file-name=libc.so | \ | ||
31 | sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p') | ||
32 | if test -z "$libdir"; then | ||
33 | libdir=/lib | ||
34 | fi | ||
35 | |||
36 | mkdir -p $prefix/$libdir || exit 1 | ||
37 | for i in $DO_INSTALL_LIBS; do | ||
38 | rm -f $prefix/$libdir/$i || exit 1 | ||
39 | if [ -f $i ]; then | ||
40 | niro | 816 | cp -pPR $i $prefix/$libdir/ || exit 1 |
41 | niro | 532 | chmod 0644 $prefix/$libdir/$i || exit 1 |
42 | fi | ||
43 | done | ||
44 | fi | ||
45 | |||
46 | if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then | ||
47 | inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'` | ||
48 | sub_shell_it=` | ||
49 | cd "$prefix" | ||
50 | niro | 816 | for d in usr/sbin usr/bin sbin bin; do |
51 | niro | 532 | pd=$PWD |
52 | if [ -d "$d" ]; then | ||
53 | cd $d | ||
54 | ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f | ||
55 | fi | ||
56 | cd "$pd" | ||
57 | done | ||
58 | ` | ||
59 | niro | 816 | exit 0 |
60 | niro | 532 | fi |
61 | |||
62 | rm -f $prefix/bin/busybox || exit 1 | ||
63 | mkdir -p $prefix/bin || exit 1 | ||
64 | install -m 755 busybox $prefix/bin/busybox || exit 1 | ||
65 | |||
66 | niro | 816 | for i in $h; do |
67 | niro | 532 | appdir=`dirname $i` |
68 | mkdir -p $prefix/$appdir || exit 1 | ||
69 | niro | 816 | if [ "$scriptwrapper" = "y" ]; then |
70 | if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then | ||
71 | ln $linkopts busybox $prefix$i || exit 1 | ||
72 | else | ||
73 | rm -f $prefix$i | ||
74 | echo "#!/bin/busybox" > $prefix$i | ||
75 | chmod +x $prefix/$i | ||
76 | fi | ||
77 | echo " $prefix$i" | ||
78 | niro | 532 | else |
79 | niro | 816 | if [ "$2" = "--hardlinks" ]; then |
80 | bb_path="$prefix/bin/busybox" | ||
81 | else | ||
82 | case "$appdir" in | ||
83 | /) | ||
84 | bb_path="bin/busybox" | ||
85 | ;; | ||
86 | /bin) | ||
87 | bb_path="busybox" | ||
88 | ;; | ||
89 | /sbin) | ||
90 | bb_path="../bin/busybox" | ||
91 | ;; | ||
92 | /usr/bin|/usr/sbin) | ||
93 | bb_path="../../bin/busybox" | ||
94 | ;; | ||
95 | *) | ||
96 | echo "Unknown installation directory: $appdir" | ||
97 | exit 1 | ||
98 | ;; | ||
99 | esac | ||
100 | fi | ||
101 | if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then | ||
102 | echo " $prefix$i -> $bb_path" | ||
103 | ln $linkopts $bb_path $prefix$i || exit 1 | ||
104 | else | ||
105 | echo " $prefix$i already exists" | ||
106 | fi | ||
107 | niro | 532 | fi |
108 | done | ||
109 | |||
110 | exit 0 |
Properties
Name | Value |
---|---|
svn:executable | * |