Files
omarchycn/install/login/limine-snapper.sh
T
Ryan Hughes caa47c7595 limine-snapper.sh: use limine-update + purge stale UKIs
mkinitcpio -P alone doesn't trigger limine's UKI pipeline. The
limine-mkinitcpio-hook package installs /etc/pacman.d/hooks/90-mkinitcpio
-install.hook (overriding mkinitcpio's normal hook) which executes
/usr/share/libalpm/scripts/limine-mkinitcpio-install only on pacman
transactions, OR via the limine-mkinitcpio / limine-update CLI wrappers.

The previous fix (mkinitcpio -P) rebuilt initramfs-linux.img but left
the stale empty-cmdline UKI at /boot/EFI/Linux/<machine-id>_linux.efi
untouched. limine-update then booted that file.

Changes:
- Validate the cmdline extracted from /boot/limine.conf: fail loudly if
  empty or missing root=
- Delete every alternate /boot/limine.conf so limine-update can't pick
  the wrong one
- Delete stale UKIs for every installed kernel pkgbase before rebuilding
- Replace 'mkinitcpio -P' with 'limine-update' (which does
  limine-install + limine-mkinitcpio, reading KERNEL_CMDLINE from
  /etc/default/limine via limine-entry-tool and embedding it into a
  fresh UKI)
- Assert /boot/limine.conf has the Omarchy entry and (for encrypted
  installs) the cryptdevice= cmdline before continuing
2026-06-04 18:34:35 -04:00

125 lines
4.8 KiB
Bash

if command -v limine &>/dev/null; then
sudo tee /etc/mkinitcpio.conf.d/omarchy_hooks.conf <<EOF >/dev/null
HOOKS=(base udev plymouth keyboard autodetect microcode modconf kms keymap consolefont block encrypt filesystems fsck btrfs-overlayfs)
EOF
sudo tee /etc/mkinitcpio.conf.d/thunderbolt_module.conf <<EOF >/dev/null
MODULES+=(thunderbolt)
EOF
# Detect boot mode
[[ -d /sys/firmware/efi ]] && EFI=true
# Find config location
if [[ -f /boot/EFI/arch-limine/limine.conf ]]; then
limine_config="/boot/EFI/arch-limine/limine.conf"
elif [[ -f /boot/EFI/BOOT/limine.conf ]]; then
limine_config="/boot/EFI/BOOT/limine.conf"
elif [[ -f /boot/EFI/limine/limine.conf ]]; then
limine_config="/boot/EFI/limine/limine.conf"
elif [[ -f /boot/limine/limine.conf ]]; then
limine_config="/boot/limine/limine.conf"
elif [[ -f /boot/limine.conf ]]; then
limine_config="/boot/limine.conf"
else
echo "Error: Limine config not found" >&2
exit 1
fi
CMDLINE=$(grep "^[[:space:]]*cmdline:" "$limine_config" | head -1 | sed 's/^[[:space:]]*cmdline:[[:space:]]*//')
if [[ -z ${CMDLINE// } ]]; then
echo "Error: failed to extract kernel cmdline from $limine_config" >&2
exit 1
fi
if [[ $CMDLINE != *root=* ]]; then
echo "Error: extracted kernel cmdline has no root=: $CMDLINE" >&2
exit 1
fi
sudo cp $OMARCHY_PATH/default/limine/default.conf /etc/default/limine
sudo sed -i "s|@@CMDLINE@@|$CMDLINE|g" /etc/default/limine
# Append any drop-in kernel cmdline configs (from hardware fix scripts, etc.)
for dropin in /etc/limine-entry-tool.d/*.conf; do
[ -f "$dropin" ] && cat "$dropin" | sudo tee -a /etc/default/limine >/dev/null
done
# UKI and EFI fallback are EFI only
if [[ -z $EFI ]]; then
sudo sed -i '/^ENABLE_UKI=/d; /^ENABLE_LIMINE_FALLBACK=/d' /etc/default/limine
fi
# Remove every alternate Limine config so limine-update can't pick a stale one
# over our /boot/limine.conf.
for stale in \
/boot/EFI/arch-limine/limine.conf \
/boot/EFI/BOOT/limine.conf \
/boot/EFI/limine/limine.conf \
/boot/limine/limine.conf; do
[[ -f $stale ]] && sudo rm -f "$stale"
done
sudo cp $OMARCHY_PATH/default/limine/limine.conf /boot/limine.conf
# limine-mkinitcpio-hook fired its post-transaction UKI build when archinstall
# pacstrapped it (via omarchy-limine's depends) BEFORE /etc/default/limine and
# /etc/kernel/cmdline existed, so the UKI on disk was built with an empty
# cmdline. Delete every stale UKI for installed kernels so limine-update only
# finds our about-to-be-rebuilt one.
if [[ -d /boot/EFI/Linux ]]; then
while IFS= read -r kname; do
[[ -n $kname ]] || continue
sudo rm -f "/boot/EFI/Linux/"*"_${kname}.efi" \
"/boot/EFI/Linux/"*"_${kname}-fallback.efi"
done < <(cat /usr/lib/modules/*/pkgbase 2>/dev/null)
fi
# limine-update runs limine-install + limine-mkinitcpio (which reads
# /etc/default/limine's KERNEL_CMDLINE[default] via limine-entry-tool and
# embeds it into a freshly-built UKI). mkinitcpio -P alone does NOT trigger
# limine's UKI pipeline — only this command does.
sudo limine-update
# Sanity-check the final state. If any of these fail, the system will not
# boot, so it's better to halt the installer here than to ship a broken UKI.
if ! grep -q "^/+Omarchy" /boot/limine.conf; then
echo "Error: /boot/limine.conf does not contain an Omarchy entry" >&2
exit 1
fi
if [[ $CMDLINE == *cryptdevice=* ]] && ! grep -q "cryptdevice=" /boot/limine.conf; then
echo "Error: encrypted install but /boot/limine.conf has no cryptdevice=" >&2
exit 1
fi
# Only snapshot root — /home is user data; rolling it back loses user work
if ! sudo snapper list-configs 2>/dev/null | grep -q "root"; then
sudo snapper -c root create-config /
fi
sudo cp $OMARCHY_PATH/default/snapper/root /etc/snapper/configs/root
# Disable btrfs quotas — full qgroup accounting is a major performance drag
sudo btrfs quota disable / 2>/dev/null || true
chrootable_systemctl_enable limine-snapper-sync.service
fi
echo "Re-enabling mkinitcpio hooks..."
# Restore the specific mkinitcpio pacman hooks
if [[ -f /usr/share/libalpm/hooks/90-mkinitcpio-install.hook.disabled ]]; then
sudo mv /usr/share/libalpm/hooks/90-mkinitcpio-install.hook.disabled /usr/share/libalpm/hooks/90-mkinitcpio-install.hook
fi
if [[ -f /usr/share/libalpm/hooks/60-mkinitcpio-remove.hook.disabled ]]; then
sudo mv /usr/share/libalpm/hooks/60-mkinitcpio-remove.hook.disabled /usr/share/libalpm/hooks/60-mkinitcpio-remove.hook
fi
echo "mkinitcpio hooks re-enabled"
if [[ -n $EFI ]] && efibootmgr &>/dev/null; then
# Remove the archinstall-created Limine entry
while IFS= read -r bootnum; do
sudo efibootmgr -b "$bootnum" -B >/dev/null 2>&1
done < <(efibootmgr | grep -E "^Boot[0-9]{4}\*? Arch Linux Limine" | sed 's/^Boot\([0-9]\{4\}\).*/\1/')
fi