Blame 0001-fix-dracut-move-hooks-directory-from-usr-lib-to-var-.patch

Adam Williamson 4faeed
From a45048b80c27ee5a45a380052a6d29ab1925f7f9 Mon Sep 17 00:00:00 2001
Adam Williamson 4faeed
From: Laszlo Gombos <laszlo.gombos@gmail.com>
Adam Williamson 4faeed
Date: Fri, 5 Apr 2024 15:50:20 +0200
Adam Williamson 4faeed
Subject: [PATCH] fix(dracut): move hooks directory from /usr/lib to /var/lib
Adam Williamson 4faeed
Adam Williamson 4faeed
Since https://github.com/systemd/systemd/commit/ffc1ec73, /usr is mounted as
Adam Williamson 4faeed
read-only in the initramfs by default.
Adam Williamson 4faeed
Adam Williamson 4faeed
Fixes #2588
Adam Williamson 4faeed
Adam Williamson 4faeed
Co-authored-by: Antonio Alvarez Feijoo <antonio.feijoo@suse.com>
Adam Williamson 4faeed
---
Adam Williamson 4faeed
 dracut-init.sh                       | 2 +-
Adam Williamson 4faeed
 dracut.sh                            | 6 +++++-
Adam Williamson 4faeed
 modules.d/99base/module-setup.sh     | 5 ++++-
Adam Williamson 4faeed
 modules.d/99shutdown/module-setup.sh | 8 +++++---
Adam Williamson 4faeed
 4 files changed, 15 insertions(+), 6 deletions(-)
Adam Williamson 4faeed
Adam Williamson 4faeed
diff --git a/dracut-init.sh b/dracut-init.sh
Adam Williamson 4faeed
index 7ce3d1dd..863df0cb 100755
Adam Williamson 4faeed
--- a/dracut-init.sh
Adam Williamson 4faeed
+++ b/dracut-init.sh
Adam Williamson 4faeed
@@ -633,7 +633,7 @@ inst_hook() {
Adam Williamson 4faeed
         dfatal "No such hook type $1. Aborting initrd creation."
Adam Williamson 4faeed
         exit 1
Adam Williamson 4faeed
     fi
Adam Williamson 4faeed
-    hook="/lib/dracut/hooks/${1}/${2}-${3##*/}"
Adam Williamson 4faeed
+    hook="/var/lib/dracut/hooks/${1}/${2}-${3##*/}"
Adam Williamson 4faeed
     inst_simple "$3" "$hook"
Adam Williamson 4faeed
     chmod u+x "$initdir/$hook"
Adam Williamson 4faeed
 }
Adam Williamson 4faeed
diff --git a/dracut.sh b/dracut.sh
Adam Williamson 4faeed
index 3914d7c5..148ef8b0 100755
Adam Williamson 4faeed
--- a/dracut.sh
Adam Williamson 4faeed
+++ b/dracut.sh
Adam Williamson 4faeed
@@ -1884,7 +1884,11 @@ mkdir -p "${initdir}"/lib/dracut
Adam Williamson 4faeed
 
Adam Williamson 4faeed
 if [[ $kernel_only != yes ]]; then
Adam Williamson 4faeed
     mkdir -p "${initdir}/etc/cmdline.d"
Adam Williamson 4faeed
-    mkdir -m 0755 "${initdir}"/lib/dracut/hooks
Adam Williamson 4faeed
+    mkdir -m 0755 -p "${initdir}"/var/lib/dracut/hooks
Adam Williamson 4faeed
+
Adam Williamson 4faeed
+    # symlink to old hooks location for compatibility
Adam Williamson 4faeed
+    ln_r /var/lib/dracut/hooks /lib/dracut/hooks
Adam Williamson 4faeed
+
Adam Williamson 4faeed
     for _d in $hookdirs; do
Adam Williamson 4faeed
         # shellcheck disable=SC2174
Adam Williamson 4faeed
         mkdir -m 0755 -p "${initdir}/lib/dracut/hooks/$_d"
Adam Williamson 4faeed
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
Adam Williamson 4faeed
index 54b0deb9..bfdc51d4 100755
Adam Williamson 4faeed
--- a/modules.d/99base/module-setup.sh
Adam Williamson 4faeed
+++ b/modules.d/99base/module-setup.sh
Adam Williamson 4faeed
@@ -45,7 +45,10 @@ install() {
Adam Williamson 4faeed
 
Adam Williamson 4faeed
     [ -e "${initdir}/lib" ] || mkdir -m 0755 -p "${initdir}"/lib
Adam Williamson 4faeed
     mkdir -m 0755 -p "${initdir}"/lib/dracut
Adam Williamson 4faeed
-    mkdir -m 0755 -p "${initdir}"/lib/dracut/hooks
Adam Williamson 4faeed
+    mkdir -m 0755 -p "${initdir}"/var/lib/dracut/hooks
Adam Williamson 4faeed
+
Adam Williamson 4faeed
+    # symlink to old hooks location for compatibility
Adam Williamson 4faeed
+    ln_r /var/lib/dracut/hooks /lib/dracut/hooks
Adam Williamson 4faeed
 
Adam Williamson 4faeed
     mkdir -p "${initdir}"/tmp
Adam Williamson 4faeed
 
Adam Williamson 4faeed
diff --git a/modules.d/99shutdown/module-setup.sh b/modules.d/99shutdown/module-setup.sh
Adam Williamson 4faeed
index 2b999024..f53017ff 100755
Adam Williamson 4faeed
--- a/modules.d/99shutdown/module-setup.sh
Adam Williamson 4faeed
+++ b/modules.d/99shutdown/module-setup.sh
Adam Williamson 4faeed
@@ -17,9 +17,11 @@ install() {
Adam Williamson 4faeed
     inst_multiple umount poweroff reboot halt losetup stat sleep timeout
Adam Williamson 4faeed
     inst_multiple -o kexec
Adam Williamson 4faeed
     inst "$moddir/shutdown.sh" "$prefix/shutdown"
Adam Williamson 4faeed
-    [ -e "${initdir}/lib" ] || mkdir -m 0755 -p "${initdir}"/lib
Adam Williamson 4faeed
-    mkdir -m 0755 -p "${initdir}"/lib/dracut
Adam Williamson 4faeed
-    mkdir -m 0755 -p "${initdir}"/lib/dracut/hooks
Adam Williamson 4faeed
+    mkdir -m 0755 -p "${initdir}"/var/lib/dracut/hooks
Adam Williamson 4faeed
+
Adam Williamson 4faeed
+    # symlink to old hooks location for compatibility
Adam Williamson 4faeed
+    ln_r /var/lib/dracut/hooks /lib/dracut/hooks
Adam Williamson 4faeed
+
Adam Williamson 4faeed
     for _d in $hookdirs shutdown shutdown-emergency; do
Adam Williamson 4faeed
         mkdir -m 0755 -p "${initdir}"/lib/dracut/hooks/"$_d"
Adam Williamson 4faeed
     done
Adam Williamson 4faeed
-- 
Adam Williamson 4faeed
2.44.0
Adam Williamson 4faeed