summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-09-11 13:07:35 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-09-11 13:07:35 -0400
commit85696715849de7ab98e669664251e7f22cf7983f (patch)
tree0948b34077d46c6a199ad970187228bc34230a7f
parentb65ea2396e5a77600958f73d6b8bb13c6e1042ad (diff)
the flare version of install_kernel
-rwxr-xr-xinstall_kernel.flare114
1 files changed, 114 insertions, 0 deletions
diff --git a/install_kernel.flare b/install_kernel.flare
new file mode 100755
index 0000000..b0533ff
--- /dev/null
+++ b/install_kernel.flare
@@ -0,0 +1,114 @@
1#!/bin/bash
2
3function log()
4{
5 echo "$1" >> /tmp/install_kernel.log
6}
7
8function die()
9{
10 echo " (EE) $1"
11 log " (EE) $1"
12 exit 1
13}
14
15function info()
16{
17 echo " (II) $1"
18 log " (II) $1"
19}
20
21function silent()
22{
23 OUTPUT=`$*`
24 if [ "$?" != "0" ]; then
25 echo $OUTPUT
26 die "$* failed!"
27 else
28 log "$OUTPUT"
29 fi
30}
31
32# Function to grab var from src
33function getvar() {
34 old=$(head -5 Makefile | grep "^$1")
35 echo $(echo ${old/"$1 ="/} | sed -e "s/[ ]*\(.*\)[ ]*/\1/g")
36 return 0
37}
38
39if [ ! -f "./.config" ]; then
40 CURDIR=`pwd`
41 die "No kernel .config exists in $CURDIR!"
42fi
43
44if [ ! -f "./Makefile" ]; then
45 die "No Makefile present!"
46fi
47
48VERSION=`getvar VERSION`
49PATCHLEVEL=`getvar PATCHLEVEL`
50SUBLEVEL=`getvar SUBLEVEL`
51EXTRAVERSION=`getvar EXTRAVERSION`
52
53. ./.config
54
55NAME="$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION$CONFIG_LOCALVERSION"
56
57info "Detected kernel version $NAME"
58
59if [ $UID != "0" ]; then
60 die "Must be root to install kernel!"
61fi
62
63# (1) copy modules
64if [ "$1" != "-m" ]; then
65 info "Installing modules..."
66 silent make -j32 modules_install
67else
68 info "Skipping installing modules."
69fi
70
71# (2) copy kernel
72info "Installing kernel..."
73silent cp -v arch/sparc64/boot/image /boot/vmlinuz-$NAME
74silent cp -v System.map /boot/System.map-$NAME
75
76# (3) build ramdisk
77info "Building module dependencies"
78silent depmod -v $NAME
79
80ALREADY_LINKED=`ls /lib/firmware | grep "$NAME" `
81if [ ! -z "$ALREADY_LINKED" ]; then
82 info "Firmware library files already linked."
83else
84 info "Creating link to firmware library files..."
85 silent ln -s /lib/firmware/2.6.22-14-sparc64-smp /lib/firmware/$NAME
86fi
87
88if [ "$1" != "-m" ]; then
89 info "Building initial ramdisk..."
90 silent update-initramfs -c -k $NAME
91else
92 info "Skipping updating initial ramdisk..."
93fi
94
95# (4) make bootloader entry
96ALREADY_PRESENT=`grep "^image=/vmlinuz-${NAME}$" /boot/silo.conf `
97
98if [ ! -z "$ALREADY_PRESENT" ]; then
99 info "Bootloader entry appears to be already present."
100else
101 info "Creating bootloader entry..."
102 cat >> /boot/silo.conf <<__EOE__
103
104image=/vmlinuz-$NAME
105 label=Kernel-$NAME
106 initrd=/initrd.img-$NAME
107 root=/dev/disk/by-uuid/4ebd4362-682e-4856-a467-086a3780179c
108 partition=4
109 append="quiet splash"
110__EOE__
111
112fi
113
114info "Kernel $NAME has been installed."