← Back to issue list

feat: kernel|initrd plugins: extend and improve behavior

View original Github issue

Metadata

Project
snapcraft
Number
#6116
Type
pull request
State
merged
Author
dilyn-corner
Labels
Created
Updated
Closed

Current evaluation

Merged after review and testing. Extended kernel and initrd plugins by migrating fetch logic, adding Ubuntu release and binary package options, and supporting extra kernel tools. Removed ZFS/DKMS support in favor of documentation. Supersedes #6102.

Suggested action:

No scores available.

Issue body

These changes update the feature branch kernel and initrd plugins in some key ways. The initrd plugin changes are largely isolated to migrating some of the root tarball fetch logic into the plugin more properly via a `@get_pull_commands`. For the legacy plugin, the prior behavior has been left in tact. The logic in the build script and some general formatting and refactoring have occurred to accommodate these changes. Additionally, a "bug" (behavioral glitch, more like) was resolved by adding an `--allow-downgrades` flag to an `apt install` command. Otherwise, the behavior is largely the same. The spread tests have been updated to leverage some new kernel plugin options, gaining some tests of new kernel options for free. The kernel plugin changes are a bit more substantive. Firstly, like the initrd plugin, the kernel source fetching logic has moved, in part, to the plugin itself (with analogous updates to the build script logic as a result). Furthermore, some options from the ubuntu-kernel plugin have been integrated into this plugin. Specifically, the ability to build a snap from a deb, to specify the Ubuntu release of a kernel tree to build from, as well as the ability to build several kernel tools (instead of just perf). Enabling ZFS support was removed, for what I think are good reasons. Those reasons being... DKMS support "exists" in the ubuntu-kernel plugin insofar as the plugin builds a deb and leverages the existing kernel build system to build DKMS packages. Attempts were made at emulating this logic within the kernel plugin, but interacting with DKMS felt far too cumbersome (not to mention incredibly fragile) in this setting; DKMS requires a lot of facts to be true of the build environment, and it proved onerous to make the logic work in a consistent fashion. DKMS is not intended to be used in this fashion anyways; DKMS is intended to be run on runtime targets after a kernel has been updated. If you are building the module at kernel build time (ostensibly what the kernel plugin purports to do), then you can merely build the module in the relevant fashion alongside the kernel in the traditional way; no need to bother with DKMS. The enable-zfs kernel plugin option demonstrated this fact -- enabling this option effectively ran the compilation commands the DKMS tooling would run, albeit in a far more opinionated fashion than DKMS would. In lieu of this support, documentation has been created (along with some examples) for how to perform something like an out-of-tree kernel module build within a snapcraft.yaml for kernel snaps. If DKMS is desired, its usage can be spoofed by adding some relevant part and creating the correct file hierarchies within the build environment. As such, building a kernel snap with ZFS support has been removed; it was too opinionated and prescriptive for what the true intention of the flag was, and to make it more flexible would force the kernel plugin to lose its identity. The ability to build additional kernel tools (bpftool, perf, cpupower) have been added. Most critically, the legacy implementations of the plugins have been removed due to the addition of a different kernel plugin (one which many of us are used to) being merged at some point; the implementation in this PR would probably break many existing users of this new plugin, and as such it has been reverted :) Things to resolve before merging: - [x] cross building when using certain options (`kernel-use-binary-package` for sure) fails in some cases due to RISC-V kernel debs having *dumb names*. The logic in the script could be improved to resolve this issue, or we can simply make the build fail with an error (checked by the plugin rather than the script). - [x] Builds haven't been tested on actual hardware. This is my next move. - [x] commits need to be cleaned up to resolve some merge issues ETA: docs-related tests failing are probably because of something unrelated? The docs tests ran fine (locally) for me previously, I suspect something has happened to e.g. Frame docs because of the RTD move/reorg. cc @stewarthore @kubiko @laurenbrock @jicheu Supercedes #6102 --- - [x] I've followed the [contribution guidelines](https://github.com/canonical/snapcraft/blob/main/CONTRIBUTING.md). - [x] I've signed the [CLA](http://www.ubuntu.com/legal/contributors/). - [x] I've successfully run `make lint && make test`. - [x] I've added or updated any relevant documentation. - [ ] I've updated the relevant release notes.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged after review and testing. Extended kernel and initrd plugins by migrating fetch logic, adding Ubuntu release and binary package options, and supporting extra kernel tools. Removed ZFS/DKMS support in favor of documentation. Supersedes #6102.
qwen3.6-35b-a3b-mtp-q6 Merged. Extended kernel and initrd plugins by migrating fetch logic, adding Ubuntu kernel options, and enabling additional tool builds. Removed ZFS/DKMS support, cleaned legacy code, and fixed cross-build issues. Validated via hardware testing.
qwen3.6-35b-a3b-mtp-q6 Merged. Extended kernel and initrd plugins with improved fetch logic, Ubuntu release and binary package options, and additional kernel tool support. Removed legacy code and ZFS/DKMS support. Validated via tests and hardware builds.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#6102 feat: kernel|initrd plugins: extend and improve behavior snapcraft closed Superseded by PR #6110. The changes were reverted to prevent conflicts with a newly merged kernel plugin that would break existing users. The author closed this PR and redirected development to the replacement.
83%
#6254 feat(kernel,initrd): extend plugins with new options, stabilize snapcraft merged Merged after approval. Extended the kernel plugin with new options, stabilized the initrd plugin, improved documentation, and added tests. Resolved a temporary Resolute tarball naming divergence. Core CI checks passed.
81%
#5814 feat(plugins): add kernel and initrd plugins snapcraft merged Merged into a feature branch after simplifying kernel and initrd plugin logic and addressing review feedback. Unrelated spread test failures prompted a temporary merge to prevent staleness, with full integration pending upstream fixes.
80%
#6284 feat: merge feature/kernel initrd plugin into main snapcraft merged Merged into main following two reviewer approvals. Integrates a feature branch adding kernel and initrd plugins for base: core22 and higher. The change spans 32 files, adding 8281 lines and removing 6257.
80%
#6255 Feature/kernel initrd plugin merge snapcraft merged Merged after resolving conflicts and aligning with HEAD. Integrates kernel initrd plugin support, requires PR #6254, approved by two reviewers, and passed CI checks.
74%
#463 Kernel plugin: Support lzma/xz-compressed initrd. snapcraft merged Merged to add lzma/xz-compressed initrd support to the kernel plugin. Replaces the file command with the magic library and includes tests. Resolves Launchpad bug 1569337. Approved with minor concerns and merged despite six unresolved review comments.
72%
#4302 plugins: kernel: split kernel plugin into kernel and initrd plugins snapcraft closed Splitting the kernel plugin into separate kernel and initrd components was closed as superseded by PR #5814. Review discussions addressed cross-compilation and LXD setup, but the changes were ultimately replaced by a newer implementation.
72%
#476 kernel plugin: iterate over modules to add to initrd snapcraft merged Merged updates to the kernel plugin that iterate over modules for initrd inclusion. Approved by @kyrofa following successful tests. Resolves LP #1572118 with 36 additions and 6 deletions across two files.
70%