diff --git a/EXTENSIONS.md b/EXTENSIONS.md index f611f34..8ffec12 100644 --- a/EXTENSIONS.md +++ b/EXTENSIONS.md @@ -105,17 +105,23 @@ deployment, retained inputs/history, and preservation of the managed overlay. DKMS packages (including `broadcom-wl-dkms` and `v4l2loopback-dkms`) use the same cumulative request path. D-097 removes the package-name/archive-hash allowlist. An archive supplying `/usr/src//dkms.conf` is a DKMS source input; -the native `dkms` package is the framework. Initial execution scope is the -x86_64 Core `linux` profile without Secure Boot; this is not universal DKMS support. +the native `dkms` package is the framework. Initial execution scope is x86_64 +Archipelago images without Secure Boot; the target kernel is whatever the image +ships (Core `linux`, Desktop `linux-zen`), not a fixed package name. This is not +universal DKMS support. - Resolve `-headers=` against retained sync DBs. Generated transaction targets stay separate from explicit requests. - DKMS source/framework package scriptlets and hooks are admitted to isolated staging without per-package approval. Replace the three native framework hooks with the offline finalizer: native helper can skip a failed build and still return zero. -- DKMS source archives may contribute `/usr/src`; header packages may - contribute kernel build trees and vDSO objects; `linux-headers` may supply its - `/usr/src/linux` link. Non-DKMS unclassified package actions still fail. +- DKMS source archives may contribute `/usr/src`. A header package is recognized + structurally by `usr/lib/modules//build/include/config/kernel.release`, + so `linux-zen-headers` and `linux-lts-headers` need no separate rule; it may + contribute that build tree, vDSO objects and one convenience link below + `usr/src` (for example `usr/src/linux` or `usr/src/linux-zen`) pointing into + the same build tree. A second real source tree is still rejected. Non-DKMS + unclassified package actions still fail. Signatures/checksums and exact snapshot inputs remain mandatory. Configurations are never sourced on the live host during archive inspection. - Offline staging explicitly adds/builds/installs each source for each image kernel, diff --git a/adapters/extensions.sh b/adapters/extensions.sh index d3425ed..bd6a892 100644 --- a/adapters/extensions.sh +++ b/adapters/extensions.sh @@ -86,18 +86,33 @@ for archive in "$generation/inputs/"*.pkg.tar.*; do role=framework elif grep -qE '^(\./)?usr/src/[^/]+/dkms\.conf$' "$listing"; then role=source + elif grep -qE '^(\./)?usr/lib/modules/[^/]+/build/include/config/kernel\.release$' "$listing"; then + # Desktop purposes replace `linux` with another kernel (linux-zen today). + # Recognize headers by the build tree they ship, not by package name or + # by the single `usr/src/linux` link of the stock kernel package. + role=headers + links="$generation/logs/$(basename "$archive").links" + bsdtar -tvf "$archive" | awk '$1 ~ /^l/ && $(NF-1) == "->" { print $(NF-2) "\t" $NF }' > "$links" fi if [[ $role == framework ]]; then dkms_enabled=true; fi while IFS= read -r path; do path=${path#./} case "$path" in .PKGINFO|.BUILDINFO|.MTREE|.INSTALL|''|*/) continue ;; - usr/src/linux) - [[ $package == linux-headers ]] || { echo "Unexpected kernel source link: $package" >&2; exit 1; } ;; usr/src/*) - [[ $role == source ]] || { echo "Source payload lacks a DKMS configuration: $package" >&2; exit 1; } ;; + case $role in + source) ;; + headers) + # Headers may add only convenience links into the matching + # module build tree; a real second source tree stays an error. + target=$(awk -F'\t' -v path="$path" '$1 == path || $1 == "./" path { print $2; exit }' "$links") + [[ $target == ../lib/modules/*/build ]] || { + echo "Headers payload has an unexpected source tree: $package: $path" >&2; exit 1; } + ;; + *) echo "Source payload lacks a DKMS configuration: $package" >&2; exit 1 ;; + esac ;; usr/lib/modules/*/build/*|usr/lib/modules/*/vdso/*.so) - [[ $package == *-headers ]] || { echo "Unexpected kernel build payload: $package" >&2; exit 1; } ;; + [[ $role == headers ]] || { echo "Unexpected kernel build payload: $package" >&2; exit 1; } ;; usr/local/*|usr/lib/modules/*|boot/*|opt/*|var/*|home/*|root/*|srv/*|mnt/*|etc/pacman.d/hooks/*) echo "Package needs a persistence/kernel adapter: $(basename "$archive"): $path" >&2; exit 1 ;; usr/*|etc/*) ;; diff --git a/tests/dkms_inputs.py b/tests/dkms_inputs.py index efe2f65..0c0b9a6 100644 --- a/tests/dkms_inputs.py +++ b/tests/dkms_inputs.py @@ -34,6 +34,11 @@ class Inputs(unittest.TestCase): (policy / file).touch() with tarfile.open(generation / 'inputs/test.pkg.tar.gz', 'w:gz') as archive: for path, content in {'.PKGINFO': 'pkgname = ' + name + '\n', **payload}.items(): + if isinstance(content, tuple): + entry = tarfile.TarInfo(path) + entry.type, entry.linkname = tarfile.SYMTYPE, content[1] + archive.addfile(entry) + continue data = content.encode() entry = tarfile.TarInfo(path) entry.size = len(data) @@ -65,6 +70,22 @@ class Inputs(unittest.TestCase): {'.INSTALL': 'unknown non-DKMS action'}): self.assertNotEqual(self.inspect('some-package', payload).returncode, 0) + def test_alternate_kernel_headers_are_admitted(self): + kernel = '7.3.4-zen2-2-zen' + result = self.inspect('linux-zen-headers', { + f'usr/lib/modules/{kernel}/build/include/config/kernel.release': kernel, + f'usr/lib/modules/{kernel}/build/Makefile': '# build tree\n', + 'usr/src/linux-zen': ('symlink', f'../lib/modules/{kernel}/build')}) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + + def test_headers_cannot_smuggle_source_trees(self): + kernel = '7.3.4-zen2-2-zen' + build = {f'usr/lib/modules/{kernel}/build/include/config/kernel.release': kernel} + for extra in ({'usr/src/vendor/driver.c': 'x'}, + {'usr/src/linux': ('symlink', '/etc')}): + result = self.inspect('linux-zen-headers', {**build, **extra}) + self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) + def test_local_extension_install_keeps_repository_signature_policy(self): text = '[options]\nSigLevel = Required DatabaseOptional\nLocalFileSigLevel = Required\n[core]\nServer = x\n' result = packages.local_file_policy(text)