]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(squash): explicitly create required directories
authorPhilipp Rudo <prudo@redhat.com>
Tue, 30 Jul 2024 11:35:17 +0000 (13:35 +0200)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Wed, 31 Jul 2024 11:41:26 +0000 (07:41 -0400)
At the moment 99squash relies on dracut-install to create the required
directories it later links to. This approach is error prone and will
cause problems when switching to use 99busybox later on, which tries to
add a link to /usr/sbin that hasn't been created. Thus explicitly
create the expected directories before installing the minimal initrd.

Signed-off-by: Philipp Rudo <prudo@redhat.com>
modules.d/99squash/module-setup.sh

index 5cbbec6394e02eadcafcb00b4ea7822da71f283e..6aa649b7cba9e3af06e48face6acc87e53a2f820 100755 (executable)
@@ -40,12 +40,15 @@ squash_get_handler() {
 }
 
 squash_install() {
-    local _busybox
+    local _busybox _dir
     _busybox=$(find_binary busybox)
 
-    # Create mount points for squash loader
-    mkdir -p "$initdir"/squash/
-    mkdir -p "$squashdir"/squash/
+    # Create mount points for squash loader and basic directories
+    mkdir -p "$initdir"/squash
+    for _dir in squash usr/bin usr/sbin usr/lib; do
+        mkdir -p "$squashdir/$_dir"
+        [[ $_dir == usr/* ]] && ln_r "/$_dir" "${_dir#usr}"
+    done
 
     # Install required modules and binaries for the squash image init script.
     if [[ $_busybox ]]; then
@@ -67,8 +70,6 @@ squash_install() {
     dracut_kernel_post
 
     # Install squash image init script.
-    ln_r /usr/bin /bin
-    ln_r /usr/sbin /sbin
     inst_simple "$moddir"/init-squash.sh /init
 
     # make sure that library links are correct and up to date for squash loader