Subject: [bug#37493] [PATCH] gnu: Add iwd.

From: Brice Waegeneire <[email-masked]>
Date: Mon, 23 Sep 2019 20:20:27 +0200

* gnu/packages/linux.scm (ell): New variable.
* gnu/packages/networking.scm (iwd): New variable.
* gnu/packages/patches/ell-fix-dbus-tests.patch: New file.
---
 gnu/packages/linux.scm                        | 37 +++++++++++
 gnu/packages/networking.scm                   | 56 ++++++++++++++++
 gnu/packages/patches/ell-fix-dbus-tests.patch | 65 +++++++++++++++++++
 3 files changed, 158 insertions(+)
 create mode 100644 gnu/packages/patches/ell-fix-dbus-tests.patch

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 59874b097c..11f2503841 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -36,6 +36,7 @@
 ;;; Copyright © 2019 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2019 Stefan Stefanović <[email-masked]>
 ;;; Copyright © 2019 Pierre Langlois <[email-masked]>
+;;; Copyright © 2019 Brice Waegeneire <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -5968,3 +5969,39 @@ have to construct the archives directly, without using the archiver.")
     (description "inputattach dispatches input events from several device
 types and interfaces and translates so that the X server can use them.")
     (license license:gpl2+)))
+
+(define-public ell
+  (package
+    (name "ell")
+    (version "0.23")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://git.kernel.org/pub/scm/libs/ell/ell.git")
+                    (commit version)))
+              (sha256
+               (base32
+                "1qhlcwhn0gj877yss2ymx1aczghlddzb5v9mm1dgp2zliii3jy10"))
+             (patches (search-patches "ell-fix-dbus-tests.patch"))))
+    (build-system gnu-build-system)
+    ;; (arguments
+    ;;  `(#:tests? #f    ;kernel/user integration tests are in package "xfstests"
+    ;;    #:phases (modify-phases %standard-phases
+    ;;               (add-after 'install 'install-headers
+    ;;                 (lambda _
+    ;;                   (invoke "make" "install-dev"))))))
+    (inputs
+     `(("dbus" ,dbus)
+       ("libtool" ,libtool)))
+    (native-inputs
+     `(("autoconf" ,autoconf)
+       ("pkgconfig" ,pkg-config)
+       ("automake" ,automake)))
+    (home-page "https://01.org/ell")
+    (synopsis "Embedded Linux Library")
+    (description "The Embedded Linux* Library (ELL) provides core, low-level
+functionality for system daemons. It typically has no dependencies other than
+the Linux kernel, C standard library, and libdl (for dynamic linking). While
+ELL is designed to be efficient and compact enough for use on embedded Linux
+platforms, it is not limited to resource-constrained systems.")
+    (license license:lgpl2.1+)))
diff --git a/gnu/packages/networking.scm b/gnu/packages/networking.scm
index 6bdf7f9e2f..87dd015320 100644
--- a/gnu/packages/networking.scm
+++ b/gnu/packages/networking.scm
@@ -30,6 +30,7 @@
 ;;; Copyright © 2019 Vasile Dumitrascu <[email-masked]>
 ;;; Copyright © 2019 Julien Lepiller <[email-masked]>
 ;;; Copyright © 2019 Timotej Lazar <[email-masked]>
+;;; Copyright © 2019 Brice Waegeneire <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2578,3 +2579,58 @@ communication.")
     (description "FRRouting (FRR) is an IP routing protocol suite which includes
 protocol daemons for BGP, IS-IS, LDP, OSPF, PIM, and RIP. ")
     (license license:gpl2+)))
+
+(define-public iwd
+  (package
+    (name "iwd")
+    (version "0.21")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://git.kernel.org/pub/scm/network/wireless/iwd.git")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "001dikinsa6kshwscjbvwipavzwpqnpvx9fpshcn63gbvbhyd393"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("dbus" ,dbus)
+       ("libtool" ,libtool)
+       ("ell" ,ell)
+       ("readline" ,readline)))
+    (native-inputs
+     `(("asciidoc" ,asciidoc)
+       ("autoconf" ,autoconf)
+       ("automake" ,automake)
+       ("pkgconfig" ,pkg-config)
+       ("python" ,python)
+       ("openssl" ,openssl)))
+    (arguments
+     `(#:configure-flags
+       (let ((dbus (assoc-ref %outputs "out")))
+         (list "--disable-systemd-service"
+               "--enable-external-ell"
+               "--enable-hwsim"
+               "--enable-tools"
+               "--enable-wired"
+               "--enable-docs"
+               "--localstatedir=/var"
+               (string-append "--with-dbus-datadir=" dbus "/share/")
+               (string-append "--with-dbus-busdir="
+                              dbus "/share/dbus-1/system-services")))
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'configure 'pre-configure
+           (lambda _
+             ;; Don't try to 'mkdir /var'.
+             (substitute* "Makefile.in"
+               (("\\$\\(MKDIR_P\\) -m 700")
+                "true")))))))
+    (home-page "https://git.kernel.org/cgit/network/wireless/iwd.git/")
+    (synopsis "Internet Wireless Daemon")
+    (description "iwd is a wireless daemon for Linux written by Intel that
+aims to replace WPA supplicant. It optimize resource utilization by not
+depending on any external libraries and instead utilizing features provided by
+the Linux Kernel to the maximum extent possible.")
+    (license license:lgpl2.1+)))
diff --git a/gnu/packages/patches/ell-fix-dbus-tests.patch b/gnu/packages/patches/ell-fix-dbus-tests.patch
new file mode 100644
index 0000000000..b494ba8b43
--- /dev/null
+++ b/gnu/packages/patches/ell-fix-dbus-tests.patch
@@ -0,0 +1,65 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -140,6 +140,7 @@
+ ell_libell_private_la_SOURCES = $(ell_libell_la_SOURCES)
+ 
+ AM_CFLAGS = -fvisibility=hidden -DUNITDIR=\""$(top_srcdir)/unit/"\" \
++				-DDBUS_DAEMON=\""$(DBUS_DAEMONDIR)/dbus-daemon"\" \
+ 				-DCERTDIR=\""$(top_builddir)/unit/"\"
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+--- a/configure.ac
++++ b/configure.ac
+@@ -14,6 +14,8 @@
+ 
+ AC_PREFIX_DEFAULT(/usr/local)
+ 
++PKG_PROG_PKG_CONFIG
++
+ COMPILER_FLAGS
+ 
+ AC_LANG_C
+@@ -131,6 +133,10 @@
+ 	AC_CHECK_PROG(have_xxd, [xxd], [yes], [no])
+ fi
+ 
++PKG_CHECK_MODULES(DBUS, dbus-1, dummy=yes,
++			AC_MSG_ERROR(D-Bus is required for running tests))
++PKG_CHECK_VAR(DBUS_DAEMONDIR, dbus-1, daemondir)
++
+ AM_CONDITIONAL(DBUS_TESTS, test "${little_endian}" = "yes")
+ AM_CONDITIONAL(CERT_TESTS, test "${have_openssl}" = "yes")
+ 
+--- a/unit/test-dbus-message-fds.c
++++ b/unit/test-dbus-message-fds.c
+@@ -51,7 +51,7 @@
+ 	char *prg_envp[1];
+ 	pid_t pid;
+ 
+-	prg_argv[0] = "/usr/bin/dbus-daemon";
++	prg_argv[0] = DBUS_DAEMON;
+ 	prg_argv[1] = "--nopidfile";
+ 	prg_argv[2] = "--nofork";
+ 	prg_argv[3] = "--config-file=" UNITDIR "dbus.conf";
+--- a/unit/test-dbus-properties.c
++++ b/unit/test-dbus-properties.c
+@@ -48,7 +48,7 @@
+ 	char *prg_envp[1];
+ 	pid_t pid;
+ 
+-	prg_argv[0] = "/usr/bin/dbus-daemon";
++	prg_argv[0] = DBUS_DAEMON;
+ 	prg_argv[1] = "--nopidfile";
+ 	prg_argv[2] = "--nofork";
+ 	prg_argv[3] = "--config-file=" UNITDIR "dbus.conf";
+--- a/unit/test-dbus.c
++++ b/unit/test-dbus.c
+@@ -45,7 +45,7 @@
+ 	char *prg_envp[1];
+ 	pid_t pid;
+ 
+-	prg_argv[0] = "/usr/bin/dbus-daemon";
++	prg_argv[0] = DBUS_DAEMON;
+ 	prg_argv[1] = "--nopidfile";
+ 	prg_argv[2] = "--nofork";
+ 	prg_argv[3] = "--config-file=" UNITDIR "dbus.conf";
-- 
2.19.2