Archived
1
0
Fork 0

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.
This commit is contained in:
Ludovic Courtès 2015-11-29 22:49:19 +01:00
parent 4b7857a48b
commit 26059753ae

View file

@ -157,20 +157,21 @@ specified with `--select'.\n"))
;;; ;;;
(define-syntax maybe-updater (define-syntax maybe-updater
;; Helper macro for 'list-udpaters'. ;; Helper macro for 'list-updaters'.
(lambda (s) (syntax-rules (=>)
(syntax-case s (=>) ((_ ((module => updater) rest ...) result)
((_ ((module => updater) rest ...) (result ...)) (maybe-updater (rest ...)
(let ((met? (false-if-exception (let ((iface (false-if-exception
(resolve-interface (syntax->datum #'module))))) (resolve-interface 'module)))
(if met? (tail result))
#'(maybe-updater (rest ...) (if iface
(result ... (@ module updater))) (cons (module-ref iface 'updater) tail)
#'(maybe-updater (rest ...) (result ...))))) tail))))
((_ (updater rest ...) (result ...)) ((_ (updater rest ...) result)
#'(maybe-updater (rest ...) (result ... updater))) (maybe-updater (rest ...)
(cons updater result)))
((_ () result) ((_ () result)
#'result)))) (reverse result))))
(define-syntax-rule (list-updaters updaters ...) (define-syntax-rule (list-updaters updaters ...)
"Expand to '(list UPDATERS ...)' but only the subset of UPDATERS that are "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) ((SOME MODULE) => UPDATER)
meaning that UPDATER is added to the list if and only if (SOME MODULE) could 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 This is a way to discard at macro expansion time updaters that depend on
unavailable optional dependencies such as Guile-JSON." unavailable optional dependencies such as Guile-JSON."
(maybe-updater (updaters ...) (list))) (maybe-updater (updaters ...) '()))
(define %updaters (define %updaters
;; List of "updaters" used by default. They are consulted in this order. ;; List of "updaters" used by default. They are consulted in this order.