diff mbox series

[bug#46031] services: cuirass: Add "simple-cuirass-services".

Message ID 875z2ilxnl.fsf@gnu.org
State Accepted
Headers show
Series [bug#46031] services: cuirass: Add "simple-cuirass-services". | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Mathieu Othacehe Feb. 23, 2021, 1:30 p.m. UTC
Hey,

> I guess the first step would be to provide an a ‘package-channel(s)’
> procedure that does like ‘package-provenance’, but returns a list of
> channels.

Seems fine to me. Here's an implementation attached. If it works for
you, the next step will be to make the "cuirass-jobs" procedure of
"gnu-system.scm" operate on channels I guess.

WDYT?

Thanks,

Mathieu

Comments

Ludovic Courtès Feb. 23, 2021, 5:42 p.m. UTC | #1
Hi,

Mathieu Othacehe <othacehe@gnu.org> skribis:

>> I guess the first step would be to provide an a ‘package-channel(s)’
>> procedure that does like ‘package-provenance’, but returns a list of
>> channels.
>
> Seems fine to me. Here's an implementation attached. If it works for
> you, the next step will be to make the "cuirass-jobs" procedure of
> "gnu-system.scm" operate on channels I guess.

But by definition, “gnu-system.scm” is about the 'guix channel.
Intuitively I’d expect channel handling to happen in user code: either
in the user-provided manifest, or in some helper code in Cuirass.  WDYT?

> From d44dcd5d153ba0a4627c205f24a0741384f3d301 Mon Sep 17 00:00:00 2001
> From: Mathieu Othacehe <othacehe@gnu.org>
> Date: Tue, 23 Feb 2021 14:24:39 +0100
> Subject: [PATCH] describe: Add package-channels.
>
> * guix/describe.scm (package-channels): New procedure.

[...]

> +(define (package-channels package)
> +  "Return the list of channels providing PACKAGE or an empty list if it could
> +not be determined."
> +  (match (and=> (package-location package) location-file)
> +    (#f #f)

The #f return value doesn’t match the docstring.

> +    (file
> +     (let ((file (if (string-prefix? "/" file)
> +                     file
> +                     (search-path %load-path file))))
> +       (and file
> +            (string-prefix? (%store-prefix) file)
> +
> +            (filter-map
> +             (lambda (entry)
> +               (let ((item (manifest-entry-item entry)))
> +                 (and (or (string-prefix? item file)
> +                          (string=? "guix" (manifest-entry-name entry)))
> +                      (manifest-entry-channel entry))))
> +             (current-profile-entries)))))))

To avoid duplication, perhaps you should rewrite ‘package-provenance’ in
terms of ‘package-channels’?

Otherwise LGTM, thanks!

Thanks,
Ludo’.
diff mbox series

Patch

From d44dcd5d153ba0a4627c205f24a0741384f3d301 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@gnu.org>
Date: Tue, 23 Feb 2021 14:24:39 +0100
Subject: [PATCH] describe: Add package-channels.

* guix/describe.scm (package-channels): New procedure.
---
 guix/describe.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/guix/describe.scm b/guix/describe.scm
index 03569b1db4..65e5772856 100644
--- a/guix/describe.scm
+++ b/guix/describe.scm
@@ -33,6 +33,7 @@ 
             package-path-entries
 
             package-provenance
+            package-channels
             manifest-entry-with-provenance
             manifest-entry-provenance))
 
@@ -178,6 +179,26 @@  property of manifest entries, or #f if it could not be determined."
                        `(,main
                          ,@(if extra (list extra) '()))))))))))
 
+(define (package-channels package)
+  "Return the list of channels providing PACKAGE or an empty list if it could
+not be determined."
+  (match (and=> (package-location package) location-file)
+    (#f #f)
+    (file
+     (let ((file (if (string-prefix? "/" file)
+                     file
+                     (search-path %load-path file))))
+       (and file
+            (string-prefix? (%store-prefix) file)
+
+            (filter-map
+             (lambda (entry)
+               (let ((item (manifest-entry-item entry)))
+                 (and (or (string-prefix? item file)
+                          (string=? "guix" (manifest-entry-name entry)))
+                      (manifest-entry-channel entry))))
+             (current-profile-entries)))))))
+
 (define (manifest-entry-with-provenance entry)
   "Return ENTRY with an additional 'provenance' property if it's not already
 there."
-- 
2.30.1