We currently hardcode the systemd unitdir, but it is desirable to be able to choose a different location in some cases. For examples, Fedora flatpak builds change the RPM %_unitdir macro, but we can't currently honour that. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- libvirt.spec.in | 1 + meson.build | 5 +++++ meson_options.txt | 1 + src/meson.build | 8 +++----- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index 1d3240ee6f..0a121515b9 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1329,6 +1329,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec) %meson \ -Drunstatedir=%{_rundir} \ -Dinitconfdir=%{_sysconfdir}/sysconfig \ + -Dunitdir=%{_unitdir} \ %{?arg_qemu} \ %{?arg_openvz} \ %{?arg_lxc} \ diff --git a/meson.build b/meson.build index 62e49be37d..295613fd93 100644 --- a/meson.build +++ b/meson.build @@ -95,6 +95,11 @@ if initconfdir == '' endif endif +unitdir = get_option('unitdir') +if unitdir == '' + unitdir = prefix / 'lib' / 'systemd' / 'system' +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 cdc8687795..a4f1dd769f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,6 +4,7 @@ option('packager_version', type: 'string', value: '', description: 'Extra packag option('system', type: 'boolean', value: false, description: 'Set install paths to system ones') 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') # 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/meson.build b/src/meson.build index dd2682ec19..8cce42c7ad 100644 --- a/src/meson.build +++ b/src/meson.build @@ -812,11 +812,9 @@ endforeach if conf.has('WITH_LIBVIRTD') # Generate systemd service and socket unit files if init_script == 'systemd' - systemd_unit_dir = prefix / 'lib' / 'systemd' / 'system' - install_data( guest_unit_files, - install_dir: systemd_unit_dir, + install_dir: unitdir, ) if conf.has('WITH_POLKIT') @@ -855,7 +853,7 @@ if conf.has('WITH_LIBVIRTD') output: service_out, configuration: unit_conf, install: true, - install_dir: systemd_unit_dir, + install_dir: unitdir, ) foreach socket : unit.get('sockets', [ 'main', 'ro', 'admin' ]) @@ -881,7 +879,7 @@ if conf.has('WITH_LIBVIRTD') output: socket_out, configuration: unit_conf, install: true, - install_dir: systemd_unit_dir, + install_dir: unitdir, ) endforeach endforeach -- 2.43.0