networkmanager: port to Meson (#59916)

networkmanager: port to Meson

authored by Jan Tojnar and committed by GitHub 60b38282 f0089b06

+112 -49
+21
pkgs/build-support/libredirect/libredirect.c
··· 91 91 return open64_real(rewrite(path, buf), flags, mode); 92 92 } 93 93 94 + int openat(int dirfd, const char * path, int flags, ...) 95 + { 96 + int (*openat_real) (int, const char *, int, mode_t) = dlsym(RTLD_NEXT, "openat"); 97 + mode_t mode = 0; 98 + if (flags & O_CREAT) { 99 + va_list ap; 100 + va_start(ap, flags); 101 + mode = va_arg(ap, mode_t); 102 + va_end(ap); 103 + } 104 + char buf[PATH_MAX]; 105 + return openat_real(dirfd, rewrite(path, buf), flags, mode); 106 + } 107 + 94 108 FILE * fopen(const char * path, const char * mode) 95 109 { 96 110 FILE * (*fopen_real) (const char *, const char *) = dlsym(RTLD_NEXT, "fopen"); ··· 152 166 char buf[PATH_MAX]; 153 167 return execv_real(rewrite(path, buf), argv); 154 168 } 169 + 170 + void *dlopen(const char *filename, int flag) 171 + { 172 + void * (*__dlopen_real) (const char *, int) = dlsym(RTLD_NEXT, "dlopen"); 173 + char buf[PATH_MAX]; 174 + return __dlopen_real(rewrite(filename, buf), flag); 175 + }
+55 -49
pkgs/tools/networking/network-manager/default.nix
··· 1 1 { stdenv, fetchurl, substituteAll, intltool, pkgconfig, dbus, dbus-glib 2 - , gnome3, systemd, libuuid, polkit, gnutls, ppp, dhcp, iptables 3 - , libgcrypt, dnsmasq, bluez5, readline 2 + , gnome3, systemd, libuuid, polkit, gnutls, ppp, dhcp, iptables, python3, vala 3 + , libgcrypt, dnsmasq, bluez5, readline, libselinux, audit 4 4 , gobject-introspection, modemmanager, openresolv, libndp, newt, libsoup 5 - , ethtool, gnused, coreutils, file, inetutils, kmod, jansson, libxslt 6 - , python3Packages, docbook_xsl, openconnect, curl, autoreconfHook }: 5 + , ethtool, gnused, coreutils, inetutils, kmod, jansson, gtk-doc, libxslt 6 + , docbook_xsl, docbook_xml_dtd_412, docbook_xml_dtd_42, docbook_xml_dtd_43 7 + , openconnect, curl, meson, ninja, libpsl, libredirect }: 7 8 8 9 let 9 10 pname = "NetworkManager"; 11 + pythonForDocs = python3.withPackages (pkgs: with pkgs; [ pygobject3 ]); 10 12 in stdenv.mkDerivation rec { 11 13 name = "network-manager-${version}"; 12 14 version = "1.16.0"; ··· 16 18 sha256 = "0b2x9hrg41cd17psqi0vacwj733v99hxczn53gdfs0yanqrji5lf"; 17 19 }; 18 20 19 - outputs = [ "out" "dev" ]; 20 - 21 - postPatch = '' 22 - patchShebangs ./tools 23 - ''; 24 - 25 - preConfigure = '' 26 - substituteInPlace configure --replace /usr/bin/uname ${coreutils}/bin/uname 27 - substituteInPlace configure --replace /usr/bin/file ${file}/bin/file 28 - 29 - # Fixes: error: po/Makefile.in.in was not created by intltoolize. 30 - intltoolize --automake --copy --force 31 - ''; 21 + outputs = [ "out" "dev" "devdoc" "man" "doc" ]; 32 22 33 23 # Right now we hardcode quite a few paths at build time. Probably we should 34 24 # patch networkmanager to allow passing these path in config file. This will 35 25 # remove unneeded build-time dependencies. 36 - configureFlags = [ 37 - "--with-dhclient=${dhcp}/bin/dhclient" 38 - "--with-dnsmasq=${dnsmasq}/bin/dnsmasq" 26 + mesonFlags = [ 27 + "-Ddhclient=${dhcp}/bin/dhclient" 28 + "-Ddnsmasq=${dnsmasq}/bin/dnsmasq" 39 29 # Upstream prefers dhclient, so don't add dhcpcd to the closure 40 - "--with-dhcpcd=no" 41 - "--with-pppd=${ppp}/bin/pppd" 42 - "--with-iptables=${iptables}/bin/iptables" 30 + "-Ddhcpcd=no" 31 + "-Dpppd=${ppp}/bin/pppd" 32 + "-Diptables=${iptables}/bin/iptables" 43 33 # to enable link-local connections 44 - "--with-udev-dir=${placeholder "out"}/lib/udev" 45 - "--with-resolvconf=${openresolv}/sbin/resolvconf" 46 - "--sysconfdir=/etc" "--localstatedir=/var" 47 - "--with-dbus-sys-dir=${placeholder "out"}/etc/dbus-1/system.d" 48 - "--with-crypto=gnutls" "--disable-more-warnings" 49 - "--with-systemdsystemunitdir=$(out)/etc/systemd/system" 50 - "--with-kernel-firmware-dir=/run/current-system/firmware" 51 - "--with-session-tracking=systemd" 52 - "--with-modem-manager-1" 53 - "--with-nmtui" 54 - "--disable-gtk-doc" 55 - "--with-libnm-glib" # legacy library, TODO: remove 56 - "--disable-tests" 34 + "-Dudev_dir=${placeholder "out"}/lib/udev" 35 + "-Dresolvconf=${openresolv}/bin/resolvconf" 36 + "-Ddbus_conf_dir=${placeholder "out"}/etc/dbus-1/system.d" 37 + "-Dsystemdsystemunitdir=${placeholder "out"}/etc/systemd/system" 38 + "-Dkernel_firmware_dir=/run/current-system/firmware" 39 + "--sysconfdir=/etc" 40 + "--localstatedir=/var" 41 + "-Dcrypto=gnutls" 42 + "-Dsession_tracking=systemd" 43 + "-Dmodem_manager=true" 44 + "-Dnmtui=true" 45 + "-Ddocs=true" 46 + "-Dlibnm_glib=true" # legacy library, TODO: remove 47 + "-Dtests=no" 48 + "-Dqt=false" 57 49 ]; 58 50 59 51 patches = [ ··· 63 55 inherit (stdenv) shell; 64 56 }) 65 57 58 + # Meson does not support using different directories during build and 59 + # for installation like Autotools did with flags passed to make install. 60 + ./fix-install-paths.patch 61 + 62 + # Our gobject-introspection patches make the shared library paths absolute 63 + # in the GIR files. When building docs, the library is not yet installed, 64 + # though, so we need to replace the absolute path with a local one during build. 65 + # We are replacing the variables in postPatch since substituteAll does not support 66 + # placeholders. 67 + ./fix-docs-build.patch 66 68 ]; 67 69 68 70 buildInputs = [ 69 - systemd libuuid polkit ppp libndp curl 71 + systemd libselinux audit libpsl libuuid polkit ppp libndp curl 70 72 bluez5 dnsmasq gobject-introspection modemmanager readline newt libsoup jansson 71 73 ]; 72 74 73 - propagatedBuildInputs = [ dbus-glib gnutls libgcrypt python3Packages.pygobject3 ]; 75 + propagatedBuildInputs = [ dbus-glib gnutls libgcrypt ]; 74 76 75 - nativeBuildInputs = [ autoreconfHook intltool pkgconfig libxslt docbook_xsl ]; 77 + nativeBuildInputs = [ 78 + meson ninja intltool pkgconfig 79 + vala gobject-introspection 80 + dbus-glib # for dbus-binding-tool 81 + # Docs 82 + gtk-doc libxslt docbook_xsl docbook_xml_dtd_412 docbook_xml_dtd_42 docbook_xml_dtd_43 pythonForDocs 83 + ]; 76 84 77 85 doCheck = false; # requires /sys, the net 78 86 79 - installFlags = [ 80 - "sysconfdir=${placeholder "out"}/etc" 81 - "localstatedir=${placeholder "out"}/var" 82 - "runstatedir=${placeholder "out"}/run" 83 - ]; 87 + postPatch = '' 88 + patchShebangs ./tools 89 + patchShebangs libnm/generate-setting-docs.py 84 90 85 - postInstall = '' 86 - mkdir -p $out/lib/NetworkManager 91 + substituteInPlace libnm/meson.build \ 92 + --subst-var-by DOCS_LD_PRELOAD "${libredirect}/lib/libredirect.so" \ 93 + --subst-var-by DOCS_NIX_REDIRECTS "${placeholder "out"}/lib/libnm.so.0=$PWD/build/libnm/libnm.so.0" 94 + ''; 87 95 88 - # FIXME: Workaround until NixOS' dbus+systemd supports at_console policy 89 - substituteInPlace $out/etc/dbus-1/system.d/org.freedesktop.NetworkManager.conf --replace 'at_console="true"' 'group="networkmanager"' 90 - 96 + postInstall = '' 91 97 # systemd in NixOS doesn't use `systemctl enable`, so we need to establish 92 98 # aliases ourselves. 93 99 ln -s $out/etc/systemd/system/NetworkManager-dispatcher.service $out/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service
+11
pkgs/tools/networking/network-manager/fix-docs-build.patch
··· 1 + --- a/libnm/meson.build 2 + +++ b/libnm/meson.build 3 + @@ -262,6 +262,8 @@ 4 + 'env', '-i', 5 + 'GI_TYPELIB_PATH=' + gi_typelib_path, 6 + 'LD_LIBRARY_PATH=' + ld_library_path, 7 + + 'LD_PRELOAD=' + '@DOCS_LD_PRELOAD@', 8 + + 'NIX_REDIRECTS=' + '@DOCS_NIX_REDIRECTS@', 9 + ] 10 + 11 + name = 'nm-property-docs.xml'
+25
pkgs/tools/networking/network-manager/fix-install-paths.patch
··· 1 + --- a/meson.build 2 + +++ b/meson.build 3 + @@ -925,9 +925,9 @@ 4 + join_paths('tools', 'meson-post-install.sh'), 5 + nm_datadir, 6 + nm_bindir, 7 + - nm_pkgconfdir, 8 + + nm_prefix + nm_pkgconfdir, 9 + nm_pkglibdir, 10 + - nm_pkgstatedir, 11 + + nm_prefix + nm_pkgstatedir, 12 + enable_docs ? 'install_docs' : '', 13 + nm_mandir, 14 + ) 15 + --- a/src/settings/plugins/ifcfg-rh/meson.build 16 + +++ b/src/settings/plugins/ifcfg-rh/meson.build 17 + @@ -70,7 +70,7 @@ 18 + ) 19 + 20 + meson.add_install_script('sh', '-c', 21 + - 'mkdir -p $DESTDIR/@0@/sysconfig/network-scripts'.format(nm_sysconfdir)) 22 + + 'mkdir -p $DESTDIR/@0@/sysconfig/network-scripts'.format(nm_prefix + nm_sysconfdir)) 23 + 24 + if enable_tests 25 + subdir('tests')