guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: refresh: Check updater availability at run time.


From: Ludovic Courtès
Subject: 01/01: refresh: Check updater availability at run time.
Date: Sun, 29 Nov 2015 21:56:40 +0000

civodul pushed a commit to branch master
in repository guix.

commit 26059753aea72d0a2bc51204bad9fe416e7c6536
Author: Ludovic Courtès <address@hidden>
Date:   Sun Nov 29 22:49:19 2015 +0100

    refresh: Check updater availability at run time.
    
    This is a followup to b68d2db, which added a check for updaters at
    macro-expansion time.  The problem is that, when running 'guix pull',
    Guile-JSON is found, so the PyPi updater (say) is added to %UPDATERS,
    but then at run time Guile-JSON might be missing.
    
    Reported by orbea on #guix.
    
    * guix/scripts/refresh.scm (maybe-updater): Rewrite as 'syntax-rules'.
    Produce code that checks conditions at run time.
    (list-updaters): Update docstring.
---
 guix/scripts/refresh.scm |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 8e8a34b..a94bb22 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -157,20 +157,21 @@ specified with `--select'.\n"))
 ;;;
 
 (define-syntax maybe-updater
-  ;; Helper macro for 'list-udpaters'.
-  (lambda (s)
-    (syntax-case s (=>)
-      ((_ ((module => updater) rest ...) (result ...))
-       (let ((met? (false-if-exception
-                    (resolve-interface (syntax->datum #'module)))))
-         (if met?
-             #'(maybe-updater (rest ...)
-                              (result ... (@ module updater)))
-             #'(maybe-updater (rest ...) (result ...)))))
-      ((_ (updater rest ...) (result ...))
-       #'(maybe-updater (rest ...) (result ... updater)))
-      ((_ () result)
-       #'result))))
+  ;; Helper macro for 'list-updaters'.
+  (syntax-rules (=>)
+    ((_ ((module => updater) rest ...) result)
+     (maybe-updater (rest ...)
+                    (let ((iface (false-if-exception
+                                  (resolve-interface 'module)))
+                          (tail  result))
+                      (if iface
+                          (cons (module-ref iface 'updater) tail)
+                          tail))))
+    ((_ (updater rest ...) result)
+     (maybe-updater (rest ...)
+                    (cons updater result)))
+    ((_ () result)
+     (reverse result))))
 
 (define-syntax-rule (list-updaters updaters ...)
   "Expand to '(list UPDATERS ...)' but only the subset of UPDATERS that are
@@ -181,11 +182,11 @@ A conditional updater has this form:
   ((SOME MODULE) => UPDATER)
 
 meaning that UPDATER is added to the list if and only if (SOME MODULE) could
-be resolved at macro expansion time.
+be resolved at run time.
 
 This is a way to discard at macro expansion time updaters that depend on
 unavailable optional dependencies such as Guile-JSON."
-  (maybe-updater (updaters ...) (list)))
+  (maybe-updater (updaters ...) '()))
 
 (define %updaters
   ;; List of "updaters" used by default.  They are consulted in this order.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]