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

Message ID 87h61z5jae.fsf_-_@gnu.org
State New
Headers

Commit Message

Ludovic Courtès May 5, 2025, 12:33 p.m. UTC
Sughosha <sughosha@disroot.org> 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’.
  

Comments

Sughosha May 14, 2025, 9:28 a.m. UTC | #1
On Monday, May 5, 2025 6:03:29 PM GMT+5:30 Ludovic Courtès wrote:
> Sughosha <sughosha@disroot.org> 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’.

I have sent the v5 patch, does it pass this test? I don't know how to run this 
test.
  
Ludovic Courtès May 14, 2025, 9:49 a.m. UTC | #2
Hi,

Sughosha <sughosha@disroot.org> writes:

> I have sent the v5 patch, does it pass this test? I don't know how to run this 
> test.

You can run “make check-system TESTS=readymedia”.

See
<https://guix.gnu.org/manual/devel/en/html_node/Running-the-Test-Suite.html>.

Ludo’.
  
Sughosha May 14, 2025, 10:37 a.m. UTC | #3
On Wednesday, May 14, 2025 3:19:35 PM GMT+5:30 Ludovic Courtès wrote:
> Hi,
> 
> Sughosha <sughosha@disroot.org> writes:
> > I have sent the v5 patch, does it pass this test? I don't know how to run
> > this test.
> 
> You can run “make check-system TESTS=readymedia”.
> 
> See
> <https://guix.gnu.org/manual/devel/en/html_node/Running-the-Test-Suite.html>
> .
> 
> Ludo’.

The test passed successfully, with the v5 patch that I sent above.
  
Maxim Cournoyer May 14, 2025, 1:58 p.m. UTC | #4
Hi,

Sughosha <sughosha@disroot.org> writes:

> On Wednesday, May 14, 2025 3:19:35 PM GMT+5:30 Ludovic Courtès wrote:
>> Hi,
>> 
>> Sughosha <sughosha@disroot.org> writes:
>> > I have sent the v5 patch, does it pass this test? I don't know how to run
>> > this test.
>> 
>> You can run “make check-system TESTS=readymedia”.
>> 
>> See
>> <https://guix.gnu.org/manual/devel/en/html_node/Running-the-Test-Suite.html>
>> .
>> 
>> Ludo’.
>
> The test passed successfully, with the v5 patch that I sent above.

It didn't for me, I got:

--8<---------------cut here---------------start------------->8---
Test begin:
  test-name: "ReadyMedia service is listening for connections"
  source-file: "/gnu/store/jp9x56qq0dalb01nh61l6zv1w8vss4rm-readymedia-test-builder"
  source-line: 1
  source-form: (test-assert "ReadyMedia service is listening for connections" (wait-for-tcp-port 8200 marionette))
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)
Group end: readymedia
# of expected passes      11
# of unexpected failures  1
--8<---------------cut here---------------end--------------->8---
  
Sughosha May 15, 2025, 2:50 a.m. UTC | #5
On Wednesday, May 14, 2025 7:28:33 PM GMT+5:30 Maxim Cournoyer wrote:
> Hi,
> 
> Sughosha <sughosha@disroot.org> writes:
> > On Wednesday, May 14, 2025 3:19:35 PM GMT+5:30 Ludovic Courtès wrote:
> >> Hi,
> >> 
> >> Sughosha <sughosha@disroot.org> writes:
> >> > I have sent the v5 patch, does it pass this test? I don't know how to
> >> > run
> >> > this test.
> >> 
> >> You can run “make check-system TESTS=readymedia”.
> >> 
> >> See
> >> <https://guix.gnu.org/manual/devel/en/html_node/Running-the-Test-Suite.ht
> >> ml> .
> >> 
> >> Ludo’.
> > 
> > The test passed successfully, with the v5 patch that I sent above.
> 
> It didn't for me, I got:
> 
> --8<---------------cut here---------------start------------->8---
> Test begin:
>   test-name: "ReadyMedia service is listening for connections"
>   source-file:
> "/gnu/store/jp9x56qq0dalb01nh61l6zv1w8vss4rm-readymedia-test-builder"
> source-line: 1
>   source-form: (test-assert "ReadyMedia service is listening for
> connections" (wait-for-tcp-port 8200 marionette)) 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) Group end: readymedia
> # of expected passes      11
> # of unexpected failures  1
> --8<---------------cut here---------------end--------------->8---

I don't know why you are getting this error. I tested it again and it passed. 
The attatchment contains the log.
  
Maxim Cournoyer May 15, 2025, 4:52 a.m. UTC | #6
Hi,

Sughosha <sughosha@disroot.org> writes:

[...]

>> --8<---------------cut here---------------start------------->8---
>> Test begin:
>>   test-name: "ReadyMedia service is listening for connections"
>>   source-file:
>> "/gnu/store/jp9x56qq0dalb01nh61l6zv1w8vss4rm-readymedia-test-builder"
>> source-line: 1
>>   source-form: (test-assert "ReadyMedia service is listening for
>> connections" (wait-for-tcp-port 8200 marionette)) 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) Group end: readymedia
>> # of expected passes      11
>> # of unexpected failures  1
>> --8<---------------cut here---------------end--------------->8---
>
> I don't know why you are getting this error. I tested it again and it passed. 
> The attatchment contains the log.

Actually, even before your change is applied, the test is failing.

It seems the least-authority-wrapper doesn't expose everything needed;
at first it was failing to start because it couldn't write to
/var/run/minidlna/minidlna.pid, so I exopsed /var/run like so:

--8<---------------cut here---------------start------------->8---
modified   gnu/services/upnp.scm
@@ -167,6 +167,10 @@ (define (readymedia-shepherd-service config)
                            (file-system-mapping
                             (source minidlna-conf)
                             (target source))
+                           (file-system-mapping
+                            (source "/var/run")
+                            (target source)
+                            (writable? #t))
                            (map (lambda (directory)
                                   (file-system-mapping
                                    (source (readymedia-media-directory-path directory))
--8<---------------cut here---------------end--------------->8---

Now, from the VM, I get:

--8<---------------cut here---------------start------------->8---
"/gnu/store/18d6ifs8j3ggb4zrkxchxn9pnk7795g4-minidlna" "-f" "/gnu/store/1b3szxs7ibivbv1bqmh5c0m5gk5ngv3b-minidlna.conf" "-S"

minidlna.c:520: warn: Unset locale
minidlna.c:1134: warn: Starting MiniDLNA version 1.3.3.
minidlna.c:331: fatal: ERROR: Failed to open sqlite database!  Exiting...
root@komputilo ~# echo $?
255
--8<---------------cut here---------------end--------------->8---

Any idea?  It should be reproducible on your side, as long as you rebase
your branch on current master, perhaps.  I tested with commit 7b73f02c38d.
  
Maxim Cournoyer May 15, 2025, 6:46 a.m. UTC | #7
Hi,

Actually, it seems the root issue may be related to bug#78356.  When
looking at /var/log/readymedia/minidlna.log we see:


--8<---------------cut here---------------start------------->8---
2025-05-15 08:22:27 In gnu/build/linux-container.scm:
...skipping...
2025-05-15 08:22:27    476:16  3 (_ "/tmp/guix-directory.w1REZ6")
2025-05-15 08:22:27      62:6  2 (call-with-clean-exit #<procedure 7fa0ff7c2e80 at gnu/b?>)
2025-05-15 08:22:27    321:20  1 (_)
2025-05-15 08:22:27 In guix/build/syscalls.scm:
2025-05-15 08:22:27   1231:10  0 (_ 268566528)
2025-05-15 08:22:27 
2025-05-15 08:22:27 guix/build/syscalls.scm:1231:10: In procedure unshare: 268566528: Invalid argument
2025-05-15 08:22:28 Backtrace:
2025-05-15 08:22:28            4 (primitive-load "/gnu/store/4h68sswscz96wk47724bfqfrq9n?")
2025-05-15 08:22:28 In ice-9/eval.scm:
2025-05-15 08:22:28    191:35  3 (_ _)
2025-05-15 08:22:28 In gnu/build/linux-container.scm:
2025-05-15 08:22:28     368:8  2 (call-with-temporary-directory #<procedure 7fa0ff7df3f0?>)
2025-05-15 08:22:28     485:7  1 (_ "/tmp/guix-directory.w1REZ6")
2025-05-15 08:22:28 In unknown file:
2025-05-15 08:22:28            0 (waitpid #f #<undefined>)
2025-05-15 08:22:28 
2025-05-15 08:22:28 ERROR: In procedure waitpid:
2025-05-15 08:22:28 Wrong type (expecting exact integer): #f
--8<---------------cut here---------------end--------------->8---


Which appears to share the same `unshare' issue as seen in bug#78356.
  

Patch

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)))))))