Skip to content

Conversation

@rlmenge
Copy link
Contributor

@rlmenge rlmenge commented Feb 6, 2026

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:

  1. Switch from Fedora's pre-built headers tarball to generating headers from Azure Linux kernel source
  2. Set version to 6.18.5.1 targeting CBL-Mariner rolling-lts/mariner-3
  3. Add build dependencies (make, gcc, perl, rsync)
  4. Generate both native x86_64 and cross-compiled arm64 headers

Produces kernel-headers and kernel-cross-headerssubpackages.

Copilot AI review requested due to automatic review settings February 6, 2026 05:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 22 to 27
# 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>
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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).

Copilot uses AI. Check for mistakes.
Copy link
Member

@reubeno reubeno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


# Build deps (Fedora's spec has none since it uses pre-built headers).
[[components.kernel-headers.overlays]]
type = "spec-search-replace"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the spec-add-tag overlay, e.g.:

[[components.mypackage.overlays]]
type = "spec-add-tag"
description = "Include a description here; it will become visible in some logging"
tag = "BuildRequires"
value = "some-devel-package"

There's an overlays.md file with examples like this, but it's not available on public GitHub yet. I can point you at it offline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the BuildRequires to use spec-add-tag

[[components.kernel-headers.overlays]]
type = "spec-search-replace"
regex = "%global released_kernel 0"
replacement = "%global released_kernel 0\n\n%define mariner_version 3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use %{azurelinux_version} in place of %{mariner_version} while we're at it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the define name


# Version updates: Fedora 6.19 -> Azure Linux 6.18.5.1
[[components.kernel-headers.overlays]]
type = "spec-search-replace"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few options for defining a macro like this. I'd actually recommend something like the following at the top of the file:

[components.kernel-headers.build]
defines = { "kernel_azurelinux_version" = "3" }

That will generate a macro definition without mutating the spec.

And ditto for the other %defines below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the defines method! I still had to use the search and replace for the defines already present in the spec.

" make ARCH=$cross_arch O=usr/include-$cross_arch headers",
"done",
"",
"find usr/include* \\( -name \".*\" -o -name \"Makefile\" \\) -delete",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@rlmenge rlmenge force-pushed the rlmenge/tomls/kernel-kernel-headers-source branch from 8ca1fc3 to 63ad4fd Compare February 10, 2026 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants