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