diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2012-07-07 20:14:20 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2012-07-07 20:14:31 +0200 |
| commit | a3d73f59e35e19561afde1bf60ef881a4e8db0e7 (patch) | |
| tree | 5ef1d41fdae49ba439d3e10ae615f69abba45e6e | |
| parent | d5f0c7cc626a0517237c55848342777623d1bd01 (diff) | |
Add `package-transitive-inputs'; use it to honor propagated inputs.
* guix/packages.scm (package-transitive-inputs): New procedure.
(package-derivation): Use it to compute INPUTS.
* tests/packages.scm (dummy-package): New macro.
("package-transitive-inputs"): New test.
| -rw-r--r-- | guix/packages.scm | 25 | ||||
| -rw-r--r-- | tests/packages.scm | 28 |
2 files changed, 51 insertions, 2 deletions
diff --git a/guix/packages.scm b/guix/packages.scm index 2d269ad339a..c835e928154 100644 --- a/guix/packages.scm +++ b/guix/packages.scm | |||
| @@ -57,6 +57,7 @@ | |||
| 57 | package-properties | 57 | package-properties |
| 58 | package-location | 58 | package-location |
| 59 | 59 | ||
| 60 | package-transitive-inputs | ||
| 60 | package-source-derivation | 61 | package-source-derivation |
| 61 | package-derivation | 62 | package-derivation |
| 62 | package-cross-derivation)) | 63 | package-cross-derivation)) |
| @@ -161,6 +162,27 @@ representation." | |||
| 161 | (($ <origin> uri method sha256 name) | 162 | (($ <origin> uri method sha256 name) |
| 162 | (method store uri 'sha256 sha256 name)))) | 163 | (method store uri 'sha256 sha256 name)))) |
| 163 | 164 | ||
| 165 | (define (package-transitive-inputs package) | ||
| 166 | "Return the transitive inputs of PACKAGE---i.e., its direct inputs along | ||
| 167 | with their propagated inputs, recursively." | ||
| 168 | (let loop ((inputs (concatenate (list (package-native-inputs package) | ||
| 169 | (package-inputs package) | ||
| 170 | (package-propagated-inputs package)))) | ||
| 171 | (result '())) | ||
| 172 | (match inputs | ||
| 173 | (() | ||
| 174 | (delete-duplicates (reverse result))) ; XXX: efficiency | ||
| 175 | (((and i (name (? package? p) sub ...)) rest ...) | ||
| 176 | (let ((t (map (match-lambda | ||
| 177 | ((dep-name derivation ...) | ||
| 178 | (cons (string-append name "/" dep-name) | ||
| 179 | derivation))) | ||
| 180 | (package-propagated-inputs p)))) | ||
| 181 | (loop (append t rest) | ||
| 182 | (append t (cons i result))))) | ||
| 183 | ((input rest ...) | ||
| 184 | (loop rest (cons input result)))))) | ||
| 185 | |||
| 164 | (define* (package-derivation store package | 186 | (define* (package-derivation store package |
| 165 | #:optional (system (%current-system))) | 187 | #:optional (system (%current-system))) |
| 166 | "Return the derivation of PACKAGE for SYSTEM." | 188 | "Return the derivation of PACKAGE for SYSTEM." |
| @@ -186,8 +208,7 @@ representation." | |||
| 186 | (list name | 208 | (list name |
| 187 | (add-to-store store (basename file) | 209 | (add-to-store store (basename file) |
| 188 | #t #f "sha256" file)))) | 210 | #t #f "sha256" file)))) |
| 189 | (concatenate (list native-inputs inputs | 211 | (package-transitive-inputs package)))) |
| 190 | propagated-inputs))))) | ||
| 191 | (apply builder | 212 | (apply builder |
| 192 | store (string-append name "-" version) | 213 | store (string-append name "-" version) |
| 193 | (package-source-derivation store source) | 214 | (package-source-derivation store source) |
diff --git a/tests/packages.scm b/tests/packages.scm index eef7d32a351..d804e0ce835 100644 --- a/tests/packages.scm +++ b/tests/packages.scm | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #:use-module (guix utils) | 22 | #:use-module (guix utils) |
| 23 | #:use-module (guix derivations) | 23 | #:use-module (guix derivations) |
| 24 | #:use-module (guix packages) | 24 | #:use-module (guix packages) |
| 25 | #:use-module (guix build-system gnu) | ||
| 25 | #:use-module (distro) | 26 | #:use-module (distro) |
| 26 | #:use-module (distro base) | 27 | #:use-module (distro base) |
| 27 | #:use-module (srfi srfi-26) | 28 | #:use-module (srfi srfi-26) |
| @@ -35,6 +36,32 @@ | |||
| 35 | 36 | ||
| 36 | (test-begin "packages") | 37 | (test-begin "packages") |
| 37 | 38 | ||
| 39 | (define-syntax-rule (dummy-package name* extra-fields ...) | ||
| 40 | (package (name name*) (version "0") (source #f) | ||
| 41 | (build-system gnu-build-system) | ||
| 42 | (description #f) (long-description #f) | ||
| 43 | (home-page #f) | ||
| 44 | extra-fields ...)) | ||
| 45 | |||
| 46 | (test-assert "package-transitive-inputs" | ||
| 47 | (let* ((a (dummy-package "a")) | ||
| 48 | (b (dummy-package "b" | ||
| 49 | (propagated-inputs `(("a" ,a))))) | ||
| 50 | (c (dummy-package "c" | ||
| 51 | (inputs `(("a" ,a))))) | ||
| 52 | (d (dummy-package "d" | ||
| 53 | (propagated-inputs `(("x" "something.drv"))))) | ||
| 54 | (e (dummy-package "e" | ||
| 55 | (inputs `(("b" ,b) ("c" ,c) ("d" ,d)))))) | ||
| 56 | (and (null? (package-transitive-inputs a)) | ||
| 57 | (equal? `(("a" ,a)) (package-transitive-inputs b)) | ||
| 58 | (equal? `(("a" ,a)) (package-transitive-inputs c)) | ||
| 59 | (equal? (package-propagated-inputs d) | ||
| 60 | (package-transitive-inputs d)) | ||
| 61 | (equal? `(("b" ,b) ("b/a" ,a) ("c" ,c) | ||
| 62 | ("d" ,d) ("d/x" "something.drv")) | ||
| 63 | (pk 'x (package-transitive-inputs e)))))) | ||
| 64 | |||
| 38 | (test-skip (if (not %store) 1 0)) | 65 | (test-skip (if (not %store) 1 0)) |
| 39 | 66 | ||
| 40 | (test-assert "GNU Hello" | 67 | (test-assert "GNU Hello" |
| @@ -63,4 +90,5 @@ | |||
| 63 | 90 | ||
| 64 | ;;; Local Variables: | 91 | ;;; Local Variables: |
| 65 | ;;; eval: (put 'test-assert 'scheme-indent-function 1) | 92 | ;;; eval: (put 'test-assert 'scheme-indent-function 1) |
| 93 | ;;; eval: (put 'dummy-package 'scheme-indent-function 1) | ||
| 66 | ;;; End: | 94 | ;;; End: |
