From 8a972da9756dbebe4e46512079363278dfb2a62a Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Sun, 13 Sep 2026 14:43:47 -0400 Subject: [PATCH] Migrate Panther Lake systems to the Omarchy PTL kernel --- etc/limine-entry-tool.d/omarchy-defaults.conf | 2 +- install/hardware/all.sh | 2 +- install/hardware/fix-elgato-camlink-4k.sh | 2 +- install/hardware/intel/ptl-kernel.sh | 13 +- install/hardware/nvidia.sh | 2 +- install/omarchy-other.packages | 4 +- migrations/1789095456.sh | 45 ++++ test/shell.d/limine-defaults-test.sh | 4 + test/shell.d/ptl-kernel-migration-test.sh | 195 ++++++++++++++++++ 9 files changed, 257 insertions(+), 12 deletions(-) create mode 100644 migrations/1789095456.sh create mode 100644 test/shell.d/ptl-kernel-migration-test.sh diff --git a/etc/limine-entry-tool.d/omarchy-defaults.conf b/etc/limine-entry-tool.d/omarchy-defaults.conf index 49c6204b..1703dab4 100644 --- a/etc/limine-entry-tool.d/omarchy-defaults.conf +++ b/etc/limine-entry-tool.d/omarchy-defaults.conf @@ -15,7 +15,7 @@ ENABLE_LIMINE_FALLBACK=yes # Find and add other bootloaders FIND_BOOTLOADERS=yes -BOOT_ORDER="*, *fallback, Snapshots" +BOOT_ORDER="linux-omarchy-*, *, *fallback, Snapshots" # Snapper is configured with NUMBER_LIMIT="5" (see default/snapper/root), but # limine-snapper-sync can see the newly created sixth snapshot before cleanup diff --git a/install/hardware/all.sh b/install/hardware/all.sh index defeef1c..df695c65 100644 --- a/install/hardware/all.sh +++ b/install/hardware/all.sh @@ -17,7 +17,7 @@ run_logged "$OMARCHY_INSTALL/hardware/intel/thermald.sh" # Swap in the Panther Lake kernel before anything pulls DKMS modules in. # intel-ipu7-camera drags in ipu7-drivers, vision-drivers and v4l2loopback, # and building all three against the stock kernel only to rebuild them against -# linux-ptl and tear the first set down again cost ~25s of the install. +# the PTL kernel and tear the first set down again cost ~25s of the install. run_logged "$OMARCHY_INSTALL/hardware/intel/ptl-kernel.sh" run_logged "$OMARCHY_INSTALL/hardware/intel/ipu7-camera.sh" run_logged "$OMARCHY_INSTALL/hardware/intel/fred.sh" diff --git a/install/hardware/fix-elgato-camlink-4k.sh b/install/hardware/fix-elgato-camlink-4k.sh index f726fd9a..eec9771f 100644 --- a/install/hardware/fix-elgato-camlink-4k.sh +++ b/install/hardware/fix-elgato-camlink-4k.sh @@ -4,7 +4,7 @@ # v4l2-relayd re-exposes it at 1280x720 under the same name. if omarchy-hw-elgato-camlink-4k; then - mapfile -t kernel_headers < <(pacman -Qqs '^linux(-zen|-lts|-hardened|-t2|-ptl|-omarchy-bore)?$' | sed 's/$/-headers/') + mapfile -t kernel_headers < <(pacman -Qqs '^linux(-zen|-lts|-hardened|-t2|-ptl|-omarchy-bore|-omarchy-ptl-novrr-mm)?$' | sed 's/$/-headers/') omarchy-pkg-add "${kernel_headers[@]}" v4l2loopback-dkms v4l2loopback-utils v4l2-relayd sudo install -Dm644 "$OMARCHY_PATH/default/udev/elgato-camlink-4k.rules" /etc/udev/rules.d/71-elgato-camlink-4k.rules diff --git a/install/hardware/intel/ptl-kernel.sh b/install/hardware/intel/ptl-kernel.sh index 79482724..12659a28 100644 --- a/install/hardware/intel/ptl-kernel.sh +++ b/install/hardware/intel/ptl-kernel.sh @@ -1,16 +1,17 @@ # Install Panther Lake kernel for Dell XPS Panther Lake systems -# The linux-ptl kernel includes audio driver patches not yet in mainline. +# The Omarchy PTL kernel includes Panther Lake display and memory fixes. if omarchy-hw-match "XPS" && omarchy-hw-intel-ptl; then echo "Detected Dell XPS Panther Lake, installing PTL kernel..." - omarchy-pkg-add linux-ptl linux-ptl-headers + # linux-ptl required SOF firmware; the new kernel only lists it as optional. + omarchy-pkg-add linux-omarchy-ptl-novrr-mm linux-omarchy-ptl-novrr-mm-headers sof-firmware pacman -Rdd --noconfirm linux linux-headers || true - # linux-ptl doesn't provide=linux, so anything depending on linux drags the + # The PTL kernel doesn't provide=linux, so anything depending on linux drags the # stock kernel back in and the boot menu grows a second, slower entry. if pacman -Qq linux &>/dev/null; then - echo "WARNING: stock linux kernel still installed alongside linux-ptl:" + echo "WARNING: stock linux kernel still installed alongside the Omarchy PTL kernel:" pacman -Qi linux | grep -i "required by" fi @@ -19,7 +20,7 @@ if omarchy-hw-match "XPS" && omarchy-hw-intel-ptl; then # the last BOOT_ORDER wins, so an earlier-sorting name is a silent no-op. rm -f /etc/limine-entry-tool.d/dell-xps-panther-lake.conf cat > /etc/limine-entry-tool.d/zz-dell-xps-panther-lake.conf <<'EOF' -# Only show Panther Lake kernel in boot menu on Dell XPS Panther Lake -BOOT_ORDER="linux-ptl*, *fallback, Snapshots" +# Prefer Omarchy kernels while keeping other kernels available for recovery +BOOT_ORDER="linux-omarchy-*, *, *fallback, Snapshots" EOF fi diff --git a/install/hardware/nvidia.sh b/install/hardware/nvidia.sh index e7370995..81e1556e 100644 --- a/install/hardware/nvidia.sh +++ b/install/hardware/nvidia.sh @@ -1,6 +1,6 @@ if lspci | grep -qi 'nvidia'; then # Check which kernel is installed and set appropriate headers package - KERNEL_PACKAGE=$(pacman -Qqs '^linux(-zen|-lts|-hardened|-t2|-ptl)?$' | head -1 || true) + KERNEL_PACKAGE=$(pacman -Qqs '^linux(-zen|-lts|-hardened|-t2|-ptl|-omarchy-ptl-novrr-mm)?$' | head -1 || true) [[ -n $KERNEL_PACKAGE ]] && omarchy-pkg-add "$KERNEL_PACKAGE-headers" if omarchy-hw-nvidia-gsp; then diff --git a/install/omarchy-other.packages b/install/omarchy-other.packages index 3214657a..873e5048 100644 --- a/install/omarchy-other.packages +++ b/install/omarchy-other.packages @@ -23,8 +23,8 @@ limine-snapper-sync linux linux-firmware linux-headers -linux-ptl -linux-ptl-headers +linux-omarchy-ptl-novrr-mm +linux-omarchy-ptl-novrr-mm-headers macbook12-spi-driver-dkms nvidia-580xx-dkms nvidia-dkms diff --git a/migrations/1789095456.sh b/migrations/1789095456.sh new file mode 100644 index 00000000..574d3d9e --- /dev/null +++ b/migrations/1789095456.sh @@ -0,0 +1,45 @@ +echo "Install the Omarchy Panther Lake kernel and prefer Omarchy kernels in Limine" + +omarchy-pkg-present linux-ptl || exit 0 + +limine_conf="${OMARCHY_PTL_LIMINE_CONF:-/etc/default/limine}" +limine_drop_ins="${OMARCHY_PTL_LIMINE_DROP_INS:-/etc/limine-entry-tool.d}" +rebuild_marker="${OMARCHY_PTL_REBUILD_MARKER:-/var/lib/omarchy/migrations/1789095456}" +kernel="linux-omarchy-ptl-novrr-mm" + +# Completion is machine-wide even though migrations run once per user. Leave +# the old kernel installed so it remains available if the new one cannot boot. +[[ ! -e $rebuild_marker ]] || exit 0 +omarchy-pkg-add "$kernel" "$kernel-headers" + +# /etc/default/limine and the Dell drop-ins were written by the installer. +# omarchy-settings ships omarchy-defaults.conf, but pacman's backup protection +# can leave its update in a .pacnew when other settings were customized. Repair +# only the old boot order in the active files, preserving custom orders and +# unrelated settings, including the root filesystem's kernel command line. +for conf in "$limine_conf" \ + "$limine_drop_ins/omarchy-defaults.conf" \ + "$limine_drop_ins/dell-xps-panther-lake.conf" \ + "$limine_drop_ins/zz-dell-xps-panther-lake.conf"; do + if [[ -f $conf ]]; then + sudo sed -i -E \ + 's/^([[:space:]]*BOOT_ORDER=)"(\*|linux-ptl\*), \*fallback, Snapshots"([[:space:]]*(#.*)?)$/\1"linux-omarchy-*, *, *fallback, Snapshots"\3/' \ + "$conf" + fi +done + +# Package hooks ran before the config repair. Rebuild the new kernel's image +# and boot entry explicitly, including on retries after a failed rebuild. +sudo limine-mkinitcpio "$kernel" + +# limine-mkinitcpio can return success after skipping a failed kernel build. +# Do not mark the migration complete unless the new kernel is in the menu. +if ! sudo limine-entry-tool --tree | grep -F "$kernel" >/dev/null; then + echo "The new Panther Lake kernel has no Limine boot entry; rerun omarchy-migrate after fixing the boot image build." >&2 + exit 1 +fi + +# Keeping the running kernel installed prevents the updater from detecting a +# kernel replacement, so request the reboot explicitly. +omarchy-state set reboot-required +sudo install -Dm644 /dev/null "$rebuild_marker" diff --git a/test/shell.d/limine-defaults-test.sh b/test/shell.d/limine-defaults-test.sh index e4c420ff..cf93ebdf 100644 --- a/test/shell.d/limine-defaults-test.sh +++ b/test/shell.d/limine-defaults-test.sh @@ -9,3 +9,7 @@ packaged_defaults="$ROOT/etc/limine-entry-tool.d/omarchy-defaults.conf" grep -Fq 'KERNEL_CMDLINE[default]+=" initramfs_async=0"' "$packaged_defaults" || fail "the packaged Limine defaults still unpack the initramfs synchronously" pass "packaged Limine defaults keep Plymouth alive at the LUKS prompt" + +grep -Fxq 'BOOT_ORDER="linux-omarchy-*, *, *fallback, Snapshots"' "$packaged_defaults" || + fail "packaged Limine defaults prefer Omarchy kernels and retain recovery entries" +pass "packaged Limine defaults prefer Omarchy kernels and retain recovery entries" diff --git a/test/shell.d/ptl-kernel-migration-test.sh b/test/shell.d/ptl-kernel-migration-test.sh new file mode 100644 index 00000000..874397c0 --- /dev/null +++ b/test/shell.d/ptl-kernel-migration-test.sh @@ -0,0 +1,195 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +migration="$ROOT/migrations/1789095456.sh" +scratch=$(mktemp -d) +trap 'rm -rf "$scratch"' EXIT +mkdir -p "$scratch/bin" "$scratch/drop-ins" + +export PATH="$scratch/bin:$ROOT/bin:$PATH" +export CALL_LOG="$scratch/calls" +export INSTALLED_PACKAGES="$scratch/packages" +export OMARCHY_PTL_LIMINE_CONF="$scratch/limine" +export OMARCHY_PTL_LIMINE_DROP_INS="$scratch/drop-ins" +export OMARCHY_PTL_REBUILD_MARKER="$scratch/state/completed" +kernel="linux-omarchy-ptl-novrr-mm" +boot_order='BOOT_ORDER="linux-omarchy-*, *, *fallback, Snapshots"' + +# Exercise the real package helpers, including their post-install queries. +cat > "$scratch/bin/pacman" <<'SH' +#!/bin/bash +case "$1" in + -Q) grep -Fxq "$2" "$INSTALLED_PACKAGES" ;; + -S) + printf 'pacman %s\n' "$*" >> "$CALL_LOG" + [[ ${INSTALL_FAIL:-0} == "0" ]] || exit 1 + for arg in "$@"; do + [[ $arg == -* ]] || printf '%s\n' "$arg" >> "$INSTALLED_PACKAGES" + done + ;; + *) exit 99 ;; +esac +SH + +cat > "$scratch/bin/sudo" <<'SH' +#!/bin/bash +printf 'sudo %s\n' "$*" >> "$CALL_LOG" +case "$1" in + pacman | sed | install | limine-mkinitcpio | limine-entry-tool) exec "$@" ;; + *) exit 99 ;; +esac +SH + +cat > "$scratch/bin/limine-mkinitcpio" <<'SH' +#!/bin/bash +[[ ${REBUILD_FAIL:-0} == "0" ]] +SH + +cat > "$scratch/bin/limine-entry-tool" <<'SH' +#!/bin/bash +[[ $* == "--tree" ]] || exit 99 +printf '%s\n' 'Omarchy' ' linux-ptl' ' Snapshots' +if [[ ${MISSING_ENTRY:-0} == "0" ]]; then + printf '%s\n' ' linux-omarchy-ptl-novrr-mm' +fi +SH + +cat > "$scratch/bin/omarchy-state" <<'SH' +#!/bin/bash +[[ $* == "set reboot-required" ]] || exit 99 +printf 'state %s\n' "$*" >> "$CALL_LOG" +SH +chmod +x "$scratch/bin/"* + +reset_fixture() { + : > "$CALL_LOG" + printf '%s\n' linux-ptl linux-ptl-headers > "$INSTALLED_PACKAGES" + rm -f "$OMARCHY_PTL_REBUILD_MARKER" "$OMARCHY_PTL_LIMINE_DROP_INS/"*.conf + cat > "$OMARCHY_PTL_LIMINE_CONF" <<'CONF' +KERNEL_CMDLINE[default]="root=UUID=keep-me rw cryptdevice=UUID=keep-me:root" +BOOT_ORDER="*, *fallback, Snapshots" +ENABLE_UKI=yes +CONF + cp "$OMARCHY_PTL_LIMINE_CONF" "$scratch/original-limine" +} + +run_migration() { + bash -euo pipefail "$migration" > "$scratch/output" 2>&1 +} + +assert_preferred() { + grep -Fxq "$boot_order" "$1" || fail "Omarchy kernels are preferred in $1" +} + +reset_fixture +printf '%s\n' linux > "$INSTALLED_PACKAGES" +run_migration +[[ ! -s $CALL_LOG ]] || fail "systems without linux-ptl do not change" +cmp -s "$OMARCHY_PTL_LIMINE_CONF" "$scratch/original-limine" || fail "unaffected Limine settings stay unchanged" +[[ ! -e $OMARCHY_PTL_REBUILD_MARKER ]] || fail "unaffected systems do not get a completion marker" +pass "systems without linux-ptl are skipped" + +reset_fixture +for name in dell-xps-panther-lake zz-dell-xps-panther-lake; do + printf '%s\n' 'BOOT_ORDER="linux-ptl*, *fallback, Snapshots"' > "$OMARCHY_PTL_LIMINE_DROP_INS/$name.conf" +done +cp "$OMARCHY_PTL_LIMINE_CONF" "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf" +run_migration +grep -Fxq "pacman -S --noconfirm --needed $kernel $kernel-headers" "$CALL_LOG" || fail "both new packages are installed" +grep -Fxq linux-ptl "$INSTALLED_PACKAGES" || fail "the old kernel is kept for recovery" +grep -Fxq linux-ptl-headers "$INSTALLED_PACKAGES" || fail "the old kernel headers are kept" +assert_preferred "$OMARCHY_PTL_LIMINE_CONF" +for conf in "$OMARCHY_PTL_LIMINE_DROP_INS/"*.conf; do + assert_preferred "$conf" +done +diff -u <(sed '/^BOOT_ORDER=/d' "$scratch/original-limine") \ + <(sed '/^BOOT_ORDER=/d' "$OMARCHY_PTL_LIMINE_CONF") || fail "kernel command line and unrelated settings are preserved" +grep -Fxq "sudo limine-mkinitcpio $kernel" "$CALL_LOG" || fail "the new kernel's boot image is rebuilt" +[[ -f $OMARCHY_PTL_REBUILD_MARKER ]] || fail "successful completion is recorded" +grep -Fxq 'state set reboot-required' "$CALL_LOG" || fail "the updater must offer a reboot when retaining the old kernel" +pass "new packages install, all stock boot orders are repaired, and the old kernel remains available" + +: > "$CALL_LOG" +run_migration +[[ ! -s $CALL_LOG ]] || fail "another user's run does not repeat the machine-wide migration" +pass "repeat runs are a no-op after successful completion" + +reset_fixture +printf '%s\n' "$kernel" >> "$INSTALLED_PACKAGES" +run_migration +grep -Fxq "$kernel-headers" "$INSTALLED_PACKAGES" || fail "missing headers install when the kernel is already present" +pass "a partially installed kernel gets its missing headers" + +reset_fixture +printf '%s\n' "$kernel" "$kernel-headers" >> "$INSTALLED_PACKAGES" +run_migration +! grep -q '^pacman -S' "$CALL_LOG" || fail "already installed packages are not reinstalled" +assert_preferred "$OMARCHY_PTL_LIMINE_CONF" +pass "existing new packages still receive the config repair and boot rebuild" + +reset_fixture +if INSTALL_FAIL=1 run_migration; then + fail "package installation failure must fail the migration" +fi +cmp -s "$OMARCHY_PTL_LIMINE_CONF" "$scratch/original-limine" || fail "install failure leaves the config untouched" +! grep -q 'limine-mkinitcpio' "$CALL_LOG" || fail "install failure does not rebuild" +[[ ! -e $OMARCHY_PTL_REBUILD_MARKER ]] || fail "install failure stays pending" +pass "package failures leave the old boot setup intact and the migration pending" + +reset_fixture +if REBUILD_FAIL=1 run_migration; then + fail "boot rebuild failure must fail the migration" +fi +[[ ! -e $OMARCHY_PTL_REBUILD_MARKER ]] || fail "rebuild failure stays pending" +! grep -q '^state ' "$CALL_LOG" || fail "rebuild failure must not request a reboot" +assert_preferred "$OMARCHY_PTL_LIMINE_CONF" +: > "$CALL_LOG" +run_migration +grep -Fxq "sudo limine-mkinitcpio $kernel" "$CALL_LOG" || fail "retry must rebuild even after config and packages are repaired" +[[ -f $OMARCHY_PTL_REBUILD_MARKER ]] || fail "retry records successful completion" +pass "a failed rebuild is retried even after config and package changes succeeded" + +reset_fixture +if MISSING_ENTRY=1 run_migration; then + fail "a silently skipped kernel build must fail the migration" +fi +[[ ! -e $OMARCHY_PTL_REBUILD_MARKER ]] || fail "a missing boot entry stays pending" +! grep -q '^state ' "$CALL_LOG" || fail "a missing boot entry must not request a reboot" +run_migration +[[ -f $OMARCHY_PTL_REBUILD_MARKER ]] || fail "a missing boot entry can be repaired on retry" +pass "a successful command without a new boot entry cannot complete the migration" + +reset_fixture +printf '%s\n' 'BOOT_ORDER="linux-lts, *, *fallback, Snapshots"' > "$OMARCHY_PTL_LIMINE_CONF" +cp "$OMARCHY_PTL_LIMINE_CONF" "$scratch/custom-limine" +run_migration +cmp -s "$OMARCHY_PTL_LIMINE_CONF" "$scratch/custom-limine" || fail "custom boot orders stay unchanged" +pass "administrator-defined boot orders are preserved" + +reset_fixture +cp "$OMARCHY_PTL_LIMINE_CONF" "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf" +printf '%s\n' 'ENABLE_SORT=yes' >> "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf" +cp "$ROOT/etc/limine-entry-tool.d/omarchy-defaults.conf" "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf.pacnew" +run_migration +assert_preferred "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf" +grep -Fxq 'ENABLE_SORT=yes' "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf" || fail "custom packaged settings survive the repair" +cmp -s "$ROOT/etc/limine-entry-tool.d/omarchy-defaults.conf" \ + "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf.pacnew" || fail "the pending pacnew is left for the administrator to merge" +pass "active packaged defaults are repaired when customized settings leave the update in a pacnew" + +reset_fixture +printf '%s\n' ' BOOT_ORDER="*, *fallback, Snapshots" # keep this comment' > "$OMARCHY_PTL_LIMINE_CONF" +run_migration +grep -Fxq " $boot_order # keep this comment" "$OMARCHY_PTL_LIMINE_CONF" || fail "stock orders with comments are repaired" +pass "indentation and comments survive the repair" + +reset_fixture +rm "$OMARCHY_PTL_LIMINE_CONF" +cp "$ROOT/etc/limine-entry-tool.d/omarchy-defaults.conf" "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf" +run_migration +[[ ! -e $OMARCHY_PTL_LIMINE_CONF ]] || fail "missing central config is not fabricated" +assert_preferred "$OMARCHY_PTL_LIMINE_DROP_INS/omarchy-defaults.conf" +pass "installs without a central config inherit the packaged boot order"