summaryrefslogtreecommitdiffstats
path: root/install_kernel.jupiter-cs
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-05-23 03:49:11 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-05-23 03:49:11 -0400
commitf6005265512004afaf72d7e873fb6702af8a453c (patch)
treeedaf78aba840a0e5368c5efc317b842d766c8876 /install_kernel.jupiter-cs
assorted utilities from the LITMUS project
Diffstat (limited to 'install_kernel.jupiter-cs')
-rwxr-xr-xinstall_kernel.jupiter-cs92
1 files changed, 92 insertions, 0 deletions
diff --git a/install_kernel.jupiter-cs b/install_kernel.jupiter-cs
new file mode 100755
index 0000000..720fb9c
--- /dev/null
+++ b/install_kernel.jupiter-cs
@@ -0,0 +1,92 @@
1#!/bin/bash
2
3function die()
4{
5 echo " (EE) $1"
6 exit 1
7}
8
9function info()
10{
11 echo " (II) $1"
12}
13
14function silent()
15{
16 OUTPUT=`$*`
17 if [ "$?" != "0" ]; then
18 echo $OUTPUT
19 die "$* failed!"
20 fi
21}
22
23# Function to grab var from src
24function getvar() {
25 old=$(head -5 Makefile | grep "^$1")
26 echo $(echo ${old/"$1 ="/} | sed -e "s/[ ]*\(.*\)[ ]*/\1/g")
27 return 0
28}
29
30if [ ! -f "./.config" ]; then
31 CURDIR=`pwd`
32 die "No kernel .config exists in $CURDIR!"
33fi
34
35if [ ! -f "./Makefile" ]; then
36 die "No Makefile present!"
37fi
38
39VERSION=`getvar VERSION`
40PATCHLEVEL=`getvar PATCHLEVEL`
41SUBLEVEL=`getvar SUBLEVEL`
42EXTRAVERSION=`getvar EXTRAVERSION`
43
44. ./.config
45
46NAME="$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION$CONFIG_LOCALVERSION"
47
48info "Detected kernel version $NAME"
49
50if [ $UID != "0" ]; then
51 die "Must be root to install kernel!"
52fi
53
54# (1) copy modules
55if [ "$1" != "-m" ]; then
56 info "Installing modules..."
57 silent make -j8 modules_install
58else
59 info "Skipping installing modules."
60fi
61
62# (2) copy kernel
63info "Installing kernel..."
64silent cp -v arch/i386/boot/bzImage /boot/vmlinuz-$NAME
65silent cp -v System.map /boot/System.map-$NAME
66
67# (3) build ramdisk
68info "Building module dependencies"
69silent depmod -v $NAME
70
71info "Building initial ramdisk..."
72silent mkinitcpio -g /boot/kernel-$NAME.img -k $NAME
73
74# (4) make bootloader entry
75ALREADY_PRESENT=`grep "kernel /boot/vmlinuz-$NAME" /boot/grub/menu.lst `
76
77if [ ! -z "$ALREADY_PRESENT" ]; then
78 info "Bootloader entry appears to be already present."
79else
80 info "Creating bootloader entry..."
81 cat >> /boot/grub/menu.lst <<__EOE__
82
83# Custom kernel
84title Kernel $NAME
85root (hd0,5)
86kernel /boot/vmlinuz-$NAME root=/dev/sda6 ro vga=791
87initrd /boot/kernel-$NAME.img
88__EOE__
89
90fi
91
92info "Kernel $NAME has been installed."