From 85b4dabd94d53f8179f31a42046cd83fc3a352fc Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 29 May 2022 23:46:35 -0400 Subject: services: jami: Modernize to adjust to Shepherd 0.9+ changes. This partially fixes , allowing the 'jami' and 'jami-provisioning' system tests to pass again. In version 0.9.0, Shepherd constructors are now run concurrently, via cooperative scheduling (Guile Fibers). The Jami service previously relied on blocking sleeps while polling for D-Bus services to become ready after forking a process; this wouldn't work anymore since while blocking the service process wouldn't be given the chance to finish starting. The new reliance on Fibers in Shepherd's fork+exec-command in the helper 'send-dbus' procedure also meant that it wouldn't work outside of Shepherd anymore. Finally, the 'start-service' Shepherd procedure used in the test suite would cause the Jami daemon to be spawned multiple times (a bug introduced in Shepherd 0.9.0). To fix/simplify these problems, this change does the following: 1. Use the Guile AC/D-Bus library for D-Bus communication, which simplify things, such as avoiding the need to fork 'dbus-send' processes. 2. The non-blocking 'sleep' version of Fiber is used for the 'with-retries' waiting syntax. 3. A 'dbus' package variant is used to adjust the session bus configuration, tailoring it for the use case at hand. 4. Avoid start-service in the tests, preferring 'jami-service-available?' for now. * gnu/build/jami-service.scm (parse-dbus-reply, strip-quotes) (deserialize-item, serialize-boolean, dbus-dict->alist) (dbus-array->list, parse-account-ids, parse-account-details) (parse-contacts): Delete procedures. (%send-dbus-binary, %send-dbus-bus, %send-dbus-user, %send-dbus-group) (%send-dbus-debug): Delete parameters. (jami-service-running?): New procedure. (send-dbus/configuration-manager): Rename to... (call-configuration-manager-method): ... this. Turn METHOD into a positional argument. Turn ARGUMENTS into an optional argument. Invoke `call-dbus-method' instead of `send-dbus', adjusting callers accordingly. (get-account-ids, id->account-details, id->account-details) (id->volatile-account-details, username->id, add-account remove-account) (username->contacts, remove-contact, add-contact, set-account-details) (set-all-moderators, username->all-moderators?, username->moderators) (set-moderator): Adjust accordingly. (with-retries, send-dbus, dbus-available-services) (dbus-service-available?): Move to ... * gnu/build/dbus-service.scm: ... this new module. (send-dbus): Rewrite to use the Guile AC/D-Bus library. (%dbus-query-timeout, sleep*): New variables. (%current-dbus-connection): New parameter. (initialize-dbus-connection!, argument->signature-type) (call-dbus-method): New procedures. (dbus-available-services): Adjust accordingly. * gnu/local.mk (GNU_SYSTEM_MODULES): Register new module. * gnu/packages/glib.scm (dbus-for-jami): New variable. * gnu/services/telephony.scm: (jami-configuration)[dbus]: Default to dbus-for-jami. (jami-dbus-session-activation): Write a D-Bus daemon configuration file at '/var/run/jami/session-local.conf'. (jami-shepherd-services): Add the closure of guile-ac-d-bus and guile-fibers as extensions. Adjust imported modules. Remove no longer used parameters. : Use a PID file, avoiding the need for the manual synchronization. : Set DBUS_SESSION_BUS_ADDRESS environment variable. Poll using 'jami-service-available?' instead of 'dbus-service-available?'. * gnu/tests/telephony.scm (run-jami-test): Add needed Guile extensions. Set DBUS_SESSION_BUS_ADDRESS environment variable. Adjust all tests to use 'jami-service-available?' to determine if the service is started rather than the now problematic Shepherd's 'start-service'. --- gnu/packages/glib.scm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'gnu/packages/glib.scm') diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm index 09d5a03555..732b1aea8a 100644 --- a/gnu/packages/glib.scm +++ b/gnu/packages/glib.scm @@ -9,7 +9,7 @@ ;;; Copyright © 2017 Petter ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice ;;; Copyright © 2018 Alex Vong -;;; Copyright © 2019, 2021 Maxim Cournoyer +;;; Copyright © 2019, 2021, 2022 Maxim Cournoyer ;;; Copyright © 2019 Giacomo Leidi ;;; Copyright © 2019, 2020, 2021 Marius Bakke ;;; Copyright © 2020 Nicolò Balzarotti @@ -176,6 +176,23 @@ or through unencrypted TCP/IP suitable for use behind a firewall with shared NFS home directories.") (license license:gpl2+))) ; or Academic Free License 2.1 +;;; This variant is used for the Jami service: it provides an entry point to +;;; further customize the configuration of the D-Bus instance run by the +;;; jami-dbus-session service. +(define-public dbus-for-jami + (hidden-package + (package/inherit dbus + (name "dbus-for-jami") + (arguments + (substitute-keyword-arguments (package-arguments dbus) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'customize-config + (lambda _ + (substitute* "bus/session.conf.in" + (("@SYSCONFDIR_FROM_PKGDATADIR@/dbus-1/session-local.conf") + "/var/run/jami/session-local.conf"))))))))))) + (define glib (package (name "glib") -- cgit v1.2.3 From 3aaf52a129ccf1d42aefd31322d21f697ce026b4 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 7 Dec 2021 22:20:02 -0500 Subject: gnu: Add dbus-verbose. * gnu/packages/glib.scm (dbus-verbose): New variable. --- gnu/packages/glib.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gnu/packages/glib.scm') diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm index 732b1aea8a..98267fcee5 100644 --- a/gnu/packages/glib.scm +++ b/gnu/packages/glib.scm @@ -193,6 +193,21 @@ shared NFS home directories.") (("@SYSCONFDIR_FROM_PKGDATADIR@/dbus-1/session-local.conf") "/var/run/jami/session-local.conf"))))))))))) +;;; The reason this is not enabled in the regular dbus package is because it +;;; impacts the performance of D-Bus (including its library) as a whole, even +;;; when the DBUS_VERBOSE environment variable is not set. +(define-public dbus-verbose + (package/inherit dbus + (name "dbus-verbose") + (arguments (substitute-keyword-arguments (package-arguments dbus) + ((#:configure-flags flags '()) + `(cons "--enable-verbose-mode" ,flags)))) + (synopsis "D-Bus with verbose mode enabled for debugging") + (description "This variant D-Bus package is built with verbose mode, which +eases debugging of D-Bus services by printing various debug information when +the @code{DBUS_VERBOSE} environment variable is set to @samp{1}. For more +information, refer to the @samp{dbus-daemon(1)} man page."))) + (define glib (package (name "glib") -- cgit v1.2.3