source: MondoRescue/branches/3.2/mindi-busybox/applets/install.sh

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