meson: allow systemd unitdir to be changed

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.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2024-06-06 12:57:08 +01:00
parent 6569ded5de
commit a7eb7de531
4 changed files with 10 additions and 5 deletions

View File

@ -1327,6 +1327,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} \

View File

@ -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')

View File

@ -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')

View File

@ -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