52 lines
1.9 KiB
Bash
Executable File
52 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# inspired by https://github.com/oraoto/archlinux-firecracker/blob/master/scripts/build-arch-kernel.sh
|
|
|
|
set -ex
|
|
|
|
KERNEL_VERSION=$1
|
|
WD=../out
|
|
NPROC=8
|
|
|
|
## Install build tools
|
|
# pacman -Syu base-devel bc pahole --ignore linux-firmware
|
|
# disabling CONFIG_DEBUG_INFO_BTF so no pahole required
|
|
|
|
sudo rm -rf "$WD"/linux
|
|
## Get kernel source
|
|
git clone --depth 1 --branch v$KERNEL_VERSION https://github.com/torvalds/linux.git "$WD"/linux
|
|
|
|
## Get Archlinux kernel config
|
|
curl -o "$WD"/linux/.config https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/main/config?ref_type=heads
|
|
|
|
CONFIG_PATH="$WD"/linux/.config
|
|
|
|
## Disable modules
|
|
sed 's/\(.*\)=m/#\1 is not set/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)MOUSE\(.*\)=y/\1MOUSE\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)USB\(.*\)=y/\1USB\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)TOUCHSCREEN\(.*\)=y/\1TOUCHSCREEN\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)HID\(.*\)=y/\1HID\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)GPU\(.*\)=y/\1GPU\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)GPIO\(.*\)=y/\1GPIO\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)NVDIMM\(.*\)=y/\1NVDIMM\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)MFD\(.*\)=y/\1MFD\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)XEN\(.*\)=y/\1XEN\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)VIDEO\(.*\)=y/\1VIDEO\2=n/g' -i "$CONFIG_PATH"
|
|
# sed 's/\(.*\)PCI\(.*\)=y/\1PCI\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)WLAN\(.*\)=y/\1WLAN\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)DRM\(.*\)=y/\1DRM\2=n/g' -i "$CONFIG_PATH"
|
|
sed 's/\(.*\)BTF\(.*\)=y/\1BTF\2=n/g' -i "$CONFIG_PATH"
|
|
|
|
cat kernel-config/virtio.config >> "$CONFIG_PATH"
|
|
cat kernel-config/fs.config >> "$CONFIG_PATH"
|
|
cat kernel-config/net.config >> "$CONFIG_PATH"
|
|
|
|
## Add KVM guest support
|
|
make -C "$WD"/linux/ kvm_guest.config
|
|
|
|
#make -C "$WD"/linux/ -j$NPROC EXTRA_CFLAGS=-Wno-error=use-after-free
|
|
make -C "$WD"/linux/ -j$NPROC WERROR=0
|
|
|
|
cp "$WD"/linux/vmlinux "$WD"/vmlinux-$KERNEL_VERSION
|