mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
inferior: Support querying package replacements.
I'm looking at this to help with adding support for looking up package replacements to store in the Guix Data Service. * guix/inferior.scm (inferior-package-replacement): New procedure. * tests/inferior.scm ("inferior-package-replacement"): New test.
This commit is contained in:
parent
b149c16371
commit
97d615b176
2 changed files with 42 additions and 0 deletions
|
@ -90,6 +90,7 @@ (define-module (guix inferior)
|
|||
inferior-package-native-search-paths
|
||||
inferior-package-transitive-native-search-paths
|
||||
inferior-package-search-paths
|
||||
inferior-package-replacement
|
||||
inferior-package-provenance
|
||||
inferior-package-derivation
|
||||
|
||||
|
@ -462,6 +463,27 @@ (define inferior-package-search-paths
|
|||
(define inferior-package-transitive-native-search-paths
|
||||
(cut %inferior-package-search-paths <> 'package-transitive-native-search-paths))
|
||||
|
||||
(define (inferior-package-replacement package)
|
||||
"Return the replacement for PACKAGE. This will either be an inferior
|
||||
package, or #f."
|
||||
(match (inferior-package-field
|
||||
package
|
||||
'(compose (match-lambda
|
||||
((? package? package)
|
||||
(let ((id (object-address package)))
|
||||
(hashv-set! %package-table id package)
|
||||
(list id
|
||||
(package-name package)
|
||||
(package-version package))))
|
||||
(#f #f))
|
||||
package-replacement))
|
||||
(#f #f)
|
||||
((id name version)
|
||||
(inferior-package (inferior-package-inferior package)
|
||||
name
|
||||
version
|
||||
id))))
|
||||
|
||||
(define (inferior-package-provenance package)
|
||||
"Return a \"provenance sexp\" for PACKAGE, an inferior package. The result
|
||||
is similar to the sexp returned by 'package-provenance' for regular packages."
|
||||
|
|
|
@ -26,6 +26,7 @@ (define-module (test-inferior)
|
|||
#:use-module (gnu packages)
|
||||
#:use-module (gnu packages bootstrap)
|
||||
#:use-module (gnu packages guile)
|
||||
#:use-module (gnu packages sqlite)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-34)
|
||||
#:use-module (srfi srfi-64)
|
||||
|
@ -260,6 +261,25 @@ (define result
|
|||
(list (inferior-package-derivation %store guile "x86_64-linux")
|
||||
(inferior-package-derivation %store guile "armhf-linux")))))
|
||||
|
||||
(unless (package-replacement sqlite)
|
||||
(test-skip 1))
|
||||
|
||||
(test-equal "inferior-package-replacement"
|
||||
(package-derivation %store
|
||||
(package-replacement sqlite)
|
||||
"x86_64-linux")
|
||||
(let* ((inferior (open-inferior %top-builddir
|
||||
#:command "scripts/guix"))
|
||||
(packages (inferior-packages inferior)))
|
||||
(match (lookup-inferior-packages inferior
|
||||
(package-name sqlite)
|
||||
(package-version sqlite))
|
||||
((inferior-sqlite rest ...)
|
||||
(inferior-package-derivation %store
|
||||
(inferior-package-replacement
|
||||
inferior-sqlite)
|
||||
"x86_64-linux")))))
|
||||
|
||||
(test-equal "inferior-package->manifest-entry"
|
||||
(manifest-entry->list (package->manifest-entry
|
||||
(first (find-best-packages-by-name "guile" #f))))
|
||||
|
|
Loading…
Reference in a new issue