annotate scripts/install.sh @ 668:0ee40175a307

Fix catv to display byte 255 correctly. (It's both M- and ^?.)
author Rob Landley <rob@landley.net>
date Sat, 06 Oct 2012 01:54:24 -0500
parents 150a6d81bd02
children 1c15ba60aa64
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
266
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 # Grab default values for $CFLAGS and such.
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 source ./configure
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 # Parse command line arguments.
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
8
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 [ -z "$PREFIX" ] && PREFIX="."
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
10
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 LONG_PATH=""
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 while [ ! -z "$1" ]
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 do
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 # Create symlinks instead of hardlinks?
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
15
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 [ "$1" == "--symlink" ] && LINK_TYPE="-s"
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
17
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 # Uninstall?
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
19
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 [ "$1" == "--uninstall" ] && UNINSTALL=1
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
21
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 # Delete destination command if it exists?
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
23
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 [ "$1" == "--force" ] && DO_FORCE="-f"
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
25
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 # Use {,usr}/{bin,sbin} paths instead of all files in one directory?
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
27
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 if [ "$1" == "--long" ]
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 then
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 LONG_PATH="bin/"
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 fi
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
32
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 shift
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 done
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
35
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 echo "Compile instlist..."
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
37
603
150a6d81bd02 Replace CCFLAGS with description of how to add flags to HOSTCC.
Rob Landley <rob@landley.net>
parents: 266
diff changeset
38 $DEBUG $HOSTCC -I . scripts/install.c -o instlist || exit 1
266
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 COMMANDS="$(./instlist $LONG_PATH)"
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
40
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 echo "Install commands..."
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
42
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 # Copy toybox itself
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
44
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 if [ -z "$UNINSTALL" ]
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 then
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 mkdir -p ${PREFIX}/${LONG_PATH} || exit 1
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 cp toybox ${PREFIX}/${LONG_PATH} || exit 1
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 else
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 rm "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 rmdir "${PREFIX}/${LONG_PATH}" 2>/dev/null
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 fi
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 cd "${PREFIX}"
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
54
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 # Make links to toybox
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
56
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 for i in $COMMANDS
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 do
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 # Figure out target of link
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
60
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 if [ -z "$LONG_PATH" ]
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 then
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
63 DOTPATH=""
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
64 else
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
65 # Create subdirectory for command to go in (if necessary)
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
66
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
67 DOTPATH="$(echo $i | sed 's@\(.*/\).*@\1@')"
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
68 if [ -z "$UNINSTALL" ]
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
69 then
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
70 mkdir -p "$DOTPATH" || exit 1
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
71 else
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
72 rmdir "$DOTPATH" 2>/dev/null
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
73 fi
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
74
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
75 if [ -z "$LINK_TYPE" ]
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
76 then
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
77 dotpath="bin/"
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
78 else
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
79 if [ "$DOTPATH" != "$LONG_PATH" ]
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
80 then
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
81 DOTPATH="$(echo $DOTPATH | sed -e 's@[^/]*/@../@g')"$LONG_PATH
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
82 else
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
83 DOTPATH=""
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
84 fi
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
85 fi
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
86 fi
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
87
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
88 # Create link
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
89 [ -z "$UNINSTALL" ] &&
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
90 ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i ||
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
91 rm $i 2>/dev/null
2ba3b8dce3ef Add an install script, with --long --symlink --force and --uninstall options.
Rob Landley <rob@landley.net>
parents:
diff changeset
92 done