meson.build: allow explicit distrosysconfdir

Allows either:

- Build inside minimal-and-clean chroot with neither
  /etc/sysconfig nor /etc/default available.
- Cross Compile lxc from foreign distro,
  let's say host distro uses /etc/sysconfig and build distro
  uses /etc/default and vice versus.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
This commit is contained in:
Đoàn Trần Công Danh 2022-08-09 22:24:09 +07:00
parent cbbb09b56f
commit 16ebb29dcc
2 changed files with 9 additions and 2 deletions

View File

@ -117,14 +117,18 @@ conf.set('SYSCONFDIR', sysconfdir)
# Set sysconfdir
fs = import('fs')
if fs.is_dir('/etc/sysconfig')
distrosysconfdir = get_option('distrosysconfdir')
if distrosysconfdir != ''
distrosysconfdir = join_paths(sysconfdir, distrosysconfdir)
conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
elif fs.is_dir('/etc/sysconfig')
distrosysconfdir = join_paths(sysconfdir, 'sysconfig')
conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
elif fs.is_dir('/etc/default')
distrosysconfdir = join_paths(sysconfdir, 'default')
conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
else
distrosysconfdir = ''
error('"distrosysconfdir" is not set')
endif
# Cross-compile on Android.

View File

@ -115,3 +115,6 @@ option('thread-safety', type : 'boolean', value : 'true',
# was --{disable,enable}-memfd-rexec in autotools
option('memfd-rexec', type : 'boolean', value : 'true',
description : 'whether to rexec the lxc-attach binary when attaching to a container')
option('distrosysconfdir', type : 'string', value: '',
description: 'relative path to sysconfdir for distro default configuration')