Last active
June 24, 2023 23:31
-
-
Save rgov/68e4a82a61beac26987ce8a674f099d0 to your computer and use it in GitHub Desktop.
Building a patched Ubuntu kernel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
LINUX_META_PKG='linux-meta' | |
LINUX_PKG='linux-image-unsigned-"$KERNEL_ABI_VERSION"-generic' | |
# Enable apt source repositories | |
sed -i '/^deb /{n; s/^# deb-src/deb-src/;}' /etc/apt/sources.list | |
apt update | |
apt install -y dpkg-dev | |
# Download the linux-meta sources | |
apt source "$LINUX_META_PKG" | |
mv "$LINUX_META_PKG"-[0123456789]* linux-meta | |
# Determine the kernel ABI version referenced by the package | |
pushd linux-meta | |
KERNEL_ABI_VERSION=$(\ | |
dpkg-parsechangelog -SVersion | awk -F. '{print $1"."$2"."$3"-"$4}') | |
popd | |
# Perform environment variable expansion on LINUX_PKG | |
LINUX_PKG=$(eval "echo ${LINUX_PKG}") | |
# Download the corresponding unsigned kernel sources | |
apt source "$LINUX_PKG" | |
mv "$LINUX_PKG"-[0123456789]* linux | |
# Install dependencies for these two packages | |
apt build-dep -y "$LINUX_META_PKG" "$LINUX_PKG" | |
# Build the packages | |
for PKG in linux linux-meta; do | |
pushd "$PKG" | |
dpkg-buildpackage -rfakeroot -uc -b | |
popd | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the Raspberry Pi kernel it should be: