-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkernel_install
executable file
·63 lines (50 loc) · 1.26 KB
/
kernel_install
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
#!/bin/sh
set -eu
alias make="make --jobs=$(nproc)"
silent() {
"${@}" >/dev/null 2>/dev/null
}
efibootmgr_add() {
local kernel="${1}"
local label="${2}"
if ! efibootmgr | grep -qE "${label}$"
then
silent efibootmgr -c -l "${kernel}" -L "${label}"
fi
}
boot_mounted=false
if ! mount | grep -q '/boot'
then
mount /boot
boot_mounted=true
fi
make
if grep -q 'CONFIG_MODULES=y' .config
then
make modules_install
fi
install_out="$(make install)"
kernel_ext="$(echo "${install_out}" | cut -d ' ' -f 3)"
kernel_version="$(echo "${kernel_ext}" | cut -d '-' -f 1)"
kernel_tag="$(echo "${kernel_ext}" | cut -d '-' -f 2)"
kernel_revision="$(echo "${kernel_ext}" | cut -d '-' -f 3)"
[ -n "${kernel_revision}" ] && kernel_version="${kernel_version}-${kernel_revision}"
boot_name="Gentoo ${kernel_version}"
[ "${kernel_tag}" != 'gentoo' ] && boot_name="${boot_name} ${kernel_tag}"
efi_ro=false
if mount | grep "^efivarfs" | grep -q "ro"
then
efi_ro=true
efi_mpoint=$(mount | grep "^efivarfs" | cut -d " " -f 3)
mount -o remount,rw efivarfs $efi_mpoint
fi
efibootmgr_add "\\vmlinuz-${kernel_ext}.old" "${boot_name} old"
efibootmgr_add "\\vmlinuz-${kernel_ext}" "${boot_name}"
if ${efi_ro}
then
mount -o remount,ro efivarfs $efi_mpoint
fi
if ${boot_mounted}
then
umount /boot
fi