multipath-tools: Build: properly parse systemd's version
Subsystems (2)
PATCH 1/1 multipath-tools: Build: properly parse systemd's version
From: Dominique Leuenberger <[email protected]>
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.
--- Makefile.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Makefile.inc +7 -2
@@ -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
Signature · 1 line
2.21.0
Quoted 9 lines · Martin Wilck
From: Dominique Leuenberger <[email protected]>
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.
There is a simpler patch in Fedora, see below.
Quoted 16 lines
Signed-off-by Martin Wilck <[email protected]>--- Makefile.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)Makefile.inc +0
-2@@ -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')
Makefile.inc ifndef RUN · line 48
Quoted 10 lines
Makefile.inc +7
-0+ 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
From a4dbf985b2440f8bb0210b90aaf549030e274b4f Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <[email protected]>
Date: Mon, 18 Feb 2019 00:09:17 +0100
Subject: [PATCH] Fix systemd version detection
--- Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.inc +1 -1
@@ -37,7 +37,7 @@ 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') + SYSTEMD = $(shell systemctl --version 2> /dev/null | sed -n 's/systemd \([0-9]*\).*/\1/p') endif endif
Signature · 1 line
2.20.1
Quoted 12 lines · Xose Vazquez Perez
Quoted 11 lines · Martin Wilck
From: Dominique Leuenberger <[email protected]>
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.
Quoted 6 lines
Quoted 4 lines
Try to retrieve the version from pkg-config instead, and if that fails,
discard anything after the first number in "systemctl --version" output.There is a simpler patch in Fedora, see below.
Which is equivalent to the "else" clause of my patch, thanks for pointing it out.
But pkg-config should be the way to go in the future, so why not use it if we can?
Martin
Quoted 60 lines
Quoted 28 lines
Signed-off-by Martin Wilck <[email protected]>--- Makefile.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)Makefile.inc +4
-2@@ -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)
Makefile.inc +1
-0+ SYSTEMD = $(shell systemctl --version 2>
/dev/null| \Makefile.inc
Quoted 4 lines
Makefile.inc +2
-0+ sed -n 's/systemd \([0-9]*\).*/\1/p') + endif endif endifFrom
a4dbf985b2440f8bb0210b90aaf549030e274b4fMon Sep 17 00:00:00 2001
From: Igor Gnatenko <[email protected]>
Date: Mon, 18 Feb 2019 00:09:17 +0100
Subject: [PATCH] Fix systemd version detectionSigned-off-by Igor Gnatenko <[email protected]>--- Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Makefile.inc +1
-1@@ -37,7 +37,7 @@ 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') + SYSTEMD = $(shell systemctl --version 2> /dev/null | sed -n 's/systemd \([0-9]*\).*/\1/p')endif
endif
Signature · 9 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107 SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 18 lines · Martin Wilck
Quoted 17 lines · Xose Vazquez Perez
Quoted 15 lines · Martin Wilck
From: Dominique Leuenberger <[email protected]>
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.
Quoted 7 lines
Quoted 1 line
There is a simpler patch in Fedora, see below.
Which is equivalent to the "else" clause of my patch, thanks for pointing it out.
But pkg-config should be the way to go in the future, so why not use it if we can?
I agree.