From bd519d88e4392d4a6c88c191202540e90db9ab60 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 13 Sep 2018 17:24:58 +0200 Subject: [PATCH 1/8] build: meson: support $DESTDIR in installation script Adapt the meson post-installation script to handle the $DESTDIR variable supplied by user to specify the installation target directory. While at it, convert the script to shell because it seems simpler to me. (cherry picked from commit 98b4a19a536ddb9f75611deaa272ae5661c5df4d) --- Makefile.am | 2 +- meson.build | 2 +- meson_post_install.py | 46 ------------------------------------- tools/meson-post-install.sh | 44 +++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 48 deletions(-) delete mode 100644 meson_post_install.py create mode 100755 tools/meson-post-install.sh diff --git a/Makefile.am b/Makefile.am index 5b0feefa40..e67a3d870c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4744,7 +4744,6 @@ EXTRA_DIST += \ valgrind.suppressions \ meson.build \ meson_options.txt \ - meson_post_install.py \ config.h.meson \ config-extra.h.meson \ docs/meson.build \ @@ -4785,6 +4784,7 @@ EXTRA_DIST += \ tools/check-exports.sh \ tools/create-exports-NetworkManager.sh \ tools/debug-helper.py \ + tools/meson-post-install.sh \ tools/run-nm-test.sh \ tools/test-networkmanager-service.py \ tools/test-sudo-wrapper.sh \ diff --git a/meson.build b/meson.build index e0da40e49e..c488e3c8e6 100644 --- a/meson.build +++ b/meson.build @@ -896,7 +896,7 @@ configure_file( ) meson.add_install_script( - 'meson_post_install.py', + join_paths('tools', 'meson-post-install.sh'), nm_datadir, nm_bindir, nm_pkgconfdir, diff --git a/meson_post_install.py b/meson_post_install.py deleted file mode 100644 index 16dbc42b95..0000000000 --- a/meson_post_install.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys - -if not os.environ.get('DESTDIR'): - datadir = sys.argv[1] - bindir = sys.argv[2] - pkgconfdir = sys.argv[3] - pkglibdir = sys.argv[4] - localstatedir = sys.argv[5] - - completions_dir = os.path.join(datadir, 'bash-completion', 'completions') - os.rename(os.path.join(completions_dir, 'nmcli-completion'), os.path.join(completions_dir, 'nmcli')) - - nmtui_alias = ['nmtui-connect', 'nmtui-edit', 'nmtui-hostname'] - src = os.path.join(bindir, 'nmtui') - [os.symlink(src, os.path.join(bindir, dst)) - for dst in nmtui_alias] - - dst_dirs = [ - os.path.join(pkgconfdir, 'conf.d'), - os.path.join(pkgconfdir, 'system-connections'), - os.path.join(pkgconfdir, 'dispatcher.d', 'no-wait.d'), - os.path.join(pkgconfdir, 'dispatcher.d', 'pre-down.d'), - os.path.join(pkgconfdir, 'dispatcher.d', 'pre-up.d'), - os.path.join(pkgconfdir, 'dnsmasq.d'), - os.path.join(pkgconfdir, 'dnsmasq-shared.d'), - os.path.join(pkglibdir, 'conf.d'), - os.path.join(pkglibdir, 'VPN'), - os.path.join(localstatedir, 'lib', 'NetworkManager') - ] - [os.makedirs(dst_dir) - for dst_dir in dst_dirs - if not os.path.exists(dst_dir)] - - if sys.argv[6] == 'install_docs': - mandir = sys.argv[7] - - src = os.path.join(mandir, 'man1', 'nmtui.1') - [os.symlink(src, os.path.join(mandir, 'man1', dst + '.1')) - for dst in nmtui_alias] - - src = os.path.join(mandir, 'man5', 'NetworkManager.conf.5') - dst = os.path.join(mandir, 'man5', 'nm-system-settings.conf.5') - os.symlink(src, dst) diff --git a/tools/meson-post-install.sh b/tools/meson-post-install.sh new file mode 100755 index 0000000000..fd21941bbd --- /dev/null +++ b/tools/meson-post-install.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +datadir=$1 +bindir=$2 +pkgconfdir=$3 +pkglibdir=$4 +localstatedir=$5 + +[ -n "$DESTDIR" ] && DESTDIR=${DESTDIR%%/}/ + +if [ -f "${DESTDIR}${datadir}/bash-completion/completions/nmcli-completion" ]; then + mv "${DESTDIR}${datadir}/bash-completion/completions/nmcli-completion" \ + "${DESTDIR}${datadir}/bash-completion/completions/nmcli" +fi + +if [ -x "${DESTDIR}${bindir}/nmtui" ]; then + for alias in nmtui-connect nmtui-edit nmtui-hostname; do + ln -sf nmtui "${DESTDIR}${bindir}/$alias" + done +fi + +for dir in "${pkgconfdir}/conf.d" \ + "${pkgconfdir}/system-connections" \ + "${pkgconfdir}/dispatcher.d/no-wait.d" \ + "${pkgconfdir}/dispatcher.d/pre-down.d" \ + "${pkgconfdir}/dispatcher.d/pre-up.d" \ + "${pkgconfdir}/dnsmasq.d" \ + "${pkgconfdir}/dnsmasq-shared.d" \ + "${pkgconfdir}/conf.d" \ + "${pkgconfdir}/VPN" \ + "${localstatedir}/lib/NetworkManager"; do + mkdir -p "${DESTDIR}${dir}" +done + +if [ "$6" = install_docs ]; then + mandir=$7 + + for alias in nmtui-connect nmtui-edit nmtui-hostname; do + ln -f "${DESTDIR}${mandir}/man1/nmtui.1" "${DESTDIR}${mandir}/man1/${alias}.1" + done + + ln -f "${DESTDIR}${mandir}/man5/NetworkManager.conf.5" "${DESTDIR}${mandir}/man5/nm-system-settings.conf" +fi + From 7f57600fce2ebe606b77e1ed4218fc4507132817 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 14 Sep 2018 15:33:47 +0200 Subject: [PATCH 2/8] build: meson: check vapi prerequisites and allow autodetection Turn the vapi option into a combo that allows autodetection and check whether all prerequisites are satisfied (including introspection support) when vapi is explicitly enabled. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/28 (cherry picked from commit 37954c91bd1a9a44cf7e21ca5019c959b84a722a) --- meson.build | 25 +++++++++++++++++++++---- meson_options.txt | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index c488e3c8e6..be3b142ae0 100644 --- a/meson.build +++ b/meson.build @@ -711,11 +711,27 @@ auto_support_src = 'int main() { int a = 0; __auto_type b = a; return b + a; };' config_h.set10('_NM_CC_SUPPORT_AUTO_TYPE', cc.compiles(auto_support_src)) # Vala bindings -enable_vapi = get_option('vapi') -if enable_vapi +vapi_opt = get_option('vapi') +if vapi_opt == 'false' + enable_vapi = false +else vala_req_version = '>= 0.17.1.24' - assert(add_languages('vala', required: false), 'vala is required to build. Use -Dvapi=false to disable it') - assert(meson.get_compiler('vala').version().version_compare(vala_req_version), 'vala ' + vala_req_version + ' is required to build. Use -Dvapi=false to disable it') + enable_vapi = true + + if not enable_introspection + assert(vapi_opt != 'true', 'vala api require GObject introspection. Use -Dvapi=false to disable it') + enable_vapi = false + endif + + if enable_vapi and not add_languages('vala', required: false) + assert(vapi_opt != 'true', 'vala is required to build. Use -Dvapi=false to disable it') + enable_vapi = false + endif + + if enable_vapi and not meson.get_compiler('vala').version().version_compare(vala_req_version) + assert(vapi_opt != 'true', 'vala ' + vala_req_version + ' is required to build. Use -Dvapi=false to disable it') + enable_vapi = false + endif endif # Tests, utilities and documentation @@ -979,4 +995,5 @@ output += ' JSON validation for libnm: ' + enable_json_validation.to_string() + output += ' crypto: ' + crypto + ' (have-gnutls: ' + crypto_gnutls_dep.found().to_string() + ', have-nss: ' + crypto_nss_dep.found().to_string() + ')\n' output += ' sanitizers: ' + get_option('b_sanitize') + '\n' output += ' Mozilla Public Suffix List: ' + enable_libpsl.to_string() + '\n' +output += ' vapi: ' + enable_vapi.to_string() + '\n' message(output) diff --git a/meson_options.txt b/meson_options.txt index 7f06d53a71..0f93d77f30 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -61,7 +61,7 @@ option('config_dhcp_default', type: 'combo', choices: ['dhcpcanon', 'dhclient', # miscellaneous option('introspection', type: 'boolean', value: true, description: 'Enable introspection for this build') -option('vapi', type: 'boolean', value: true, description: 'build Vala bindings') +option('vapi', type : 'combo', choices : ['auto', 'true', 'false'], description: 'build Vala bindings') option('docs', type: 'boolean', value: false, description: 'use to build documentation') option('tests', type: 'combo', choices: ['yes', 'no', 'root'], value: 'yes', description: 'Build NetworkManager tests') option('more_asserts', type: 'string', value: 'all', description: 'Enable more assertions for debugging (0 = none, 100 = all, default: all)') From bb892155af3c66ff0d571667de81c52b8f60401a Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 14 Sep 2018 17:41:09 +0200 Subject: [PATCH 3/8] build: meson: man files depend on common.ent (cherry picked from commit c8636449b3cf68d3ba8446dcef3f6dbecf48c3e4) --- man/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/meson.build b/man/meson.build index 044ddcaba4..929431668e 100644 --- a/man/meson.build +++ b/man/meson.build @@ -10,7 +10,7 @@ common_conf.set('NM_CONFIG_DEFAULT_MAIN_DHCP', config_dhcp_default) common = 'common.ent' -configure_file( +common_ent_file = configure_file( input: common + '.in', output: common, configuration: common_conf @@ -58,6 +58,7 @@ foreach man: mans input: input, output: output, command: xsltproc_options + [docbook_xls, '@INPUT@'], + depend_files: common_ent_file, install: true, install_dir: join_paths(nm_mandir, 'man' + man[1]) ) From b459ffbdd8ac6989ef68e890de2b674d190f32bb Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 14 Sep 2018 17:41:36 +0200 Subject: [PATCH 4/8] build: meson: gtk-doc needs common.ent (cherry picked from commit c06a6aec1a969dcb5ec2e2ce8ecfe270cfdedeba) --- man/meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/man/meson.build b/man/meson.build index 929431668e..41fbf583a6 100644 --- a/man/meson.build +++ b/man/meson.build @@ -47,6 +47,8 @@ if enable_ovs mans += [['nm-openvswitch', '7']] endif +content_files += join_paths(meson.current_build_dir(), 'common.ent') + foreach man: mans input = man[0] + '.xml' content_files += join_paths(meson.current_source_dir(), input) From fc22330c1c2afd44826ad0fa1978d3258610d099 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 14 Sep 2018 18:14:46 +0200 Subject: [PATCH 5/8] docs: include openvswitch(7) man page only when ovs is enabled (cherry picked from commit 6da369252a7b76cbbe38254ee9dd55cfc66723bd) --- docs/api/Makefile.am | 6 +++++- docs/api/network-manager-docs.xml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/api/Makefile.am b/docs/api/Makefile.am index 859aa20bc2..f48e132874 100644 --- a/docs/api/Makefile.am +++ b/docs/api/Makefile.am @@ -88,11 +88,15 @@ content_files = \ $(top_builddir)/man/nmcli-examples.xml \ $(top_builddir)/man/nm-settings.xml \ $(top_builddir)/man/nm-settings-keyfile.xml \ - $(top_builddir)/man/nm-openvswitch.xml \ version.xml \ ../../COPYING \ $(NULL) + +if WITH_OPENVSWITCH +content_files += $(top_builddir)/man/nm-openvswitch.xml +endif + if CONFIG_PLUGIN_IFCFG_RH content_files += $(top_builddir)/man/nm-settings-ifcfg-rh.xml endif diff --git a/docs/api/network-manager-docs.xml b/docs/api/network-manager-docs.xml index 9285744310..23d67db1e7 100644 --- a/docs/api/network-manager-docs.xml +++ b/docs/api/network-manager-docs.xml @@ -77,7 +77,7 @@ - + From 3711c31467fd0dd98eca55e9bb497b2085b1c58c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 18 Sep 2018 10:14:09 +0200 Subject: [PATCH 6/8] build: meson: fix computing NM exported symbols The script didn't include all the symbols needed by plugins because libNetworkManager.a, as built by meson, doesn't include symbols from other static libraries that are linked in. Since we used libNetworkManager.a to know which symbols are potentiall available from NM, the result was an incomplete list. Unfortunately, the only way to include the whole static library is to create a dependency object and use 'link_whole', but this is only available in meson >= 0.46. Since 'link_whole' is available for executables in meson >= 0.40, create a fake executable and use that to enumerate symbols. Also add tests to check that plugins can be loaded correctly. Fixes: dfa2a2b40c866bf7a5484b72639464c31b80e7da (cherry picked from commit 19a718bc13824eae925ece55d04ebc07cd00cf62) --- src/meson.build | 27 +++++++++++++++++++++++++- tools/create-exports-NetworkManager.sh | 7 ++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/meson.build b/src/meson.build index f46366a904..0a66647c25 100644 --- a/src/meson.build +++ b/src/meson.build @@ -252,11 +252,27 @@ subdir('settings/plugins') create_exports_networkmanager = join_paths(meson.source_root(), 'tools', 'create-exports-NetworkManager.sh') symbol_map_name = 'NetworkManager.ver' +# libNetworkManager.a, as built by meson doesn't contain all symbols +# from libNetworkManagerBase.a and other static libraries, unless we +# add dependencies with link_whole, only supported in meson >= 0.46. +# Create an executable with full symbols that we use in place of the +# library to enumerate the symbols. +network_manager_sym = executable( + 'nm-full-symbols', + 'main.c', + c_args: nm_cflags, + link_args: '-Wl,--no-gc-sections', + dependencies: nm_deps, + link_whole: [libnetwork_manager, libnetwork_manager_base, libnm_core], + install: false, +) + +# this uses symbols from nm-full-symbols instead of libNetworkManager.a ver_script = custom_target( symbol_map_name, input: meson.source_root(), output: symbol_map_name, - depends: [ libnetwork_manager, core_plugins ], + depends: [ network_manager_sym, core_plugins ], command: [create_exports_networkmanager, '--called-from-build', '@INPUT@'] ) @@ -273,3 +289,12 @@ network_manager = executable( install: true, install_dir: nm_sbindir ) + +if enable_tests + foreach plugin : core_plugins + test ('sym/' + plugin.full_path().split('/')[-1], + network_manager, + args: '--version', + env: ['LD_BIND_NOW=1', 'LD_PRELOAD=' + plugin.full_path()]) + endforeach +endif diff --git a/tools/create-exports-NetworkManager.sh b/tools/create-exports-NetworkManager.sh index c23203bf79..3c5789d884 100755 --- a/tools/create-exports-NetworkManager.sh +++ b/tools/create-exports-NetworkManager.sh @@ -35,7 +35,12 @@ call_nm() { } get_symbols_nm () { - call_nm ./src/${libs}libNetworkManager.a | + if [ -z "$from_meson" ]; then + base=./src/.libs/libNetworkManager.a + else + base=./src/nm-full-symbols + fi + call_nm "$base" | sed -n 's/^[tTDGRBS] //p' | _sort } From 6a815260dba692d40c83a22a5505607fb1855a81 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 18 Sep 2018 14:56:59 +0200 Subject: [PATCH 7/8] build: meson: GTK documentation requires introspection (cherry picked from commit 84701c049cfed8a8cf8a841100b6ce8b6be0d46e) --- meson.build | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index be3b142ae0..0d5ad7fa1c 100644 --- a/meson.build +++ b/meson.build @@ -864,11 +864,10 @@ if enable_qt endif enable_docs = get_option('docs') + if enable_docs + assert(enable_introspection, '-Ddocs=true requires -Dintrospection=true') subdir('man') - - #assert(enable_introspection, '-Dgtk_doc=true requires -Dintrospection=true') - subdir('docs') endif From fb432eec2578f3e0ca24a3d132dacfa782f6ff8e Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 18 Sep 2018 15:10:39 +0200 Subject: [PATCH 8/8] travis: disable gtk-doc for meson builds Introspection can't be enabled on travis due to a GLib bug [1]. Therefore, gtk-doc must be disabled as well. [1] https://bugzilla.gnome.org/show_bug.cgi?id=774368 (cherry picked from commit 5af7d46be49b581319e92296931f30af714d3c6d) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index de6ff770a0..c96bb9496a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -97,7 +97,7 @@ script: -D introspection=false \ -D qt=false \ -D crypto=$CRYPTO \ - -D docs=true \ + -D docs=false \ \ -D libnm_glib=true \ -D iwd=true \