#!/usr/bin/env bash # inspired by https://github.com/oraoto/archlinux-firecracker/blob/master/scripts/build-arch-kernel.sh set -ex KERNEL_VERSION=v5.11 WD=../out ## Install build tools # pacman -Syu base-devel bc pahole --ignore linux-firmware ## Get kernel source git clone https://github.com/torvalds/linux.git "$WD"/linux git checkout $KERNEL_VERSION ## Get Archlinux kernel config curl -o "$WD"/linux/.config https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux 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" cat kernel-config/config/virtio.config >> "$CONFIG_PATH" cat kernel-config/config/fs.config >> "$CONFIG_PATH" cat kernel-config/config/net.config >> "$CONFIG_PATH" ## Add KVM guest support make kvm_guest.config #make -j$(nproc) # #./scripts/extract-vmlinux ./arch/x86_64/boot/bzImage > "$WD"/vmlinux-$KERNEL_VERSION.bin