-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade_kernel_gentoo.sh
48 lines (40 loc) · 1.03 KB
/
upgrade_kernel_gentoo.sh
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
#!/usr/bin/env bash
## Upgrade gentoo kernel
# The first and only argument must be the folder name of the new kernel.
# Stop script when an error occurs
set -o errexit
set -o pipefail
set -o nounset
# For debugging purposes
set -o xtrace
readonly kernel_path='/usr/src/'
_usage () {
local script_name="$0"
echo "Usage: $0 <newkernelfolder>"
}
_main () {
echo "Backing up old kernel..."
cd "${kernel_path}/linux/"
cp .config ~/kernel-config-"$(uname -r)"
echo "Copying old configuration..."
cp /usr/src/linux/.config /tmp/.config
echo "Setting new kernel as default..."
ln -sf /usr/src/"$1" /usr/src/linux
cp /tmp/.config /usr/src/linux/
eselect kernel set 2
cd /usr/src/linux/
echo "Building..."
make -j4 olddefconfig
make -j4 modules_prepare
emerge --ask @module-rebuild
make -j4
make install
make -j4 modules_install
echo "Please, update your EFI entry: cp /boot/vmlinuz-*-gentoo /boot/efi/boot/bootx64.efi"
}
if [[ $# -eq 1 ]]
then
_main $1
else
_usage
fi