Collapse the Gentoo kernel scripts into one, and move the install into a gentoo set - #43
Merged
Conversation
gentoo-kernel-upgrade-openrc and -systemd were ~400 lines each and differed on exactly one thing: whether the kernel image in /boot is named vmlinuz-<version> or kernel-<version>. Everything else — the emerge check, eselect, the EFI backup, the initramfs regeneration, the cleanup pass — was duplicated verbatim, which means any fix had to be made twice. Merged them into scripts/gentoo-kernel-upgrade, which detects the naming at runtime: the name the running kernel is installed under first, then whatever else is in /boot, then the init system as a last resort. KERNEL_PREFIX overrides it if the guess is ever wrong. That also removes the interactive "which init system?" prompt from 07-last-touches.sh, which blocked unattended installs on Gentoo.
Installing the kernel-upgrade helper was the one thing 07-last-touches.sh did that wasn't really "last touches" — it fired on every Gentoo box whether I wanted the script there or not, and it's exactly the kind of optional, platform-specific extra the set system exists for. Moved it to config/sets/gentoo/, opt-in via `make picky` like the desktop sets. `os` can only be as specific as `uname -s`, so the set is offered on any Linux and checks for /etc/gentoo-release itself at deploy time, warning and exiting 0 elsewhere — same shape as gnome/kde/xfce checking for their own tooling. Also added config/sets/*/apply.sh to the shellcheck glob, which was missing it: without that the new script would ship unlinted. It caught an unquoted expansion in the kernel-upgrade helper straight away. The other four apply.sh scripts were already clean. README: documented the new set, and filled in `gnome`, which never got an entry when it landed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scripts/gentoo-kernel-upgrade-openrcandscripts/gentoo-kernel-upgrade-systemdwere ~400 lines each and differed on three lines — whether the kernel image in/bootis namedvmlinuz-<version>orkernel-<version>. Everything else was duplicated verbatim, so any fix had to be made twice.Collapsing them
One
scripts/gentoo-kernel-upgradethat detects the naming at runtime, cheapest reliable signal first:installkernelactually used./boot(the running kernel may already have been cleaned up).KERNEL_PREFIX=kerneloverrides it if the guess is ever wrong.That also kills the interactive "which init system? [1]/2" prompt in
07-last-touches.sh, which blocked unattended installs on Gentoo.The gentoo set
Installing that helper was the one thing
07-last-touches.shdid that isn't really a last touch — it fired on every Gentoo box whether the script was wanted or not. It'sconfig/sets/gentoo/now, opt-in viamake pickylike the desktop sets.oscan only be as specific asuname -s, so the set is offered on any Linux and checks/etc/gentoo-releaseitself at deploy time, warning and exiting 0 elsewhere — the same shape as gnome/kde/xfce checking for their own tooling.Also here
config/sets/*/apply.shadded to the shellcheck glob. Without it the new script would ship unlinted. It immediately caught an unquoted expansion in the kernel-upgrade helper; the other fourapply.shscripts were already clean.gnomedocumented. It never got an entry when it landed — missing from both the layout tree and the set list.Testing
bash -nunder/bin/bash3.2 on macOS./boot) — all pass, under bash 5 and bash 3.2.gentoo/stage3image: set deploys, helper lands in/usr/bin, runs and reports the naming it detected.ubuntu:24.04:gentooshows in the picker, skips with a warning off-Gentoo, andbasicstill deploys alongside it.docker buildx build -f tests/Dockerfile-alpine .green.Not fixed, noticed while in here
cleanup_old_versions()reads$current_versionout ofmain's scope via bash's dynamic scoping rather than taking it as an argument. It works, and it predates this change, so I left it alone.