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

218d2d
From 55a56c546bde71fb42c99aadd96e98fca2199823 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
218d2d
Subject: [PATCH 19/23] fix(dracut): move hooks directory from /usr/lib to
218d2d
 /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
218d2d
index c37038e3..1c7ca58a 100755
Adam Williamson 4faeed
--- a/dracut-init.sh
Adam Williamson 4faeed
+++ b/dracut-init.sh
218d2d
@@ -630,7 +630,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
218d2d
index a0af3dd2..5d43f44c 100755
Adam Williamson 4faeed
--- a/dracut.sh
Adam Williamson 4faeed
+++ b/dracut.sh
218d2d
@@ -1883,7 +1883,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
-- 
218d2d
2.42.0
Adam Williamson 4faeed