]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dracut): respect PKG_CONFIG env var instead of hardcoding pkg-config
authorJames Le Cuirot <jlecuirot@microsoft.com>
Thu, 5 Sep 2024 10:55:35 +0000 (11:55 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Fri, 2 May 2025 19:22:45 +0000 (15:22 -0400)
When using a sysroot, we should use pkg-config data from the sysroot.
While we could set PKG_CONFIG_LIBDIR, the lib directory can vary.
Distributions typically set up pkg-config wrappers for this purpose and
it is customary to respect the PKG_CONFIG variable in build systems.
Users can still set simply PKG_CONFIG_LIBDIR instead if they prefer that
approach.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
dracut-init.sh
dracut.sh
man/dracut.8.adoc

index 9be00c5649129166b3656af51c17028c00f90eb5..3eaa8524ebe8b833431bcd8c356461d9f7caedba 100755 (executable)
@@ -81,6 +81,7 @@ export srcmods
 DRACUT_LDD=${DRACUT_LDD:-ldd}
 DRACUT_TESTBIN=${DRACUT_TESTBIN:-/bin/sh}
 DRACUT_LDCONFIG=${DRACUT_LDCONFIG:-ldconfig}
+PKG_CONFIG=${PKG_CONFIG:-pkg-config}
 
 # shellcheck source=./dracut-functions.sh
 . "$dracutbasedir"/dracut-functions.sh
index c2b2c9496df9dd16a5686770e7c08a93b4cc18bb..e158aabd4d4251320eb2e91851c59f035669f78d 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1489,7 +1489,7 @@ set_global_var() {
     local _pkgvar="${2%:*}"
     local _var="${2#*:}"
     [[ -z ${!_var} || ! -d ${dracutsysrootdir}${!_var} ]] \
-        && export "$_var"="$(pkg-config "$_pkgconfig" --variable="$_pkgvar" 2> /dev/null)"
+        && export "$_var"="$($PKG_CONFIG "$_pkgconfig" --variable="$_pkgvar" 2> /dev/null)"
     if [[ -z ${!_var} || ! -d ${dracutsysrootdir}${!_var} ]]; then
         shift 2
         if (($# == 1)); then
index a6d044a9f80aa67d8988a628797964ec70a9d069..ba33ab190b0720dd8d02fc4b468fd3729a42e9f4 100644 (file)
@@ -655,6 +655,13 @@ _DRACUT_LDD_::
 Default:
     _ldd_
 
+_PKG_CONFIG_::
+    sets the _pkg-config_ program path and options. Optional.
+    Most useful together with **--sysroot**.
++
+Default:
+    _pkg-config_
+
 _DRACUT_TESTBIN_::
     sets the initially tested binary for detecting library paths.
     Optional. Used for **--sysroot**. In the cross-compiled sysroot,