This repository has been archived by the owner on Apr 17, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathupdatekernel.sh
61 lines (49 loc) · 1.93 KB
/
updatekernel.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
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
source utils/functions.sh
source utils/extract.sh
export MNT=/mnt
[[ -n "$1" ]] && { export DIR=$1; }
# Ask user which USB Device they would like to use
printq "Which USB Drive or SD Card would you like to use (e.g. /dev/sda)?"
lsblk -o name,model,tran | grep --color=never "usb"
read USB
printq "Ok, using $USB to update the kernel and its modules"
# Mount the USB
sudo mount ${USB}2 /mnt
cd ~/linux-build || { mkdir ~/linux-build; cd ~/linux-build; }
# Set up the kernel.flags depending on the UUID
export USB_ROOTFS=$(sudo blkid -o value -s PARTUUID ${USB}2)
bash <(curl -s https://raw.githubusercontent.com/cb-linux/breath/main/kernel.flags.sh) > kernel.flags
# Download kernel and modules
if [[ -n "$DIR" ]]; then
echo "Files supplied"
cp ${DIR}/bzImage.alt bzImage
cp ${DIR}/modules.alt.tar.xz modules.tar.xz
elif [[ $VERSION == "ALT" ]]; then
sudo rm -rf bzImage* modules*
wget https://github.com/cb-linux/breath/releases/latest/download/bzImage.alt -q --show-progress
ln -s bzImage.alt bzImage
wget https://github.com/cb-linux/breath/releases/latest/download/modules.alt.tar.xz -q --show-progress
ln -s modules.alt.tar.xz modules.tar.xz
else
wget https://github.com/cb-linux/breath/releases/latest/download/bzImage -q --show-progress
wget https://github.com/cb-linux/breath/releases/latest/download/modules.tar.xz -q --show-progress
fi
# Sign the kernel
# After this, the kernel can no longer be booted on non-depthcharge devices
futility vbutil_kernel \
--arch x86_64 --version 1 \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--bootloader kernel.flags \
--config kernel.flags \
--vmlinuz bzImage \
--pack bzImage.signed
# Flash kernel
sudo dd if=bzImage.signed of=${USB}1
# Extract modules
sudo rm -rf ~/linux-build/modules/lib/modules/*
extractModules
# Write Storage
echo "Writing storage..."
sync