From e860a2e09cc1ae078b51ccda60eec24d5406ec1c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 7 Sep 2018 16:52:09 +0200 Subject: [PATCH] build: meson: fix setting iptables/dnsmasq/dnssec-trigger paths Handle the iptables, dnsmasq and dnssec-trigger paths in the same way through common code. The path set by user must be accepted as is, even if does not exist, because this is a requirement for cross-compilation. When user does not specify a path, search a predefined set of paths and fall back to an hardcoded one. (cherry picked from commit 220dea0948a22dfbdddb91ed76a23ae20d2c5810) --- meson.build | 37 ++++++++++++++++++++++++++----------- meson_options.txt | 6 +++--- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index 3902dda1d..7806c5308 100644 --- a/meson.build +++ b/meson.build @@ -652,19 +652,34 @@ endif config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_RC_MANAGER', config_dns_rc_manager_default) -# iptables path -config_h.set_quoted('IPTABLES_PATH', find_program(get_option('iptables')).path()) +# external misc tools paths +default_paths = ['/sbin', '/usr/sbin'] +dnssec_ts_paths = ['/usr/local/libexec', + '/usr/local/lib', + '/usr/local/lib/dnssec-trigger', + '/usr/libexec', + '/usr/lib', + '/usr/lib/dnssec-trigger'] -# dnsmasq path -config_h.set_quoted('DNSMASQ_PATH', find_program(get_option('dnsmasq')).path()) +# 0: cmdline option, 1: paths, 2: fallback, 3: config.h option +progs = [['iptables', default_paths, '/sbin/iptables'], + ['dnsmasq', default_paths, ''], + ['dnssec_trigger', dnssec_ts_paths, join_paths(nm_libexecdir, 'dnssec-trigger-script'), 'DNSSEC_TRIGGER_SCRIPT'], + ] -# dnssec-trigger-script path -dnssec_trigger_script = find_program(get_option('dnssec_trigger'), required: false) -if dnssec_trigger_script.found() - config_h.set_quoted('DNSSEC_TRIGGER_SCRIPT', dnssec_trigger_script.path()) -else - config_h.set_quoted('DNSSEC_TRIGGER_SCRIPT', join_paths(nm_libexecdir, 'dnssec-trigger-script')) -endif +foreach prog : progs + path = get_option(prog[0]) + if path == '' + search_paths = [ prog[0] ] + foreach path : prog[1] + search_paths += (path + '/' + prog[0]) + endforeach + exe = find_program(search_paths, required : false) + path = exe.found() ? exe.path() : prog[2] + endif + name = prog.length() > 3 ? prog[3] : (prog[0].to_upper() + '_PATH') + config_h.set_quoted(name, path) +endforeach # system CA certificates path system_ca_path = get_option('system_ca_path') diff --git a/meson_options.txt b/meson_options.txt index 25ec7ae4e..6bd1eec3c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -7,9 +7,9 @@ option('dbus_ifaces_dir', type: 'string', value: '', description: 'where D-Bus i option('dbus_sys_dir', type: 'string', value: '', description: 'where D-Bus system service directory is') option('polkit_dir', type: 'string', value: '', description: 'where PolicyKit policy directory is') option('kernel_firmware_dir', type: 'string', value: '/lib/firmware', description: 'where kernel firmware directory is (default is /lib/firmware)') -option('iptables', type: 'array', value: ['iptables', '/sbin/iptables', '/usr/sbin/iptables'], description: 'path to iptables') -option('dnsmasq', type: 'array', value: ['dnsmasq', '/sbin/dnsmasq', '/usr/sbin/dnsmasq'], description: 'path to dnsmasq') -option('dnssec_trigger', type: 'array', value: ['dnssec-trigger-script', '/usr/local/libexec/dnssec-trigger-script', '/usr/local/lib/dnssec-trigger-script', '/usr/local/lib/dnssec-trigger/dnssec-trigger-script', '/usr/libexec/dnssec-trigger-script', '/usr/lib/dnssec-trigger-script', '/usr/lib/dnssec-trigger/dnssec-trigger-script'], description: 'path to unbound dnssec-trigger-script') +option('iptables', type: 'string', value: '', description: 'path to iptables') +option('dnsmasq', type: 'string', value: '', description: 'path to dnsmasq') +option('dnssec_trigger', type: 'string', value: '', description: 'path to unbound dnssec-trigger-script') # platform option('dist_version', type: 'string', value: '', description: 'Define the NM\'s distribution version string')