omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

ptl-kernel.sh never removes the stock kernel: `pacman -Rdd linux linux-headers` aborts when linux-headers isn't installed, and `|| true` hides it

Open Faxulous opened this issue 2 months ago • 2 comments

System details

Dell XPS 16 DA16260, Intel Panther Lake (Core Ultra 300, Arc B390, no discrete GPU), Omarchy 4.0.0.alpha, linux-ptl 7.1.8.arch1-2 and stock linux 7.1.9.arch1-2 both installed

What's wrong?

install/hardware/intel/ptl-kernel.sh at quattro HEAD is byte-identical to what shipped here, and its stock-kernel removal has never removed anything.

Reproduction

No XPS or root needed — --print is a dry run:

$ pacman -Rdd --print linux nosuchpkg >/dev/null; echo $?
error: target not found: nosuchpkg
1

$ pacman -Rdd --print linux >/dev/null; echo $?
0

pacman -R aborts the entire transaction when any one target is not installed. So in:

pacman -Rdd --noconfirm linux linux-headers || true

if linux-headers is absent, neither package is removed, and || true swallows the exit 1.

Why linux-headers is absent

It is not part of the base install — omarchy-base.packages has no linux* entries, and omarchy-other.packages is a mirror-availability manifest for the ISO builder, not an install list. It arrives only as a hard dependency of intel-ipu7-camera, which all.sh deliberately runs after this script ("before anything pulls DKMS modules in"). On this machine pacman.log records it being installed exactly once, ever, one second too late:

1320: [2026-08-28T06:30:00+0100] [PACMAN] Running 'pacman -Rdd --noconfirm linux linux-headers'
1321: [2026-08-28T06:30:00+0100] [PACMAN] Running 'pacman -S --noconfirm --needed intel-ipu7-camera'
1325: [2026-08-28T06:30:01+0100] [ALPM] installed linux-headers (7.1.8.arch1-3)

grep -c 'removed linux' /var/log/pacman.log → 0. The one path that gets linux-headers in early is nvidia.sh, which runs before this script but only on NVIDIA hardware; this machine is Intel Arc only.

/var/log/omarchy-install.log:3153:

error: target not found: linux-headers
WARNING: stock linux kernel still installed alongside linux-ptl:
Required By     : None
[2026-08-28 06:30:00] Completed: /usr/share/omarchy/install/hardware/intel/ptl-kernel.sh

run_logged logs Completed: only on exit 0, so the install records this as a success.

Worth noting: a8977c44 dropped the old 2>/dev/null from this line and added the WARNING guard, which is why the real error is visible at all. The guard's diagnosis points elsewhere though — pacman -Qi linux reports Required By : None and pactree -r linux -d1 shows no reverse dependencies. Nothing dragged the stock kernel back; it was never removed.

Cost

Stock linux 7.1.9.arch1-2 is still installed, limine-mkinitcpio builds omarchy_linux.efi alongside omarchy_linux-ptl.efi, and dkms status shows ipu7-drivers, vision-drivers and v4l2loopback each built twice — the duplicate DKMS work the all.sh ordering comment was added to avoid. The second boot entry is masked here by the BOOT_ORDER="linux-ptl*, …" drop-in the same script writes.

Suggested fix (untested — I have not run this, only the --print dry runs above)

for pkg in linux linux-headers; do
  pacman -Qq "$pkg" &>/dev/null || continue
  pacman -Rdd --noconfirm "$pkg" || echo "WARNING: could not remove $pkg"
done

Two things worth knowing before touching this line:

  • Don't just delete || true. run_logged sources these scripts under bash -eE, so a bare non-zero exit here would skip the BOOT_ORDER drop-in written further down and put the stock entry back in the menu. The failure needs to stay non-fatal.
  • >&2 on the WARNING won't help. run_logged redirects the script's stdout and stderr into the same log file unless OMARCHY_LOG_TO_STDOUT=1, so stderr is no more visible than stdout during a normal install.

Also: linux-headers returns a second later on camera-equipped machines regardless, since intel-ipu7-camera depends on it. Removing it here is undone either way — the aborted transaction is the actual bug.

Trade-off this exposes

Since a8977c44 the removal has been a no-op on every affected install, so making it work is a real behaviour change: XPS Panther Lake machines would lose their fallback kernel. On this machine keeping stock linux has been useful as a recovery path and A/B kernel. That's a call for you rather than something I'd assume — but either way the current code shouldn't report success while doing nothing.

Possibly related

Open PR #8829 widens the condition to all Intel Panther Lake systems, keeps this removal line unchanged, and moves the BOOT_ORDER drop-in behind a new XPS-only guard. If it merges before this is fixed, non-XPS PTL machines would get the failed removal without the drop-in that currently hides the second boot entry.

I searched the tracker for ptl-kernel, linux-ptl, pacman -Rdd, target not found linux-headers, stock kernel, two kernels boot menu and similar and didn't find this reported, but it's a large tracker and search is keyword-based, so apologies if I missed an existing issue.

Faxulous avatar Sep 04 '26 11:09 Faxulous

Confirmed. The mechanism reproduces on a clean Omarchy 4.0.0.alpha VM, dry runs only — nothing was removed:

$ pacman -Qq linux-headers &>/dev/null && echo YES || echo NO
NO
$ sudo pacman -Rdd --print linux linux-headers; echo $?
error: target not found: linux-headers
1
$ sudo pacman -Rdd --print linux; echo $?
linux-7.1.9.arch1-2
0

A fresh install carries linux and no linux-headers (only linux-api-headers, a different package), pacman aborts the whole remove transaction on the missing target, and || true at install/hardware/intel/ptl-kernel.sh:8 swallows the exit 1 so run_logged (install/helpers/logging.sh:70) records Completed:. Your reading is right in every particular.

It is also a regression with a commit behind it. ced028f8 ("Don't fail if headers haven't been installed", 2026-04-22) already fixed this, with the loop you propose:

for pkg in linux linux-headers; do
  sudo pacman -Rdd --noconfirm "$pkg" 2>/dev/null || true
done

d12d449b ("install: split and harden hardware config scripts", 2026-05-24) collapsed it back to the single multi-target call, as part of a 22-file sweep whose subject was dropping the now-redundant sudo from install scripts. The removal worked between those two dates and has not since. a8977c44 only dropped the 2>/dev/null, which is why the error is visible in the log at all.

Three things found while checking, worth having before the line is touched:

  • The line is a no-op on a first install and destructive on a rerun. bin/omarchy-apply-hardware:75 sources install/hardware/all.sh, and its own help text says it can be rerun. By then linux-headers is installed — intel-ipu7-camera depends on it, as you note — so both targets resolve, the removal succeeds, and -Rdd skips the dependency check (verified: pacman -Rns --print linux-api-headers exits 1 on its reverse dependency, pacman -Rdd --print exits 0). Nothing puts it back, because install/hardware/intel/ipu7-camera.sh calls omarchy-pkg-add, which is a no-op once the package is registered.
  • Both header packages already provide LINUX-HEADERS. pacman -Si linux-headers linux-ptl-headers shows Provides : LINUX-HEADERS on each. If intel-ipu7-camera depended on the virtual name rather than on linux-headers exactly, linux-ptl-headers would satisfy it, the stock headers would have no reverse dependency left, and the removal would not need -Rdd at all. That change belongs in omarchy-pkgs rather than here.
  • The ordering against the bootloader is safe, but not unconditionally. omarchy-pkg-add linux-ptl linux-ptl-headers runs first and exits 1 on failure, which under run_logged's bash -eE aborts the script before line 8, and the BOOT_ORDER drop-in is written last — so the stock kernel is never removed before its replacement is installed, and no boot entry is left pointing at a kernel that is gone. What that does not guarantee is that the replacement is bootable: limine-mkinitcpio-hook 1.37.1 runs process_kernel "$pkgbase_file" || true (/usr/share/libalpm/scripts/limine-mkinitcpio-install:265), so a failed UKI build for linux-ptl leaves the package registered and the transaction green, and the next line then removes the stock kernel. Narrow, but unguarded.

No fix is being filed from here. Making the removal work changes which kernels an XPS Panther Lake machine boots with, and the fallback-kernel trade-off you raise is the maintainer's to answer rather than something to restore by inertia. Two open PRs also touch this file: #8829, which you found, and #7321, which adds test/shell.d/ptl-kernel-test.sh asserting the current pacman -Rdd --noconfirm linux linux-headers argv against a stubbed pacman — so a fix has to land with those rather than beside them.

On the two siblings: #10155 and #10048 do not share a root cause with this one. #10155 is upstream semantics moving under a setting that is still written (ac66a73be03a inverted the check so only fred=off is read). #10048 is an architecture assumption in bin/omarchy-update-restart:14, where kernel_updated starts true and is only cleared by a /usr/lib/modules/*/vmlinuz that linux-aarch64 never ships. What the three share is shape rather than cause: a step whose effect nothing verifies, defaulting to the wrong answer once its assumption stops holding.

Reviewed twice — by me, and independently by Codex at xhigh reasoning, which contributed the LINUX-HEADERS virtual-provides route and the limine-mkinitcpio-hook failure-swallowing point above. Codex did not find the d12d449b regression, and its claim that a per-package -Rdd loop would do the same damage on a first install was rejected: on the reported path linux-headers is not installed yet, so the loop skips it and only linux is removed.

omarchybot avatar Sep 04 '26 12:09 omarchybot

Rechecked against current quattro and the v4.0.4 release. The code this issue is about no longer exists, so there is nothing left to fix here.

  • install/hardware/intel/ptl-kernel.sh, including the pacman -Rdd --noconfirm linux linux-headers || true line, was deleted by #11845 ("Migrate to linux-omarchy except on T2 Macs", ec73ba5d0 on the release line, ff85faf8d on quattro). The file is still in v4.0.0 through v4.0.3, and v4.0.4 is the first release without it.
  • Nothing else in install/, bin/, migrations/ or default/ on quattro removes the stock kernel or linux-headers. The generic removal helper bin/omarchy-pkg-drop only passes pacman the targets that are actually installed, so it cannot hit the abort-on-missing-target problem described here.
  • The trade-off you raised has been settled in the code. The replacement migration, migrations/1789325478.sh, installs linux-omarchy and makes it the first Limine entry on every x86_64 machine except T2 Macs, and it deliberately leaves the old kernel installed (lines 15–16: "Leave the old kernel installed so it remains available if the new one cannot boot"). On your XPS that means stock linux and linux-ptl both stay, as fallbacks behind linux-omarchy. Fresh installs now get their kernel from the ISO (08a875852), so no install script removes a kernel at all.

This was checked by reading the source and history only. Nothing needed running, so no worker was used. The second opinion, Codex at medium effort, reached the same conclusion on its own reading of the tree and history; it agreed rather than adding anything new, and its independence from this review is not guaranteed.

Waiting on the maintainer, with a recommendation to close this as resolved by #11845.

omarchybot avatar Oct 11 '26 04:10 omarchybot