Skip to content

test-kernel: run an upstream PR's kernel beside linux-aurora, once - #5

Merged
CoreyH merged 2 commits into
mainfrom
tools/test-kernel
Oct 29, 2026
Merged

CoreyH merged 2 commits into
mainfrom
tools/test-kernel

Conversation

@CoreyH

@CoreyH CoreyH commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Why

We've committed to testing upstream aurora work on this MacBook. The first one: omacom/linux-aurora #274 asks for "an M1/M2 suspend for patch 1", and its CI built a ready package (linux-aurora 7.2.11.aurora10-1.382, kernel release 7.2.11-10-1.382-ARCH).

Installing that with pacman would replace the regular kernel and fire the m1n1 hook, which rebuilds boot.bin with the package's device trees. test-kernel installs it beside the regular kernel instead and boots it once.

What

test-kernel install <pkg> <name> | boot <name> | remove <name> | list (run as root):

  • Modules go to /usr/lib/modules/<release>, refused if that release exists, so the installed linux-aurora can't be overwritten.
    • The package's pkgbase is left out. mkinitcpio's pacman hook treats every module tree whose pkgbase is linux-aurora as linux-aurora, and could copy the test kernel over /boot/vmlinuz-linux-aurora.
    • Its dtbs are left out: boot.bin takes linux-aurora's (/etc/default/update-m1n1). For #274's build, t6000-j314s.dtb is byte-identical to the installed one anyway.
  • The kernel and initramfs go to /boot/aurora-test/<name>/, outside the names GRUB's 10_linux scans (/boot/vmlinuz-*, vmlinux-*, kernel-*, Image). So the only menu entry is the one from /etc/grub.d/43_aurora_test_<name>. It copies the regular entry's command line and is never the default. Install first checks that the ~500 MB vfat /boot has room.
  • grub.cfg is replaced only if the regenerated one differs from the current one by that entry's section alone. Otherwise it's left untouched and the difference shown. The new config is staged beside it (grub.cfg.test-kernel.new), the current one is backed up (grub.cfg.test-kernel.bak), and then the staged one is synced and renamed into place. Every step is checked, so a failed write leaves the live config intact.
  • boot uses grub-reboot, so only the next restart takes the test kernel and every later one gets the regular kernel, including after a hard power-off. remove refuses while the test kernel is running, clears a pending next_entry, and never deletes a module tree a package owns.

Tested (non-root parts)

  • Refuses to run unprivileged.

  • Release detection on #274's package gives 7.2.11-10-1.382-ARCH, with a clean exit under pipefail (an earlier | head -1 was dropped for that reason).

  • The command line copied from the live grub.cfg matches the regular entry.

  • without_section comparison on copies of the live grub.cfg: a change only in the test section is accepted, and an extra change elsewhere (timeout) is refused.

  • Failure injection on the real regen_grub (throwaway files): a partial write with an error, an extra change, and a failed rename each return 1 with the live config byte-identical. A section-only change replaces it.

Not run yet: an actual install (root), grub-mkconfig, or a boot. That happens after review and merge.

After merging

pkexec bash install.sh. Then: pkexec test-kernel install <#274 package> pr274, and when ready pkexec test-kernel boot pr274 and restart.

🤖 Generated with Claude Code

…ot it once

For testing upstream PRs on this machine, starting with omacom/linux-aurora
#274's CI build (patch 1 on an M1). test-kernel install/boot/remove/list:
- modules into /usr/lib/modules/<release>, refused if it exists; without the
  package's pkgbase (mkinitcpio's hook would treat the tree as linux-aurora
  and could copy it over /boot/vmlinuz-linux-aurora) and without its dtbs
  (boot.bin takes linux-aurora's);
- /boot/vmlinuz-aurora-<name> and initramfs-aurora-<name>.img, and a GRUB
  entry from /etc/grub.d/43_aurora_test_<name>, never the default;
- grub.cfg is rewritten only if the regenerated one differs by that entry's
  section alone, else left as it is with the difference shown;
- boot uses grub-reboot (one restart only); remove refuses while running it
  and never deletes a module tree a package owns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

GRUB auto-discovery makes installation reject its own kernel, and a failed config write can silently damage the regular boot menu. Both issues need addressing before this is used on the laptop.

Reviewed changes Reviewed all four changed files with Bash syntax checks, ShellCheck, and isolated GRUB-regeneration tests; no live installation or boot was performed.

  • Side-by-side installation: Adds named kernel installations with separate modules, kernel images, and initramfs files, excluding package metadata and device trees.
  • Boot lifecycle: Generates custom GRUB entries, restricts config changes to one section, schedules one-shot boots, and removes kernels with running-release and package-ownership checks.
  • Tool integration: Installs and uninstalls the helper and documents it in the repository layout.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

Comment thread test-kernel Resolved
Comment thread test-kernel Resolved
…safely

Review on #5:
- GRUB's 10_linux scans /boot/vmlinuz-* (and vmlinux-*, kernel-*, Image) on
  aarch64, so /boot/vmlinuz-aurora-<name> got a second, automatic entry and
  the section-only check rejected the tool's own install. Images now live in
  /boot/aurora-test/<name>/{vmlinuz,initramfs.img}, which nothing scans.
- regen_grub runs in conditionals, where set -e doesn't apply, and copied
  straight over the live grub.cfg. Every step is now checked: grub-mkconfig
  writes a staged grub.cfg.test-kernel.new (and checks it itself), the
  current one is backed up, and the staged one is synced and renamed into
  place; any failure returns 1 with the live config untouched.
- Install checks /boot (vfat, ~500 MB) has room for the kernel, an initramfs
  the size of the regular one and 32 MiB, before writing anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes Re-reviewed 0aa09a7 against the previous review at 1ded704, focusing on the GRUB safety fixes and new space check.

  • Moved test images: Placed kernels and initramfs files under /boot/aurora-test/<name>/, outside standard GRUB discovery paths, with matching menu and cleanup paths.
  • Staged GRUB updates: Replaced direct overwrites with checked generation, backup, sync, and rename operations that preserve the live config on failure.
  • Added capacity preflight: Checked /boot free space against the kernel size, regular initramfs size, and a 32 MiB margin before installation writes.

Bash syntax checks, ShellCheck, and eight isolated GRUB-regeneration tests passed, including injected generation, backup, sync, and rename failures. No live installation or boot was performed.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@CoreyH
CoreyH merged commit a5e5cd7 into main Oct 29, 2026
1 check passed
@CoreyH
CoreyH deleted the tools/test-kernel branch October 29, 2026 15:57
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.

1 participant