Create toml overlay for kernel-headers#15747
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces the kernel-headers component for Azure Linux 4.0, which provides C header files for the Linux kernel userspace interface. The component uses Fedora's kernel-headers spec as a base and applies overlays to adapt it for Azure Linux's kernel source from CBL-Mariner-Linux-Kernel 6.18.5.1.
Changes:
- Creates kernel-headers component using Fedora rawhide spec with overlays to switch from pre-built headers to generating from Azure Linux kernel source
- Updates version from Fedora 6.19-rc8 to Azure Linux 6.18.5.1 targeting rolling-lts/mariner-3
- Implements build process to generate both native and cross-compiled headers (x86_64 ↔ aarch64)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| base/comps/kernel-headers/sources | Adds SHA512 checksum for kernel-6.18.5.1.tar.gz source tarball |
| base/comps/kernel-headers/kernel-headers.spec | Base Fedora kernel-headers spec file (6.19-rc8) that will be modified by overlays |
| base/comps/kernel-headers/kernel-headers.comp.toml | Component configuration with overlays to adapt Fedora spec for Azure Linux: changes source to CBL-Mariner kernel, updates version to 6.18.5.1, adds build dependencies, and replaces install logic to generate native and cross-architecture headers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # This is a tarball with headers from the kernel, which should be created | ||
| # using create_headers_tarball.sh provided in the kernel source package. | ||
| # To create the tarball, you should go into a prepared/patched kernel sources | ||
| # directory, or git kernel source repository, and do eg.: | ||
| # For a RHEL package: (...)/create_headers_tarball.sh -m RHEL_RELEASE | ||
| # For a Fedora package: kernel/scripts/create_headers_tarball.sh -r <release number> |
There was a problem hiding this comment.
These comments describe how to create a pre-built headers tarball using Fedora/RHEL scripts, but the overlays in kernel-headers.comp.toml change Source0 to use the full Azure Linux kernel source instead of a pre-built headers tarball. These comments are now misleading and should be updated or removed to reflect that this component generates headers from the full kernel source during the build process.
| # This is a tarball with headers from the kernel, which should be created | |
| # using create_headers_tarball.sh provided in the kernel source package. | |
| # To create the tarball, you should go into a prepared/patched kernel sources | |
| # directory, or git kernel source repository, and do eg.: | |
| # For a RHEL package: (...)/create_headers_tarball.sh -m RHEL_RELEASE | |
| # For a Fedora package: kernel/scripts/create_headers_tarball.sh -r <release number> | |
| # Source0 is provided by the component configuration and points to the full | |
| # Azure Linux kernel source tree. This package generates the headers from that | |
| # source during the build process; no pre-built headers tarball is required. | |
| # | |
| # The actual Source0 URL or artifact name may be overridden by the build | |
| # overlays (for example, in kernel-headers.comp.toml). |
reubeno
left a comment
There was a problem hiding this comment.
It looks like we're effectively gutting the upstream kernel-headers.spec (i.e., replacing all of %build and %install).
Given that, I could see an argument both ways for whether to overlay the upstream spec, or whether to just fully fork it and make it our own. I'm interested to get your take on it, but have left some comments throughout the .toml file regardless as general suggestions for the current approach.
| [[components.kernel-headers.overlays]] | ||
| type = "spec-search-replace" | ||
| regex = "%global released_kernel 0" | ||
| replacement = "%global released_kernel 0\n\n%define mariner_version 3" |
There was a problem hiding this comment.
Should we use %{azurelinux_version} in place of %{mariner_version} while we're at it?
There was a problem hiding this comment.
Updated the define name
| " make ARCH=$cross_arch O=usr/include-$cross_arch headers", | ||
| "done", | ||
| "", | ||
| "find usr/include* \\( -name \".*\" -o -name \"Makefile\" \\) -delete", |
There was a problem hiding this comment.
It's a toss-up, but you might consider using single-quoted TOML strings for the strings where there's content that would need escaping in double quotes. (And double-quoted strings like you've done above where there would need to be single-quoted content inside 😄 )
| # Install: copy built headers into RPM buildroot, replacing Fedora's copy logic. | ||
| [[components.kernel-headers.overlays]] | ||
| type = "spec-search-replace" | ||
| regex = "# List of architectures we support and want to copy their headers" |
There was a problem hiding this comment.
It looks like this is just at the beginning of the %install section; did I get that right? (The regex replacements run the risk of being brittle in case the text being searched for changes upstream so I consider them a less-preferred option.)
If that's the case, then a spec-prepend-lines overlay could work here? e.g.,
[[components.kernel-headers.overlays]]
type = "spec-prepend-lines"
section = "%install"
lines = [
...
]If you'd prefer not to have the lines chopped up, I think you can use a """-style string within a list. (That may be a readability/maintainability improvement for the other multi-line change above too, come to think of it.)
There was a problem hiding this comment.
Using prepend for both the build and install sections
| "find usr/include* \\( -name \".*\" -o -name \"Makefile\" \\) -delete", | ||
| ] | ||
|
|
||
| # Install: copy built headers into RPM buildroot, replacing Fedora's copy logic. |
There was a problem hiding this comment.
Have we checked to see if the resulting RPM installs roughly the same files + dir structures as the upstream Fedora one, with these changes? Even if we take a different approach for composing it, I'd presume we would want to match the structure of the output.
There was a problem hiding this comment.
Diffs look good! Here are the diffs:
For kernel-headers, found azurelinux includes headers_check.pl because we use make headers but that can be resolved using make headers_install which I have updated the spec to use (this is different from AzL3)
For kernel-cross-headers there are a lot of differences since we support only arm64 for cross-headers. Additionally it looks like Fedora includes some headers which are more relevant for x86
Architecture Fedora AZL
------------------------- -------- --------
arm-linux-gnu 1082 0
arm64-linux-gnu 1082 1053
loongarch-linux-gnu 1082 0
powerpc-linux-gnu 1082 0
riscv-linux-gnu 1082 0
s390-linux-gnu 1082 0
x86-linux-gnu 1082 0
=== arm64-linux-gnu: Only in Fedora (31 files) ===
/usr/arm64-linux-gnu/include/asm/amd_hsmp.h
/usr/arm64-linux-gnu/include/asm/a.out.h
/usr/arm64-linux-gnu/include/asm/boot.h
/usr/arm64-linux-gnu/include/asm/bootparam.h
/usr/arm64-linux-gnu/include/asm/debugreg.h
/usr/arm64-linux-gnu/include/asm/e820.h
/usr/arm64-linux-gnu/include/asm/elf.h
/usr/arm64-linux-gnu/include/asm/hw_breakpoint.h
/usr/arm64-linux-gnu/include/asm/hwcap2.h
/usr/arm64-linux-gnu/include/asm/ist.h
/usr/arm64-linux-gnu/include/asm/kvm_perf.h
/usr/arm64-linux-gnu/include/asm/ldt.h
/usr/arm64-linux-gnu/include/asm/mce.h
/usr/arm64-linux-gnu/include/asm/msr.h
/usr/arm64-linux-gnu/include/asm/mtrr.h
/usr/arm64-linux-gnu/include/asm/posix_types_32.h
/usr/arm64-linux-gnu/include/asm/posix_types_64.h
/usr/arm64-linux-gnu/include/asm/posix_types_x32.h
/usr/arm64-linux-gnu/include/asm/prctl.h
/usr/arm64-linux-gnu/include/asm/processor-flags.h
/usr/arm64-linux-gnu/include/asm/ptrace-abi.h
/usr/arm64-linux-gnu/include/asm/setup_data.h
/usr/arm64-linux-gnu/include/asm/sgx.h
/usr/arm64-linux-gnu/include/asm/sigcontext32.h
/usr/arm64-linux-gnu/include/asm/svm.h
/usr/arm64-linux-gnu/include/asm/unistd_32.h
/usr/arm64-linux-gnu/include/asm/unistd_x32.h
/usr/arm64-linux-gnu/include/asm/vm86.h
/usr/arm64-linux-gnu/include/asm/vmx.h
/usr/arm64-linux-gnu/include/asm/vsyscall.h
/usr/arm64-linux-gnu/include/linux/a.out.h
=== arm64-linux-gnu: Only in Azure Linux (2 files) ===
/usr/arm64-linux-gnu/include/asm/hwcap.h
/usr/arm64-linux-gnu/include/asm/sve_context.h
Switch from 'make headers' to 'make headers_install' with INSTALL_HDR_PATH. headers_install runs the kernel's built-in sanitization which strips internal build scripts and artifacts (e.g. headers_check.pl) that don't belong in the shipped RPM. This also removes the manual 'find ... -delete' cleanup step, since headers_install handles that automatically.
63ad4fd to
c3401e6
Compare
Introduces the kernel-headers component for Azure Linux 4.0, built from the CBL-Mariner-Linux-Kernel 6.18.5.1 source.
Uses the Fedora kernel-headers.spec as a base with overlays to:
Produces
kernel-headersandkernel-cross-headerssubpackages.