summaryrefslogtreecommitdiffstats
path: root/install_kernel.bonham
diff options
context:
space:
mode:
Diffstat (limited to 'install_kernel.bonham')
-rwxr-xr-xinstall_kernel.bonham116
1 files changed, 116 insertions, 0 deletions
diff --git a/install_kernel.bonham b/install_kernel.bonham
new file mode 100755
index 0000000..b7958e0
--- /dev/null
+++ b/install_kernel.bonham
@@ -0,0 +1,116 @@
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 -j32 modules_install
58else
59 info "Skipping installing modules."
60fi
61
62# (2) copy kernel
63info "Installing kernel..."
64silent cp -v arch/x86_64/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
71if [ "$1" != "-m" ]; then
72 info "Building initial ramdisk..."
73 silent update-initramfs -c -k $NAME
74else
75 info "Skipping updating initial ramdisk..."
76fi
77
78# (4) make bootloader entry
79ALREADY_PRESENT=`grep "/vmlinuz-$NAME" /etc/grub.d/15_litmus `
80
81if [ ! -z "$ALREADY_PRESENT" ]; then
82 info "Bootloader entry appears to be already present."
83else
84 info "Creating bootloader entry..."
85
86 if [[ "$NAME" =~ "litmus" ]]; then
87 cat >> /etc/grub.d/15_litmus <<__EOE__
88
89menuentry 'Ubuntu/Litmus, with $NAME' --class ubuntu --class gnu-linux --class gnu --class os {
90 recordfail
91 insmod ext2
92 set root='(hd0,3)'
93 search --no-floppy --fs-uuid --set 08b4e70f-d536-45bc-8693-164891c8834b
94 linux /vmlinuz-$NAME root=/dev/sda5 ro quanta=aligned
95 initrd /initrd.img-$NAME
96}
97__EOE__
98 else
99 cat >> /etc/grub.d/15_litmus <<__EOE__
100
101menuentry 'Ubuntu/Custom Kernel, with $NAME' --class ubuntu --class gnu-linux --class gnu --class os {
102 recordfail
103 insmod ext2
104 set root='(hd0,3)'
105 search --no-floppy --fs-uuid --set 08b4e70f-d536-45bc-8693-164891c8834b
106 linux /vmlinuz-$NAME root=/dev/sda5 ro
107 initrd /initrd.img-$NAME
108}
109__EOE__
110 fi
111
112update-grub
113
114fi
115
116info "Kernel $NAME has been installed."