From: Benjamin Drung Date: Mon, 26 Jan 2026 20:30:27 +0000 (+0100) Subject: fix(dracut): move libdirs to dracut-functions.sh X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fe23c38b49b6468a109284398e54fd592df3758;p=thirdparty%2Fdracut-ng.git fix(dracut): move libdirs to dracut-functions.sh The variable `libdirs` is used by functions defined in `dracut-functions.sh` (for example `inst_libdir_file`). So move initializing `libdirs` to `dracut-functions.sh`. --- diff --git a/dracut-functions.sh b/dracut-functions.sh index d04718db2..669f62719 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -1508,6 +1508,26 @@ determine_kernel_image() { return 1 } +_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" + [[ -d "${dracutsysrootdir-}/usr/lib64" ]] && libdirs+=" /usr/lib64" + fi + + if [[ -d "${dracutsysrootdir-}/lib" ]]; then + libdirs+=" /lib" + [[ -d "${dracutsysrootdir-}/usr/lib" ]] && libdirs+=" /usr/lib" + fi + + # shellcheck disable=SC2046 # word splitting is wanted, libraries must not contain spaces + libdirs+="$(printf ' %s' $(ldconfig_paths))" + + echo "${libdirs# }" +} + if ! is_func dinfo > /dev/null 2>&1; then # shellcheck source=./dracut-logger.sh . "${BASH_SOURCE[0]%/*}/dracut-logger.sh" @@ -1515,6 +1535,7 @@ if ! is_func dinfo > /dev/null 2>&1; then fi DRACUT_LDCONFIG=${DRACUT_LDCONFIG:-ldconfig} +DRACUT_TESTBIN=${DRACUT_TESTBIN:-/bin/sh} if ! [[ "${DRACUT_INSTALL-}" ]]; then DRACUT_INSTALL=$(find_binary dracut-install || true) @@ -1537,3 +1558,7 @@ if ! command -v "${DRACUT_INSTALL%% *}" > /dev/null 2>&1; then dfatal "${DRACUT_INSTALL:-dracut-install} not found!" exit 10 fi + +if ! [[ ${libdirs-} ]]; then + libdirs=$(_detect_library_directories) +fi diff --git a/dracut.sh b/dracut.sh index aaa1d24b1..244a28303 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1471,35 +1471,8 @@ export srcmods export hookdirs } -DRACUT_TESTBIN=${DRACUT_TESTBIN:-/bin/sh} PKG_CONFIG=${PKG_CONFIG:-pkg-config} -_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" - [[ -d "${dracutsysrootdir-}/usr/lib64" ]] && libdirs+=" /usr/lib64" - - fi - - if [[ -d "${dracutsysrootdir-}/lib" ]]; then - libdirs+=" /lib" - [[ -d "${dracutsysrootdir-}/usr/lib" ]] && libdirs+=" /usr/lib" - fi - - # shellcheck disable=SC2046 # word splitting is wanted, libraries must not contain spaces - libdirs+="$(printf ' %s' $(ldconfig_paths))" - - echo "${libdirs# }" -} - -# Detect lib paths -if ! [[ ${libdirs-} ]]; then - libdirs=$(_detect_library_directories) -fi - dracut_module_included() { [[ " $mods_to_load $modules_loaded " == *\ $*\ * ]] }