summary refs log tree commit diff
path: root/maintainers
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-04-12 08:05:20 +0000
committerLudovic Courtès <ludo@gnu.org>2011-04-12 08:05:20 +0000
commit91e63f9caea7df74d239a42503a06a64793350c9 (patch)
tree58c5b8320e97c66929728cb759a4096846c318e3 /maintainers
parentcea90f43e483d56f3aeba2b527cd90bc64d85e2e (diff)
gnupdate: Handle `repeated' nodes referring to a drv not encountered yet.
* maintainers/scripts/gnu/gnupdate (xml-element->snix): Return an
  `unresolved' node when the repeated derivation hasn't been encountered
  yet.
  (resolve): New procedure.
  (xml->snix): Use it.

svn path=/nixpkgs/trunk/; revision=26790
Diffstat (limited to 'maintainers')
-rwxr-xr-xmaintainers/scripts/gnu/gnupdate47
1 files changed, 42 insertions, 5 deletions
diff --git a/maintainers/scripts/gnu/gnupdate b/maintainers/scripts/gnu/gnupdate
index a6923506dbb17..5eb22cb5963d1 100755
--- a/maintainers/scripts/gnu/gnupdate
+++ b/maintainers/scripts/gnu/gnupdate
@@ -117,8 +117,19 @@ exec ${GUILE-guile} -L "$PWD" -l "$0"    \
              (if (pair? body)
                  (values `(derivation ,drv-path ,out-path ,(cdr body))
                          derivations)
-                 (error "no previous occurrence of derivation"
-                        drv-path)))
+
+                 ;; DRV-PATH hasn't been encountered yet but may be later
+                 ;; (see <http://article.gmane.org/gmane.linux.distributions.nixos/5946>.)
+                 ;; Return an `unresolved' node.
+                 (values `(unresolved
+                           ,(lambda (derivations)
+                              (let ((body (vhash-assoc drv-path derivations)))
+                                (if (pair? body)
+                                    `(derivation ,drv-path ,out-path
+                                                 ,(cdr body))
+                                    (error "no previous occurrence of derivation"
+                                           drv-path)))))
+                         derivations)))
            (values `(derivation ,drv-path ,out-path ,body)
                    (vhash-cons drv-path body derivations)))))
     ((ellipsis)
@@ -146,6 +157,32 @@ exec ${GUILE-guile} -L "$PWD" -l "$0"    \
      (values `(varpat ,(assq-ref attributes 'name)) derivations))
     (else (error "unhandled Nix XML element" elem))))
 
+(define (resolve snix derivations)
+  "Return a new SNix tree where `unresolved' nodes from SNIX have been
+replaced by the result of their application to DERIVATIONS, a vhash."
+  (let loop ((node snix)
+             (seen vlist-null))
+    (if (vhash-assq node seen)
+        (values node seen)
+        (match node
+          (('unresolved proc)
+           (let ((n (proc derivations)))
+             (values n seen)))
+          ((tag body ...)
+           (let ((body+seen (fold (lambda (n body+seen)
+                                    (call-with-values
+                                        (lambda ()
+                                          (loop n (cdr body+seen)))
+                                      (lambda (n* seen)
+                                        (cons (cons n* (car body+seen))
+                                              (vhash-consq n #t seen)))))
+                                  (cons '() (vhash-consq node #t seen))
+                                  body)))
+             (values (cons tag (reverse (car body+seen)))
+                     (vhash-consq node #t (cdr body+seen)))))
+          (anything
+           (values anything seen))))))
+
 (define xml->snix
   ;; Return the SNix represention of TREE, an SXML tree as returned by
   ;; parsing the XML output of `nix-instantiate' on Nixpkgs.
@@ -173,9 +210,9 @@ exec ${GUILE-guile} -L "$PWD" -l "$0"    \
                              ;; Discard inter-node strings, which are blanks.
                              seed))))
     (lambda (port)
-      ;; Discard the second value returned by the parser (the derivation
-      ;; vhash).
-      (caar (parse port (cons '() vlist-null))))))
+      (match (parse port (cons '() vlist-null))
+        (((snix) . derivations)
+         (resolve snix derivations))))))
 
 (define (call-with-package snix proc)
   (match snix