diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2018-09-18 09:56:34 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-09-21 17:04:37 +0200 |
| commit | 2e6d64e122ad2745154a38122785895d1b66c2ff (patch) | |
| tree | 3382cc262500b4bf939d3a8339a0f172e6f62af1 | |
| parent | eee8b303f6d82c1400fd8fd3b097406358ed7875 (diff) | |
inferior: Add 'inferior-package->manifest-entry'.
* guix/inferior.scm (inferior-package->manifest-entry): New procedure.
* tests/inferior.scm (manifest-entry->list): New procedure.
("inferior-package->manifest-entry"): New test.
| -rw-r--r-- | guix/inferior.scm | 42 | ||||
| -rw-r--r-- | tests/inferior.scm | 18 |
2 files changed, 56 insertions, 4 deletions
diff --git a/guix/inferior.scm b/guix/inferior.scm index 3fa4930095c..c86fdd3ec12 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #:select (read-derivation-from-file)) | 33 | #:select (read-derivation-from-file)) |
| 34 | #:use-module (guix gexp) | 34 | #:use-module (guix gexp) |
| 35 | #:use-module (guix search-paths) | 35 | #:use-module (guix search-paths) |
| 36 | #:use-module (guix profiles) | ||
| 36 | #:use-module (srfi srfi-1) | 37 | #:use-module (srfi srfi-1) |
| 37 | #:use-module (srfi srfi-26) | 38 | #:use-module (srfi srfi-26) |
| 38 | #:use-module (ice-9 match) | 39 | #:use-module (ice-9 match) |
| @@ -45,12 +46,12 @@ | |||
| 45 | inferior-eval | 46 | inferior-eval |
| 46 | inferior-object? | 47 | inferior-object? |
| 47 | 48 | ||
| 49 | inferior-packages | ||
| 50 | lookup-inferior-packages | ||
| 51 | |||
| 48 | inferior-package? | 52 | inferior-package? |
| 49 | inferior-package-name | 53 | inferior-package-name |
| 50 | inferior-package-version | 54 | inferior-package-version |
| 51 | |||
| 52 | inferior-packages | ||
| 53 | lookup-inferior-packages | ||
| 54 | inferior-package-synopsis | 55 | inferior-package-synopsis |
| 55 | inferior-package-description | 56 | inferior-package-description |
| 56 | inferior-package-home-page | 57 | inferior-package-home-page |
| @@ -62,7 +63,9 @@ | |||
| 62 | inferior-package-native-search-paths | 63 | inferior-package-native-search-paths |
| 63 | inferior-package-transitive-native-search-paths | 64 | inferior-package-transitive-native-search-paths |
| 64 | inferior-package-search-paths | 65 | inferior-package-search-paths |
| 65 | inferior-package-derivation)) | 66 | inferior-package-derivation |
| 67 | |||
| 68 | inferior-package->manifest-entry)) | ||
| 66 | 69 | ||
| 67 | ;;; Commentary: | 70 | ;;; Commentary: |
| 68 | ;;; | 71 | ;;; |
| @@ -441,3 +444,34 @@ PACKAGE must be live." | |||
| 441 | target) | 444 | target) |
| 442 | ;; Compile PACKAGE for SYSTEM, optionally cross-building for TARGET. | 445 | ;; Compile PACKAGE for SYSTEM, optionally cross-building for TARGET. |
| 443 | (inferior-package->derivation package system #:target target)) | 446 | (inferior-package->derivation package system #:target target)) |
| 447 | |||
| 448 | |||
| 449 | ;;; | ||
| 450 | ;;; Manifest entries. | ||
| 451 | ;;; | ||
| 452 | |||
| 453 | (define* (inferior-package->manifest-entry package | ||
| 454 | #:optional (output "out") | ||
| 455 | #:key (parent (delay #f)) | ||
| 456 | (properties '())) | ||
| 457 | "Return a manifest entry for the OUTPUT of package PACKAGE." | ||
| 458 | ;; For each dependency, keep a promise pointing to its "parent" entry. | ||
| 459 | (letrec* ((deps (map (match-lambda | ||
| 460 | ((label package) | ||
| 461 | (inferior-package->manifest-entry package | ||
| 462 | #:parent (delay entry))) | ||
| 463 | ((label package output) | ||
| 464 | (inferior-package->manifest-entry package output | ||
| 465 | #:parent (delay entry)))) | ||
| 466 | (inferior-package-propagated-inputs package))) | ||
| 467 | (entry (manifest-entry | ||
| 468 | (name (inferior-package-name package)) | ||
| 469 | (version (inferior-package-version package)) | ||
| 470 | (output output) | ||
| 471 | (item package) | ||
| 472 | (dependencies (delete-duplicates deps)) | ||
| 473 | (search-paths | ||
| 474 | (inferior-package-transitive-native-search-paths package)) | ||
| 475 | (parent parent) | ||
| 476 | (properties properties)))) | ||
| 477 | entry)) | ||
diff --git a/tests/inferior.scm b/tests/inferior.scm index 99d736bd40f..6f6abd28a18 100644 --- a/tests/inferior.scm +++ b/tests/inferior.scm | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #:use-module (guix inferior) | 21 | #:use-module (guix inferior) |
| 22 | #:use-module (guix packages) | 22 | #:use-module (guix packages) |
| 23 | #:use-module (guix store) | 23 | #:use-module (guix store) |
| 24 | #:use-module (guix profiles) | ||
| 24 | #:use-module (guix derivations) | 25 | #:use-module (guix derivations) |
| 25 | #:use-module (gnu packages) | 26 | #:use-module (gnu packages) |
| 26 | #:use-module (gnu packages bootstrap) | 27 | #:use-module (gnu packages bootstrap) |
| @@ -38,6 +39,13 @@ | |||
| 38 | (define %store | 39 | (define %store |
| 39 | (open-connection-for-tests)) | 40 | (open-connection-for-tests)) |
| 40 | 41 | ||
| 42 | (define (manifest-entry->list entry) | ||
| 43 | (list (manifest-entry-name entry) | ||
| 44 | (manifest-entry-version entry) | ||
| 45 | (manifest-entry-output entry) | ||
| 46 | (manifest-entry-search-paths entry) | ||
| 47 | (map manifest-entry->list (manifest-entry-dependencies entry)))) | ||
| 48 | |||
| 41 | 49 | ||
| 42 | (test-begin "inferior") | 50 | (test-begin "inferior") |
| 43 | 51 | ||
| @@ -164,4 +172,14 @@ | |||
| 164 | (list (inferior-package-derivation %store guile "x86_64-linux") | 172 | (list (inferior-package-derivation %store guile "x86_64-linux") |
| 165 | (inferior-package-derivation %store guile "armhf-linux"))))) | 173 | (inferior-package-derivation %store guile "armhf-linux"))))) |
| 166 | 174 | ||
| 175 | (test-equal "inferior-package->manifest-entry" | ||
| 176 | (manifest-entry->list (package->manifest-entry | ||
| 177 | (first (find-best-packages-by-name "guile" #f)))) | ||
| 178 | (let* ((inferior (open-inferior %top-builddir | ||
| 179 | #:command "scripts/guix")) | ||
| 180 | (guile (first (lookup-inferior-packages inferior "guile"))) | ||
| 181 | (entry (inferior-package->manifest-entry guile))) | ||
| 182 | (close-inferior inferior) | ||
| 183 | (manifest-entry->list entry))) | ||
| 184 | |||
| 167 | (test-end "inferior") | 185 | (test-end "inferior") |
