source: MondoRescue/branches/3.3/mindi-busybox/applets/install.sh@ 3625

Last change on this file since 3625 was 3621, checked in by Bruno Cornec, 10 years ago

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

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