[dm-devel] [PATCH RESEND 1/3] multipath-tools: Build: properly parse systemd's version

Martin Wilck mwilck at suse.com
Thu Apr 11 10:27:12 UTC 2019


From: Dominique Leuenberger <dimstar at opensuse.org>

Since systemd 241, systemctl --version no longer 'just' prints out the
version, but gives more information like git commit ref and whatnot. In
it's shortest form, it gives something like "systemd 241 (241)", which when
passed as parameter "-DUSE_SYSTEMD=241 (241)" results in shell errors.

Try to retrieve the version from pkg-config instead, and if that fails,
discard anything after the first number in "systemctl --version" output.

Acked-by: Benjamin Marzinski <bmarzins at redhat.com>
Acked-by: Xose Vazquez Perez <xose.vazquez at gmail.com>
Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 Makefile.inc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index fc728ca9..56c3eda0 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -36,8 +36,13 @@ ifndef RUN
 endif
 
 ifndef SYSTEMD
-	ifeq ($(shell systemctl --version > /dev/null 2>&1 && echo 1), 1)
-		SYSTEMD = $(shell systemctl --version 2> /dev/null |  sed -n 's/systemd \([0-9]*\)/\1/p')
+	ifeq ($(shell pkg-config --modversion libsystemd >/dev/null 2>&1 && echo 1), 1)
+		SYSTEMD = $(shell pkg-config --modversion libsystemd)
+	else
+		ifeq ($(shell systemctl --version >/dev/null 2>&1 && echo 1), 1)
+			SYSTEMD = $(shell systemctl --version 2> /dev/null | \
+				sed -n 's/systemd \([0-9]*\).*/\1/p')
+		endif
 	endif
 endif
 
-- 
2.21.0




More information about the dm-devel mailing list