]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
refactor(dracut.sh): introduce _detect_library_directories
authorBenjamin Drung <benjamin.drung@canonical.com>
Mon, 26 Jan 2026 16:50:48 +0000 (17:50 +0100)
committerLaszlo <laszlo.gombos@gmail.com>
Wed, 28 Jan 2026 16:49:02 +0000 (11:49 -0500)
Move constructing `libdirs` into a separate helper function
`_detect_library_directories`.

dracut.sh

index 0eb112ca6b31300cf733f3b159d11dbe85596af3..94a9c196025b6fdb03754e9efb444687598836e3 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1474,8 +1474,9 @@ export srcmods
 DRACUT_TESTBIN=${DRACUT_TESTBIN:-/bin/sh}
 PKG_CONFIG=${PKG_CONFIG:-pkg-config}
 
-# Detect lib paths
-if ! [[ ${libdirs-} ]]; then
+_detect_library_directories() {
+    local libdirs=""
+
     if [[ $($DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} --dry-run -R "$DRACUT_TESTBIN") == */lib64/* ]] &> /dev/null \
         && [[ -d "${dracutsysrootdir-}/lib64" ]]; then
         libdirs+=" /lib64"
@@ -1491,7 +1492,12 @@ if ! [[ ${libdirs-} ]]; then
     # shellcheck disable=SC2046  # word splitting is wanted, libraries must not contain spaces
     libdirs+="$(printf ' %s' $(ldconfig_paths))"
 
-    libdirs="${libdirs# }"
+    echo "${libdirs# }"
+}
+
+# Detect lib paths
+if ! [[ ${libdirs-} ]]; then
+    libdirs=$(_detect_library_directories)
     export libdirs
 fi