diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-01 17:11:42 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-01 17:11:42 -0400 |
commit | 2b67e23c9482cf31a2968240364a826fb600b974 (patch) | |
tree | 716f14ad4f4252fca786beb151b4d2cfc97d3749 | |
parent | ac8a3c832addc68ee4ad01337a17f63bdb4138ab (diff) |
add install script for District10
This currently assumes installing from Ludwig to Jupiter via NFS.
-rwxr-xr-x | install_kernel.district10 | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/install_kernel.district10 b/install_kernel.district10 new file mode 100755 index 0000000..00eb7c6 --- /dev/null +++ b/install_kernel.district10 | |||
@@ -0,0 +1,118 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | TFTP_DIR=/home/nfsroot/tftp-boot | ||
4 | BOOT_LINK=uImage | ||
5 | |||
6 | USER_TAG=$USER | ||
7 | if [ ! -z "$SUDO_USER" ] | ||
8 | then | ||
9 | USER_TAG=$SUDO_USER | ||
10 | fi | ||
11 | |||
12 | MAKE_ACTIVE= | ||
13 | |||
14 | function die() | ||
15 | { | ||
16 | echo " (EE) $1" | ||
17 | exit 1 | ||
18 | } | ||
19 | |||
20 | function info() | ||
21 | { | ||
22 | echo " (II) $1" | ||
23 | } | ||
24 | |||
25 | function silent() | ||
26 | { | ||
27 | OUTPUT=`$*` | ||
28 | if [ "$?" != "0" ]; then | ||
29 | echo $OUTPUT | ||
30 | die "$* failed!" | ||
31 | fi | ||
32 | } | ||
33 | |||
34 | function usage() | ||
35 | { | ||
36 | cat <<EOF | ||
37 | Usage: install_kernel.district10 [--activate] | ||
38 | |||
39 | Options: | ||
40 | --activate Point uImage symlink to newly installed kernel. | ||
41 | |||
42 | Note: must be invoked in kernel src directory. | ||
43 | EOF | ||
44 | } | ||
45 | |||
46 | while [ ! -z "$1" ] | ||
47 | do | ||
48 | case $1 in | ||
49 | --activate) | ||
50 | shift | ||
51 | MAKE_ACTIVE=yes | ||
52 | ;; | ||
53 | --help|-h) | ||
54 | usage | ||
55 | exit 0 | ||
56 | ;; | ||
57 | *) # unknown argument | ||
58 | echo "Unknown argument $1" | ||
59 | usage | ||
60 | exit 1 | ||
61 | ;; | ||
62 | esac | ||
63 | done | ||
64 | |||
65 | |||
66 | if [ ! -f "./.config" ]; then | ||
67 | CURDIR=`pwd` | ||
68 | die "No kernel .config exists in $CURDIR!" | ||
69 | fi | ||
70 | |||
71 | if [ ! -f "./Makefile" ]; then | ||
72 | die "No Makefile present!" | ||
73 | fi | ||
74 | |||
75 | NAME=`cat include/config/kernel.release` | ||
76 | NAME=${NAME/%\+/} # remove trailing '+' (if any) | ||
77 | |||
78 | if [ -z "$NAME" ] | ||
79 | then | ||
80 | die "Could not determine kernel version!" | ||
81 | fi | ||
82 | |||
83 | info "Detected kernel version $NAME" | ||
84 | |||
85 | if [ $UID != "0" ]; then | ||
86 | die "Must be root to install kernel!" | ||
87 | fi | ||
88 | |||
89 | if [ ! -d "$TFTP_DIR" ] | ||
90 | then | ||
91 | die "TFTP directory $TFTP_DIR does not exist. Is the NFS root mounted?" | ||
92 | fi | ||
93 | |||
94 | KERNEL="uimage-${USER_TAG}-${NAME}" | ||
95 | UIMAGE="${TFTP_DIR}/$KERNEL" | ||
96 | CONFIG="${UIMAGE}.config" | ||
97 | SYSMAP="${UIMAGE}.System.map" | ||
98 | |||
99 | # (1) Copy kernel | ||
100 | info "Copy uImage to $UIMAGE" | ||
101 | silent cp -v arch/arm/boot/uImage "$UIMAGE" | ||
102 | |||
103 | # (2) .config | ||
104 | info "Copy .config to $CONFIG" | ||
105 | silent cp -v .config "$CONFIG" | ||
106 | |||
107 | # (3) System.map | ||
108 | info "Copy System.map to $SYSMAP" | ||
109 | silent cp -v System.map "$SYSMAP" | ||
110 | |||
111 | if [ -n "$MAKE_ACTIVE" ] | ||
112 | then | ||
113 | info "Pointing kernel symlink $BOOT_LINK to $KERNEL" | ||
114 | cd "$TFTP_DIR" | ||
115 | [ -L "$BOOT_LINK" ] || die "expected $BOOT_LINK in $TFTP_DIR to be a symbolic link." | ||
116 | silent rm "$BOOT_LINK" | ||
117 | silent ln -s "$KERNEL" "$BOOT_LINK" | ||
118 | fi | ||