source: MondoRescue/branches/2.2.9/mindi-busybox/applets/install.sh@ 3320

Last change on this file since 3320 was 3320, checked in by Bruno Cornec, 9 years ago
  • Re-add (thanks git BTW) the 2.2.9 branch which had been destroyed in the move to 3.0
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.4 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
11h=`sort busybox.links | uniq`
12scriptwrapper="n"
13cleanup="0"
14noclobber="0"
15case "$2" in
16 --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;;
25esac
26
27if [ -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 cp -pPR $i $prefix/$libdir/ || exit 1
41 chmod 0644 $prefix/$libdir/$i || exit 1
42 fi
43 done
44fi
45
46if [ "$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 for d in usr/sbin usr/bin sbin bin; do
51 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 exit 0
60fi
61
62rm -f $prefix/bin/busybox || exit 1
63mkdir -p $prefix/bin || exit 1
64install -m 755 busybox $prefix/bin/busybox || exit 1
65
66for i in $h; do
67 appdir=`dirname $i`
68 mkdir -p $prefix/$appdir || exit 1
69 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 else
79 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 fi
108done
109
110exit 0
Note: See TracBrowser for help on using the repository browser.