From cddcce4ff37941cd27c69e24d5fcd211e6829bd2 Mon Sep 17 00:00:00 2001
From: hygienic-books <hygienic-books@tentic.net>
Date: Mon, 20 Feb 2023 04:14:44 +0100
Subject: [PATCH] fix(os): Shorten initramfs build list (#1)

---
 setup.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/setup.sh b/setup.sh
index bfddaf2..ce8a107 100644
--- a/setup.sh
+++ b/setup.sh
@@ -258,6 +258,16 @@ function add_zfs_hook_to_initramfs () {
         '/mnt/etc/mkinitcpio.conf'
 }
 
+function set_initramfs_build_list () {
+    # No need to build fallback initramfs, our new fallback is ZFS snapshots
+    sed -ri \
+        -e '/^#/d' \
+        -e '/^$/d' \
+        -e '/^fallback/d' \
+        -e 's'$'\x1''^(PRESETS=)[^\r\n\f]*'$'\x1''\1('"'"'default'"'"')'$'\x1''g' \
+        '/mnt/etc/mkinitcpio.d/linux.preset'
+}
+
 function add_zfs_files_to_new_os () {
     for zfs_file in '/etc/hostid' '/etc/zfs/zpool.cache' '/etc/zfs/zpool.key'; do
         rsync -av --itemize-changes {'','/mnt'}"${zfs_file}"
@@ -510,6 +520,7 @@ function main () {
             set_hostname
             set_locale
             add_zfs_hook_to_initramfs
+            set_initramfs_build_list
             add_zfs_files_to_new_os
             enter_chroot
             # We're done in chroot