#!/usr/bin/env bash # Copyright (C) 2023 Umorpha Systems # SPDX-License-Identifier: AGPL-3.0-or-later set -euE -o pipefail v() { printf >&2 ' $ %s\n' "${*@Q}" "$@" } main() { local rootfs rootfs=$1 if [[ "$rootfs" != *rootfs* ]]; then echo >&2 "!! Filename '${rootfs}' does not look like a rootfs filename" return 2 fi local booted other booted=$(awk '$2 == "/run/umorpha-root/root"{print $1}' "/dev/mapper/vg_umorpha-lv_root_$other" { for krnl in "$tmpdir/mnt"/usr/lib/modules/*/vmlinuz; do pkgbase=$(cat -- ${krnl%vmlinuz}pkgbase) cat <<-EOF menuentry 'Parabola GNU/Linux-libre, ${pkgbase} kernel' set search --no-floppy --fs-uuid --set=root ${selector_boot#UUID=} echo 'Loading ${pkgbase} kernel...' linux /vmlinuz-${pkgbase} root=$selector_root overlay_root=$selector_overlay boot=$selector_boot rw echo 'Loading initial ramdisk...' initrd /initramfs-${pkgbase}.img echo 'Booting...' boot EOF done } | install -Dm600 /dev/stdin "/boot/grub/grub_a.cfg" <<-EOF v arch-chroot -- "$tmpdir/mnt" sh -c "printf '%s\n' usr/lib/modules/*/vmlinuz | /usr/share/libalpm/scripts/mkinitcpio install" } main "$@"