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

Martin Wilck mwilck at suse.com
Thu Mar 7 19:20:41 UTC 2019


On Thu, 2019-03-07 at 19:22 +0100, Xose Vazquez Perez wrote:
> On 3/7/19 3:54 PM, Martin Wilck wrote:
> > 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.
> 
> 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


> 
> > 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
> >  
> > 
> 
> From a4dbf985b2440f8bb0210b90aaf549030e274b4f Mon Sep 17 00:00:00
> 2001
> From: Igor Gnatenko <ignatenkobrain at fedoraproject.org>
> Date: Mon, 18 Feb 2019 00:09:17 +0100
> Subject: [PATCH] Fix systemd version detection
> 
> Signed-off-by: Igor Gnatenko <ignatenkobrain at fedoraproject.org>
> ---
>  Makefile.inc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile.inc b/Makefile.inc
> index fc728ca..5b2f6d4 100644
> --- a/Makefile.inc
> +++ b/Makefile.inc
> @@ -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
> 

-- 
Dr. Martin Wilck <mwilck at suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)





More information about the dm-devel mailing list