-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathbuild_and_install_kernel.sh
executable file
·76 lines (64 loc) · 2.34 KB
/
build_and_install_kernel.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
set -eux -o pipefail
# Enable source
printf "Installing dependencies...\n"
sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update
# Install build dependencies
sudo apt-get build-dep linux linux-image-$(uname -r) -y || true
sudo apt-get install -y libncurses-dev flex bison openssl libssl-dev dkms \
libelf-dev libudev-dev libpci-dev libiberty-dev \
autoconf fakeroot bc cpio
# Install BTF dependency
wget -O /tmp/dwarves_1.17-1_amd64.deb http://old-releases.ubuntu.com/ubuntu/pool/universe/d/dwarves-dfsg/dwarves_1.17-1_amd64.deb
sudo dpkg -i /tmp/dwarves_1.17-1_amd64.deb
SCRIPT_PATH=`realpath $0`
BASE_DIR=`dirname $SCRIPT_PATH`
LINUX_PATH="$BASE_DIR/linux"
pushd $LINUX_PATH
if [ ! -e "Makefile" ]; then
git submodule init
git submodule update
fi
# Cleanup the previous build
rm -f ../linux-* 2> /dev/null
make distclean
# Configure kernel
printf "Configuring kernel...\n"
(yes "" || true) | make localmodconfig
./scripts/config -e CONFIG_DEBUG_INFO
./scripts/config -e CONFIG_BPF_SYSCALL
./scripts/config -e CONFIG_DEBUG_INFO_BTF
./scripts/config -e CONFIG_UIO
./scripts/config -e CONFIG_UIO_PCI_GENERIC
./scripts/config -e CONFIG_EXT4_FS
make olddefconfig
if [ -z "$(cat .config | grep CONFIG_DEBUG_INFO_BTF)" ]; then
printf "Cannot find CONFIG_DEBUG_INFO_BTF in .config file. Please enable it manually by 'make nconfig'.\n"
exit 1
fi
if [ -z "$(cat .config | grep CONFIG_UIO_PCI_GENERIC)" ]; then
printf "Cannot find CONFIG_UIO_PCI_GENERIC in .config file. Please enable it manually by 'make nconfig'.\n"
exit 1
fi
if [ -z "$(cat .config | grep CONFIG_EXT4_FS)" ]; then
printf "Cannot find CONFIG_EXT4_FS in .config file. Please enable it manually by 'make nconfig'.\n"
exit 1
fi
# Compile kernel
printf "Compiling kernel...\n"
make deb-pkg -j8
popd
# Install kernel
printf "Installing kernel...\n"
pushd $BASE_DIR
sudo dpkg -i linux-*.deb
popd
if [ -z "$(awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg | grep -m 1 'Ubuntu, with Linux 5.12.0-xrp+')" ]; then
printf "Cannot find XRP kernel. Please install the kernel manually.\n"
exit 1
fi
printf "XRP kernel is installed. To boot into XRP kernel, please run:\n"
printf " sudo grub-reboot \"Advanced options for Ubuntu>Ubuntu, with Linux 5.12.0-xrp+\"\n"
printf " sudo reboot\n"