summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2021-06-14 09:09:25 +0200
committerMathieu Othacehe <othacehe@gnu.org>2021-06-14 09:09:25 +0200
commit7546a1d3c0a354ca7dc0b7e53c1505130c2d263d (patch)
tree9598a9302cc0c06ff85edc46cc0752d84ef0c42e
parent1b0bfb5df16e42f219f31cf3a1d55414d2c79e42 (diff)
downloadguix-7546a1d3c0a354ca7dc0b7e53c1505130c2d263d.tar.gz
ci: Backport sexp->channel procedure.
* gnu/ci.scm (sexp->channel): New procedure.
-rw-r--r--gnu/ci.scm29
1 files changed, 29 insertions, 0 deletions
diff --git a/gnu/ci.scm b/gnu/ci.scm
index 7ef8365318..5a068167ae 100644
--- a/gnu/ci.scm
+++ b/gnu/ci.scm
@@ -80,6 +80,35 @@
 ;;;
 ;;; Code:
 
+;; Backport from (guix channels) module.
+(define* (sexp->channel sexp #:optional (name 'channel))
+  "Read SEXP, a provenance sexp as created by 'channel-instance->sexp'; use
+NAME as the channel name if SEXP does not specify it.  Return #f if the sexp
+does not have the expected structure."
+  (match sexp
+    (('repository ('version 0)
+                  ('url url)
+                  ('branch branch)
+                  ('commit commit)
+                  rest ...)
+     ;; Historically channel sexps did not include the channel name.  It's OK
+     ;; for channels created by 'channel-instances->manifest' because the
+     ;; entry name is the channel name, but it was missing for entries created
+     ;; by 'manifest-entry-with-provenance'.
+     (channel (name (match (assq 'name rest)
+                      (#f name)
+                      (('name name) name)))
+              (url url)
+              (branch branch)
+              (commit commit)
+              (introduction
+               (match (assq 'introduction rest)
+                 (#f #f)
+                 (('introduction intro)
+                  (sexp->channel-introduction intro))))))
+
+    (_ #f)))
+
 (define* (derivation->job name drv
                           #:key
                           (max-silent-time 3600)