Skip to content

Instantly share code, notes, and snippets.

@lmb
Created January 10, 2024 15:51
Show Gist options
  • Save lmb/56ae65a13919a07c5852d93f84c8a972 to your computer and use it in GitHub Desktop.
Save lmb/56ae65a13919a07c5852d93f84c8a972 to your computer and use it in GitHub Desktop.
Build RHEL 8 kernel via rocky linux container
FROM rockylinux:8 AS builder
RUN dnf install -y 'dnf-command(builddep)' 'dnf-command(config-manager)'
RUN dnf config-manager --set-enabled powertools
RUN dnf builddep -y kernel
FROM builder
WORKDIR /tmp
RUN dnf download --source kernel && rpm -ivh kernel*.src.rpm
WORKDIR /root/rpmbuild/SPECS
RUN rpmbuild -bp kernel.spec --with baseonly
RUN ln -s /root/rpmbuild/BUILD/kernel-*/linux-* /tmp/source
WORKDIR /tmp/source
# Emulate InitBuildVars() from kernel.spec
RUN make -s mrproper
# Remove modules
RUN sed -E -e 's/^(CONFIG_[^=]+)=m/# \1 is not set/' configs/kernel-*-$(uname -m)-debug.config > .config
RUN make olddefconfig
# TODO: Apply custom config
RUN make -j 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment