]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
feat(dracut): set systemdversion global var using pkg-config
authorJames Le Cuirot <jlecuirot@microsoft.com>
Thu, 5 Sep 2024 11:19:09 +0000 (12:19 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Fri, 2 May 2025 19:22:45 +0000 (15:22 -0400)
This falls back to 0 if the version cannot be determined. The version
isn't a regular pkg-config variable like the others, but we still want
the ability to override this through the Dracut config, so make
"modversion" a special case.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
dracut.sh

index e158aabd4d4251320eb2e91851c59f035669f78d..238245566491f61d13b8e2707bac8555fef5c904 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1488,9 +1488,14 @@ set_global_var() {
     local _pkgconfig="$1"
     local _pkgvar="${2%:*}"
     local _var="${2#*:}"
-    [[ -z ${!_var} || ! -d ${dracutsysrootdir}${!_var} ]] \
-        && export "$_var"="$($PKG_CONFIG "$_pkgconfig" --variable="$_pkgvar" 2> /dev/null)"
-    if [[ -z ${!_var} || ! -d ${dracutsysrootdir}${!_var} ]]; then
+    if [[ $_pkgvar == modversion ]]; then
+        local _vararg=--modversion
+    else
+        local _vararg=--variable=$_pkgvar
+    fi
+    [[ -z ${!_var} || ($3 == /* && ! -d ${dracutsysrootdir}${!_var}) ]] \
+        && export "$_var"="$($PKG_CONFIG "$_pkgconfig" "$_vararg" 2> /dev/null)"
+    if [[ -z ${!_var} || ($3 == /* && ! -d ${dracutsysrootdir}${!_var}) ]]; then
         shift 2
         if (($# == 1)); then
             export "$_var"="$1"
@@ -1550,6 +1555,7 @@ set_global_var "systemd" "sysusers" "/usr/lib/sysusers.d"
 set_global_var "systemd" "sysusersconfdir" "/etc/sysusers.d"
 set_global_var "systemd" "tmpfilesdir" "/lib/tmpfiles.d" "/usr/lib/tmpfiles.d"
 set_global_var "systemd" "tmpfilesconfdir" "/etc/tmpfiles.d"
+set_global_var "systemd" "modversion:systemdversion" "0"
 
 # libkmod global variables
 set_global_var "libkmod" "depmodd" "/usr/lib/depmod.d"