store: 'requisites' now takes a list of store items.

* guix/store.scm (fold-path): Change 'path' to 'paths' and adjust body
accordingly.
(requisites): Likewise.
* guix/scripts/environment.scm (inputs->requisites): Adjust
user accordingly.
* guix/scripts/size.scm (requisites*): Likewise.
* guix/scripts/gc.scm (guix-gc): Likewise.
* tests/store.scm ("requisites"): Likewise.
This commit is contained in:
Ludovic Courtès 2016-05-24 23:27:07 +02:00
parent db761534df
commit f6fee16e93
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
5 changed files with 19 additions and 16 deletions

View File

@ -333,11 +333,11 @@ requisite store items i.e. the union closure of all the inputs."
(requisites* (requisites*
(match input (match input
((drv output) ((drv output)
(derivation->output-path drv output)) (list (derivation->output-path drv output)))
((drv) ((drv)
(derivation->output-path drv)) (list (derivation->output-path drv)))
((? direct-store-path? path) ((? direct-store-path? path)
path)))) (list path)))))
(mlet %store-monad ((reqs (sequence %store-monad (mlet %store-monad ((reqs (sequence %store-monad
(map input->requisites inputs)))) (map input->requisites inputs))))

View File

@ -229,7 +229,8 @@ Invoke the garbage collector.\n"))
((list-references) ((list-references)
(list-relatives references)) (list-relatives references))
((list-requisites) ((list-requisites)
(list-relatives requisites)) (list-relatives (lambda (store item)
(requisites store (list item)))))
((list-referrers) ((list-referrers)
(list-relatives referrers)) (list-relatives referrers))
((optimize) ((optimize)

View File

@ -122,7 +122,7 @@ substitutes."
(guard (c ((nix-protocol-error? c) (guard (c ((nix-protocol-error? c)
(values (substitutable-requisites store item) (values (substitutable-requisites store item)
store))) store)))
(values (requisites store item) store)))) (values (requisites store (list item)) store))))
(define (mappend-map mproc lst) (define (mappend-map mproc lst)
"Apply MPROC to each item of LST and concatenate the resulting list." "Apply MPROC to each item of LST and concatenate the resulting list."

View File

@ -803,12 +803,12 @@ the list of references")
(loop items tail (loop items tail
(cons head result))))))))) (cons head result)))))))))
(define* (fold-path store proc seed path (define* (fold-path store proc seed paths
#:optional (relatives (cut references store <>))) #:optional (relatives (cut references store <>)))
"Call PROC for each of the RELATIVES of PATH, exactly once, and return the "Call PROC for each of the RELATIVES of PATHS, exactly once, and return the
result formed from the successive calls to PROC, the first of which is passed result formed from the successive calls to PROC, the first of which is passed
SEED." SEED."
(let loop ((paths (list path)) (let loop ((paths paths)
(result seed) (result seed)
(seen vlist-null)) (seen vlist-null))
(match paths (match paths
@ -822,10 +822,10 @@ SEED."
(() (()
result)))) result))))
(define (requisites store path) (define (requisites store paths)
"Return the requisites of PATH, including PATH---i.e., its closure (all its "Return the requisites of PATHS, including PATHS---i.e., their closures (all
references, recursively)." its references, recursively)."
(fold-path store cons '() path)) (fold-path store cons '() paths))
(define (topologically-sorted store paths) (define (topologically-sorted store paths)
"Return a list containing PATHS and all their references sorted in "Return a list containing PATHS and all their references sorted in

View File

@ -244,10 +244,12 @@
(and (= (length x) (length y)) (and (= (length x) (length y))
(lset= equal? x y))) (lset= equal? x y)))
(and (same? (requisites %store t1) (list t1)) (and (same? (requisites %store (list t1)) (list t1))
(same? (requisites %store t2) (list t1 t2)) (same? (requisites %store (list t2)) (list t1 t2))
(same? (requisites %store t3) (list t1 t2 t3)) (same? (requisites %store (list t3)) (list t1 t2 t3))
(same? (requisites %store t4) (list t1 t2 t3 t4))))) (same? (requisites %store (list t4)) (list t1 t2 t3 t4))
(same? (requisites %store (list t1 t2 t3 t4))
(list t1 t2 t3 t4)))))
(test-assert "derivers" (test-assert "derivers"
(let* ((b (add-text-to-store %store "build" "echo $foo > $out" '())) (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))