[PATCH] meson: allow systemd sysusersdir to be changed

Daniel P. Berrangé posted 1 patch 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20240607204808.767903-1-berrange@redhat.com
There is a newer version of this series
libvirt.spec.in      | 1 +
meson.build          | 5 +++++
meson_options.txt    | 1 +
src/qemu/meson.build | 2 +-
4 files changed, 8 insertions(+), 1 deletion(-)
[PATCH] meson: allow systemd sysusersdir to be changed
Posted by Daniel P. Berrangé 3 months ago
We currently hardcode the systemd sysusersdir, but it is desirable to be
able to choose a different location in some cases. For example, Fedora
flatpak builds change the RPM %_sysusersdir macro, but we can't currently
honour that.

Reported-by: Yaakov Selkowitz <yselkowi@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 libvirt.spec.in      | 1 +
 meson.build          | 5 +++++
 meson_options.txt    | 1 +
 src/qemu/meson.build | 2 +-
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 244e5e824c..347a609add 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1328,6 +1328,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec)
            -Drunstatedir=%{_rundir} \
            -Dinitconfdir=%{_sysconfdir}/sysconfig \
            -Dunitdir=%{_unitdir} \
+           -Dsysusersdir=%{_sysusersdir} \
            %{?arg_qemu} \
            %{?arg_openvz} \
            %{?arg_lxc} \
diff --git a/meson.build b/meson.build
index 295613fd93..2fc9ab3e96 100644
--- a/meson.build
+++ b/meson.build
@@ -100,6 +100,11 @@ if unitdir == ''
   unitdir = prefix / 'lib' / 'systemd' / 'system'
 endif
 
+sysusersdir = getoption('sysusersdir')
+if sysusersdir == ''
+  sysusersdir = prefix / 'lib' / 'sysusers.d'
+endif
+
 bindir = prefix / get_option('bindir')
 datadir = prefix / get_option('datadir')
 includedir = prefix / get_option('includedir')
diff --git a/meson_options.txt b/meson_options.txt
index a4f1dd769f..50d71427cb 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -5,6 +5,7 @@ option('system', type: 'boolean', value: false, description: 'Set install paths
 option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc')
 option('initconfdir', type: 'string', value: '', description: 'directory for init script configuration files')
 option('unitdir', type: 'string', value: '', description: 'directory for systemd unit files')
+option('sysusersdir', type: 'string', value: '', description: 'directory for sysusers files')
 # dep:tests
 option('expensive_tests', type: 'feature', value: 'auto', description: 'set the default for enabling expensive tests (long timeouts)')
 option('test_coverage', type: 'boolean', value: false, description: 'turn on code coverage instrumentation')
diff --git a/src/qemu/meson.build b/src/qemu/meson.build
index 907893d431..57356451e4 100644
--- a/src/qemu/meson.build
+++ b/src/qemu/meson.build
@@ -163,7 +163,7 @@ if conf.has('WITH_QEMU')
   # Install the sysuser config for the qemu driver
   install_data(
     'libvirt-qemu.sysusers.conf',
-    install_dir: prefix / 'lib' / 'sysusers.d',
+    install_dir: sysusersdir,
     rename: [ 'libvirt-qemu.conf' ],
   )
 
-- 
2.43.0
Re: [PATCH] meson: allow systemd sysusersdir to be changed
Posted by Yaakov Selkowitz 3 months ago
On 6/7/24 16:48, Daniel P. Berrangé wrote:
> We currently hardcode the systemd sysusersdir, but it is desirable to be
> able to choose a different location in some cases. For example, Fedora
> flatpak builds change the RPM %_sysusersdir macro, but we can't currently
> honour that.
> 
> Reported-by: Yaakov Selkowitz <yselkowi@redhat.com>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   libvirt.spec.in      | 1 +
>   meson.build          | 5 +++++
>   meson_options.txt    | 1 +
>   src/qemu/meson.build | 2 +-
>   4 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index 295613fd93..2fc9ab3e96 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -100,6 +100,11 @@ if unitdir == ''
>     unitdir = prefix / 'lib' / 'systemd' / 'system'
>   endif
>   
> +sysusersdir = getoption('sysusersdir')

s/getoption/get_option/

> +if sysusersdir == ''
> +  sysusersdir = prefix / 'lib' / 'sysusers.d'
> +endif
> +
>   bindir = prefix / get_option('bindir')
>   datadir = prefix / get_option('datadir')
>   includedir = prefix / get_option('includedir')

-- 
Yaakov Selkowitz
Principal Software Engineer, Emerging RHEL
Red Hat, Inc.