meson: Check for os-release's ID_LIKE in addition to ID

This makes it possible to reduce the number of cases we have to
consider, because 'sles' declares itself to be like 'suse' and
both 'rhel' and 'centos' declare themselves to be like 'fedora'.

We have to move the check for Ubuntu before the one for Debian,
however, because 'ubuntu' declares itself to be like 'debian'
and it would end up with the wrong defaults otherwise.

Suggested-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrea Bolognani 2022-01-26 15:09:52 +01:00
parent ab10207c3b
commit d36ba5fa71

View File

@ -1671,24 +1671,23 @@ if not get_option('driver_qemu').disabled()
qemu_user = 'root' qemu_user = 'root'
qemu_group = 'wheel' qemu_group = 'wheel'
else else
os_release = run_command('grep', '^ID=', '/etc/os-release', check: false).stdout() os_release = run_command('grep', '-E', '^ID(_LIKE)*=', '/etc/os-release', check: false).stdout()
if os_release.contains('arch') if os_release.contains('arch')
qemu_user = 'nobody' qemu_user = 'nobody'
qemu_group = 'nobody' qemu_group = 'nobody'
elif (os_release.contains('centos') or # RHEL and CentOS both have ID_LIKE=fedora, SLES has ID_LIKE=suse
os_release.contains('fedora') or elif (os_release.contains('fedora') or
os_release.contains('gentoo') or os_release.contains('gentoo') or
os_release.contains('rhel') or
os_release.contains('sles') or
os_release.contains('suse')) os_release.contains('suse'))
qemu_user = 'qemu' qemu_user = 'qemu'
qemu_group = 'qemu' qemu_group = 'qemu'
elif os_release.contains('debian') # Ubuntu has ID_LIKE=debian so we need to handle it first
qemu_user = 'libvirt-qemu'
qemu_group = 'libvirt-qemu'
elif os_release.contains('ubuntu') elif os_release.contains('ubuntu')
qemu_user = 'libvirt-qemu' qemu_user = 'libvirt-qemu'
qemu_group = 'kvm' qemu_group = 'kvm'
elif os_release.contains('debian')
qemu_user = 'libvirt-qemu'
qemu_group = 'libvirt-qemu'
else else
qemu_user = 'root' qemu_user = 'root'
qemu_group = 'root' qemu_group = 'root'