From 63408776570e99fa7748a4d43f2357e08c6d34d9 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Tue, 2 Jan 2024 19:22:26 -0800
Subject: [PATCH] cleanup old mkinitcpio preset

---
 README.md                 | 8 +++++---
 src/hook-kernel-rename.sh | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 7a0664b..293a334 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,14 @@
 # Shared bootdir helper
 
+> Sharing the same `/boot` between multiple linux installations.
+
 Background: <https://recolic.net/blog/post/deniable-encryption-and-shared-boot-partition>
 
-You may have multiple linux installations, and they want to share the same `/boot` directory. 
-However, each of them want different kernel paramters. 
+You have multiple linux installations, with the same `/boot`. 
+However, each of them want different kernel paramters.
 
 This scenario usually appears while you want to deniable-encrypt all your computers, without 
-bringing tons of USB sticks with you. 
+bringing many USB sticks with you. 
 
 ## Problem1 - multiple installations may share the same vmlinuz filename
 
diff --git a/src/hook-kernel-rename.sh b/src/hook-kernel-rename.sh
index 7037292..a6f5ea6 100755
--- a/src/hook-kernel-rename.sh
+++ b/src/hook-kernel-rename.sh
@@ -51,5 +51,8 @@ while read -r line; do
 
     echo "Renamed pkgbase from $pkgbase to $new_pkgbase successfully. " 1>&2 || 
     exit $? # Crash on error
+
+    # Remove old mkinitcpio presets
+    [[ -f "/etc/mkinitcpio.d/${pkgbase}.preset" ]] && mv "/etc/mkinitcpio.d/${pkgbase}.preset" "/etc/mkinitcpio.d/${pkgbase}.preset.pacsave" && echo "Did old mkinitcpio.preset cleanup."
 done
 
-- 
GitLab