Subject: [bug#77023] [PATCH 0/3] home: services: Add readymedia.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 05 May 2025 14:33:29 +0200

Sughosha <[email-masked]> writes:

> * gnu/home/services/upnp.scm: New file.
> * gnu/local.mk: Register it.
> * gnu/services/upnp.scm: Export readymedia-activation and
> readymedia-shepherd-service.
> (<readymedia-configuration>)[home-service?]: New field.
> [cache-directory]: Adjust value depending on 'for-home?'.
> [log-directory]: Ditto.
> (readymedia-shepherd-service): Adjust 'requirement' and 'start' according to
> 'home-service?'.
> (readymedia-activation): Adjust creating 'media-directories' with permissions
> according to 'home-service?'.
> * doc/guix.texi (Miscellaneous Home Services): Document Readymedia Service.
> (Miscellaneous Services): Add cross-reference.
>
> Change-Id: Id0c7ac2e1c4e17f1efb2d49d98883129d90afc38

Hello!  We’re almost there.  While running the system test, I noticed
that something had broken; I also noticed that we were calling ‘getpid’
at build time rather than at run time in the Home case, hence this
patch.

However, there’s still a test failure:

--8<---------------cut here---------------start------------->8---
Test begin:
  test-name: "ReadyMedia service is listening for connections"
  source-file: "/gnu/store/scyy0hybjm1qifpwlmzjhvs1ry28lvnk-readymedia-test-builder"
  source-line: 1
  source-form: (test-assert "ReadyMedia service is listening for connections" (wait-for-tcp-por)
Test end:
  result-kind: fail
  actual-value: #f
  actual-error: (misc-error #f "nobody's listening on port ~S" (("127.0.0.1" 8200)) #f)
--8<---------------cut here---------------end--------------->8---

Could you take a look?

Thanks,
Ludo’.

diff --git a/gnu/services/upnp.scm b/gnu/services/upnp.scm
index 579378b94a..363da005f1 100644
--- a/gnu/services/upnp.scm
+++ b/gnu/services/upnp.scm
@@ -33,7 +33,6 @@ (define-module (gnu services upnp)
   #:use-module (ice-9 match)
   #:export (%readymedia-default-cache-directory
             %readymedia-default-log-directory
-            %readymedia-default-port
             %readymedia-log-file
             %readymedia-user-account
             %readymedia-user-group
@@ -206,16 +205,16 @@ (define (readymedia-activation config)
                       (unless (file-exists? directory)
                         (mkdir-p/perms directory
                                        (getpw #$(if home-service?
-                                                    (getuid)
+                                                    #~(getuid)
                                                     %readymedia-user-account))
-                                       (if home-service? #o755 #o775))))
+                                       #$(if home-service? #o755 #o775))))
                     (list #$@(map readymedia-media-directory-path
                                   media-directories)))
           (for-each (lambda (directory)
                       (unless (file-exists? directory)
                         (mkdir-p/perms directory
                                        (getpw #$(if home-service?
-                                                    (getuid)
+                                                    #~(getuid)
                                                     %readymedia-user-account))
                                        #o755)))
                     (list #$cache-directory #$log-directory))))))
diff --git a/gnu/tests/upnp.scm b/gnu/tests/upnp.scm
index e4bce30d89..0224557f40 100644
--- a/gnu/tests/upnp.scm
+++ b/gnu/tests/upnp.scm
@@ -38,6 +38,7 @@ (define %readymedia-default-port 8200)
 (define %readymedia-media-directory "/media")
 (define %readymedia-configuration-test
   (readymedia-configuration
+   (port %readymedia-default-port)
    (media-directories
     (list (readymedia-media-directory (path %readymedia-media-directory)
                                       (types '(A V)))))))