From 1c2c7c6cb3d92315624f3711114e86b0acfbce63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 17 Nov 2018 15:38:15 +0100 Subject: [PATCH] pkgconfig: define variables relative to ${prefix}/${rootprefix}/${sysconfdir} Fixes #4549. People want to be able to redefine the prefixes relative to which the other variables are defined. Something like pkgconf --define-variable=prefix=/home/user/installpath --variable=systemdsystemunitdir systemd I'm not convinced that this entirely useful, because the installed systemd will not look at those paths, but maybe it's OK as an alternative type of $DESTDIR. This has been requested a few times over the years, so let's just provide this. I thought this would be more complicated, since we allow all kinds of directories to be overrides in the compilation configuration. But it turns out that all the directories defined in systemd.pc are relative to three prefixes: $prefix, $rootprefix, and $sysconfdir. So this patch adds $rootprefix and $sysconfdir to the .pc file and then changes the subsequent definitions in the .pc file to use them. In the end we define each path twice using the same rules: once in meson.build and once in the .pc file. Without overrides: $ for i in $(pkgconf --with-path=build/src/core systemd --print-variables); do echo -n "$i = "; pkgconf --with-path=$PWD/build/src/core --variable=$i systemd done containeruidbasemax = 1878982656 containeruidbasemin = 524288 dynamicuidmax = 65519 dynamicuidmin = 61184 systemgidmax = 999 systemuidmax = 999 catalogdir = /usr/lib/systemd/catalog modulesloaddir = /usr/lib/modules-load.d binfmtdir = /usr/lib/binfmt.d sysctldir = /usr/lib/sysctl.d sysusersdir = /usr/lib/sysusers.d tmpfilesdir = /usr/lib/tmpfiles.d systemdshutdowndir = /usr/lib/systemd/system-shutdown systemdsleepdir = /usr/lib/systemd/system-sleep systemdusergeneratordir = /usr/lib/systemd/user-generators systemdsystemgeneratordir = /usr/lib/systemd/system-generators systemduserunitpath = /etc/systemd/user:/etc/systemd/user:/run/systemd/user:/usr/local/lib/systemd/user:/usr/local/share/systemd/user:/usr/lib/systemd/user:/usr/lib/systemd/user:/usr/share/systemd/user systemdsystemunitpath = /etc/systemd/system:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:/usr/lib/systemd/system:/usr/lib/systemd/system:/lib/systemd/system systemduserconfdir = /etc/systemd/user systemdsystemconfdir = /etc/systemd/system systemduserpresetdir = /usr/lib/systemd/user-preset systemduserunitdir = /usr/lib/systemd/user systemdsystempresetdir = /usr/lib/systemd/system-preset systemdsystemunitdir = /usr/lib/systemd/system systemdutildir = /usr/lib/systemd sysconfdir = /etc rootprefix = /usr prefix = /usr pcfiledir = /usr/share/pkgconfig With overrides: $ for i in $(pkgconf --with-path=build/src/core systemd --print-variables); do echo -n "$i = "; pkgconf --with-path=$PWD/build/src/core \ --define-variable=prefix=/PREFIX \ --define-variable=rootprefix=/ROOTPREFIX \ --define-variable=sysconfdir=/SYSCONF --variable=$i systemd done containeruidbasemax = 1878982656 containeruidbasemin = 524288 dynamicuidmax = 65519 dynamicuidmin = 61184 systemgidmax = 999 systemuidmax = 999 catalogdir = /PREFIX/lib/systemd/catalog modulesloaddir = /PREFIX/lib/modules-load.d binfmtdir = /PREFIX/lib/binfmt.d sysctldir = /PREFIX/lib/sysctl.d sysusersdir = /PREFIX/lib/sysusers.d tmpfilesdir = /PREFIX/lib/tmpfiles.d systemdshutdowndir = /ROOTPREFIX/lib/systemd/system-shutdown systemdsleepdir = /ROOTPREFIX/lib/systemd/system-sleep systemdusergeneratordir = /PREFIX/lib/systemd/user-generators systemdsystemgeneratordir = /ROOTPREFIX/lib/systemd/system-generators systemduserunitpath = /SYSCONF/systemd/user:/etc/systemd/user:/run/systemd/user:/usr/local/lib/systemd/user:/usr/local/share/systemd/user:/PREFIX/lib/systemd/user:/usr/lib/systemd/user:/usr/share/systemd/user systemdsystemunitpath = /SYSCONF/systemd/system:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:/ROOTPREFIX/lib/systemd/system:/usr/lib/systemd/system:/lib/systemd/system systemduserconfdir = /SYSCONF/systemd/user systemdsystemconfdir = /SYSCONF/systemd/system systemduserpresetdir = /PREFIX/lib/systemd/user-preset systemduserunitdir = /PREFIX/lib/systemd/user systemdsystempresetdir = /ROOTPREFIX/lib/systemd/system-preset systemdsystemunitdir = /ROOTPREFIX/lib/systemd/system systemdutildir = /usr/lib/systemd sysconfdir = /SYSCONF rootprefix = /ROOTPREFIX prefix = /PREFIX pcfiledir = /usr/share/pkgconfig (pkgconf doesn't provide a way to print all variables together with their definitions, according to the man page. Disappointing.) --- meson.build | 3 ++- src/core/systemd.pc.in | 36 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/meson.build b/meson.build index ccea945720..9c788979b3 100644 --- a/meson.build +++ b/meson.build @@ -235,11 +235,12 @@ conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_ conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no') substs.set('prefix', prefixdir) +substs.set('rootprefix', rootprefixdir) substs.set('exec_prefix', prefixdir) substs.set('libdir', libdir) substs.set('rootlibdir', rootlibdir) substs.set('includedir', includedir) -substs.set('pkgsysconfdir', pkgsysconfdir) +substs.set('sysconfdir', sysconfdir) substs.set('bindir', bindir) substs.set('rootbindir', rootbindir) substs.set('rootlibexecdir', rootlibexecdir) diff --git a/src/core/systemd.pc.in b/src/core/systemd.pc.in index 655773ea8a..2502d80ada 100644 --- a/src/core/systemd.pc.in +++ b/src/core/systemd.pc.in @@ -8,25 +8,27 @@ # (at your option) any later version. prefix=@prefix@ -systemdutildir=@rootlibexecdir@ -systemdsystemunitdir=@systemunitdir@ -systemdsystempresetdir=@systempresetdir@ -systemduserunitdir=@userunitdir@ -systemduserpresetdir=@userpresetdir@ -systemdsystemconfdir=@pkgsysconfdir@/system -systemduserconfdir=@pkgsysconfdir@/user +rootprefix=@rootprefix@ +sysconfdir=@sysconfdir@ +systemdutildir=${rootprefix}/lib/systemd +systemdsystemunitdir=${rootprefix}/lib/systemd/system +systemdsystempresetdir=${rootprefix}/lib/systemd/system-preset +systemduserunitdir=${prefix}/lib/systemd/user +systemduserpresetdir=${prefix}/lib/systemd/user-preset +systemdsystemconfdir=${sysconfdir}/systemd/system +systemduserconfdir=${sysconfdir}/systemd/user systemdsystemunitpath=${systemdsystemconfdir}:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:${systemdsystemunitdir}:/usr/lib/systemd/system:/lib/systemd/system systemduserunitpath=${systemduserconfdir}:/etc/systemd/user:/run/systemd/user:/usr/local/lib/systemd/user:/usr/local/share/systemd/user:${systemduserunitdir}:/usr/lib/systemd/user:/usr/share/systemd/user -systemdsystemgeneratordir=@systemgeneratordir@ -systemdusergeneratordir=@usergeneratordir@ -systemdsleepdir=@systemsleepdir@ -systemdshutdowndir=@systemshutdowndir@ -tmpfilesdir=@tmpfilesdir@ -sysusersdir=@sysusersdir@ -sysctldir=@sysctldir@ -binfmtdir=@binfmtdir@ -modulesloaddir=@modulesloaddir@ -catalogdir=@catalogdir@ +systemdsystemgeneratordir=${rootprefix}/lib/systemd/system-generators +systemdusergeneratordir=${prefix}/lib/systemd/user-generators +systemdsleepdir=${rootprefix}/lib/systemd/system-sleep +systemdshutdowndir=${rootprefix}/lib/systemd/system-shutdown +tmpfilesdir=${prefix}/lib/tmpfiles.d +sysusersdir=${prefix}/lib/sysusers.d +sysctldir=${prefix}/lib/sysctl.d +binfmtdir=${prefix}/lib/binfmt.d +modulesloaddir=${prefix}/lib/modules-load.d +catalogdir=${prefix}/lib/systemd/catalog systemuidmax=@systemuidmax@ systemgidmax=@systemgidmax@ dynamicuidmin=@dynamicuidmin@