build: meson: uniform handling of rc managers

Handle all rc managers paths through the same code.
This commit is contained in:
Beniamino Galvani 2018-09-07 17:12:31 +02:00
parent 36b0e46146
commit 2fd7559819
2 changed files with 36 additions and 43 deletions

View file

@ -579,39 +579,41 @@ if enable_ovs
assert(jansson_dep.found(), 'jansson is needed for OpenVSwitch integration. Use -Dovs=false to disable it')
endif
# resolvconf and netconfig support
locations = get_option('resolvconf')
enable_resolvconf = (locations != ['no'])
if enable_resolvconf
resolvconf = find_program(locations, required: false)
enable_resolvconf = resolvconf.found()
if enable_resolvconf
config_h.set_quoted('RESOLVCONF_PATH', resolvconf.path())
endif
endif
locations = get_option('netconfig')
enable_netconfig = (locations != ['no'])
if enable_netconfig
netconfig = find_program(locations, required: false)
enable_netconfig = netconfig.found()
if enable_netconfig
config_h.set_quoted('NETCONFIG_PATH', netconfig.path())
endif
endif
# DNS resolv.conf managers
config_dns_rc_manager_default = get_option('config_dns_rc_manager_default')
if config_dns_rc_manager_default == 'resolvconf' and not enable_resolvconf
error(config_dns_rc_manager_default + ' has not been enabled. Please don\'t disable it or use another configuration option for main.rc-manager setting')
endif
if config_dns_rc_manager_default == 'netconfig' and not enable_netconfig
error(config_dns_rc_manager_default + ' has not been enabled. Please don\'t disable it or use another configuration option for main.rc-manager setting')
endif
config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_RC_MANAGER', config_dns_rc_manager_default)
resolv_conf_summary = ''
foreach prog_name : ['resolvconf', 'netconfig']
prog_path = get_option(prog_name)
prog_enable = (prog_path != 'no')
if prog_enable
if prog_path == ''
prog = find_program(prog_name,
'/usr/' + prog_name,
'/usr/sbin/' + prog_name,
'/usr/local/sbin' + prog_name,
required : false)
if prog.found()
prog_path = prog.path()
else
prog_enable = false
endif
endif
endif
if prog_enable
config_h.set_quoted(prog_name.to_upper() + '_PATH', prog_path)
elif config_dns_rc_manager_default == prog_name
error(prog_name + ' has not been enabled. Please don\'t disable it or use another configuration option for main.rc-manager setting')
endif
resolv_conf_summary += ' ' + prog_name + ': ' + prog_enable.to_string()
if prog_enable
resolv_conf_summary += ' ' + prog_path
endif
resolv_conf_summary += '\n'
endforeach
# external misc tools paths
default_paths = ['/sbin', '/usr/sbin']
@ -951,16 +953,7 @@ output += '\nConfiguration_plugins (main.plugins=' + config_plugins_default + ')
output += ' ibft: ' + enable_ibft.to_string() + '\n'
output += ' ifcfg-rh: ' + enable_ifcfg_rh.to_string() + '\n'
output += ' ifupdown: ' + enable_ifupdown.to_string() + '\n'
output += '\nHandlers for /etc/resolv.conf:\n'
output += ' resolvconf: ' + enable_resolvconf.to_string()
if enable_resolvconf
output += ' ' + resolvconf.path()
endif
output += '\n'
output += ' netconfig: ' + enable_netconfig.to_string()
if enable_netconfig
output += ' ' + netconfig.path()
endif
output += '\nHandlers for /etc/resolv.conf:\n' + resolv_conf_summary
output += '\n'
output += ' config-dns-rc-manager-default: ' + config_dns_rc_manager_default + '\n'
output += '\nDHCP clients (default ' + config_dhcp_default + '):\n' + dhcp_summary

View file

@ -49,8 +49,8 @@ option('ifcfg_rh', type: 'boolean', value: false, description: 'enable ifcfg-rh
option('ifupdown', type: 'boolean', value: false, description: 'enable ifupdown configuration plugin (Debian/Ubuntu)')
# handlers for resolv.conf
option('resolvconf', type: 'array', value: ['resolvconf', '/sbin/resolvconf', '/usr/sbin/resolvconf', '/usr/local/sbin/resolvconf'], description: 'Enable resolvconf support')
option('netconfig', type: 'array', value: ['netconfig', '/sbin/netconfig', '/usr/sbin/netconfig', '/usr/local/sbin/netconfig'], description: 'Enable SUSE netconfig support')
option('resolvconf', type: 'string', value: '', description: 'Enable resolvconf support')
option('netconfig', type: 'string', value: '', description: 'Enable SUSE netconfig support')
option('config_dns_rc_manager_default', type: 'combo', choices: ['symlink', 'file', 'netconfig', 'resolvconf'], value: 'symlink', description: 'Configure default value for main.rc-manager setting')
# dhcp clients