build/meson: fix autodetecting ifcfg_rh/ifupdown plugins

"-Difcfg_rh=false" did not work, we would always fallback to
autodetection. That is wrong, an explicit "false" should be honored.
It's also not what autotools does. Fix this.

While at it, drop "distro" variable. It's not a clear concept
that can be reused and it's unused otherwise.

Also, no longer let the autodetection be based on cross compilation.
When cross-compiling, it seems not entirely unreasonable that you cross
compile to a comparable distro, so let the autodetection be based on
what we detect on the host. In any case, a user can and is encouraged
to explicitly enable/disable the plugins via "-Difcfg_rh=" or
"-Difupdown=".

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1310
This commit is contained in:
Thomas Haller 2022-07-22 13:04:52 +02:00
parent 077d6503ad
commit b38d180bc6
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 13 additions and 16 deletions

View file

@ -287,22 +287,19 @@ glib_dep = declare_dependency(
]
)
if meson.is_cross_build()
distro = 'unknown'
elif run_command('test', '-e', '/etc/sysconfig/network-scripts').returncode() == 0
distro = 'redhat'
elif run_command('test', '-e', '/etc/SuSE-release').returncode() == 0
distro = 'suse'
elif run_command('test', '-e', '/etc/debian_version').returncode() == 0
distro = 'debian'
elif run_command('test', '-e', '/etc/gentoo-release').returncode() == 0
distro = 'gentoo'
enable_ifcfg_rh = get_option('ifcfg_rh')
if enable_ifcfg_rh == 'auto'
enable_ifcfg_rh = (run_command('test', '-e', '/etc/sysconfig/network-scripts').returncode() == 0)
else
distro = 'unknown'
enable_ifcfg_rh = (enable_ifcfg_rh != 'false')
endif
enable_ifcfg_rh = get_option('ifcfg_rh') or (distro == 'redhat')
enable_ifupdown = get_option('ifupdown') or (distro == 'debian')
enable_ifupdown = get_option('ifupdown')
if enable_ifupdown == 'auto'
enable_ifupdown = (run_command('test', '-e', '/etc/debian_version').returncode() == 0)
else
enable_ifupdown = (enable_ifupdown != 'false')
endif
config_plugins_default = get_option('config_plugins_default')
config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_PLUGINS', config_plugins_default)

View file

@ -40,12 +40,12 @@ option('nmcli', type: 'boolean', value: true, description: 'Build nmcli')
option('nmtui', type: 'boolean', value: true, description: 'Build nmtui')
option('nm_cloud_setup', type: 'boolean', value: false, description: 'Build nm-cloud-setup, a tool for automatically configure networking in cloud (EXPERIMENTAL!)')
option('bluez5_dun', type: 'boolean', value: false, description: 'enable Bluez5 DUN support')
option('ebpf', type: 'combo', choices : ['auto', 'true', 'false'], description: 'Enable eBPF support')
option('ebpf', type: 'combo', choices: ['auto', 'true', 'false'], description: 'Enable eBPF support')
# configuration plugins
option('config_plugins_default', type: 'string', value: '', description: 'Default configuration option for main.plugins setting, used as fallback if the configuration option is unset')
option('ifcfg_rh', type: 'boolean', value: false, description: 'enable ifcfg-rh configuration plugin (Fedora/RHEL)')
option('ifupdown', type: 'boolean', value: false, description: 'enable ifupdown configuration plugin (Debian/Ubuntu)')
option('ifcfg_rh', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'enable ifcfg-rh configuration plugin (Fedora/RHEL)')
option('ifupdown', type: 'combo', choices:['auto', 'true', 'false'], value: 'auto', description: 'enable ifupdown configuration plugin (Debian/Ubuntu)')
# handlers for resolv.conf
option('resolvconf', type: 'string', value: '', description: 'Enable resolvconf support')