Message ID | 20210424054509.7740-1-mail@cbaines.net |
---|---|
State | Accepted |
Headers | show |
Series | [bug#47986] inferior: Support querying package replacements. | expand |
Context | Check | Description |
---|---|---|
cbaines/submitting builds | success | |
cbaines/comparison | success | View comparision |
cbaines/git branch | success | View Git branch |
cbaines/applying patch | success | View Laminar job |
cbaines/issue | success | View issue |
Hi, Christopher Baines <mail@cbaines.net> skribis: > 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. Could you add a docstring and ideally a test? (There might be complications for the test, let’s see how it goes.) Thanks! Ludo’.
Ludovic Courtès <ludo@gnu.org> writes: > Christopher Baines <mail@cbaines.net> skribis: > >> 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. > > Could you add a docstring and ideally a test? (There might be > complications for the test, let’s see how it goes.) I've sent an update patch now. Maybe the test should search out for a package without a replacement, as well as a package with a replacement, so that it tests both cases, but I just went with a simpler approach for now.
diff --git a/guix/inferior.scm b/guix/inferior.scm index eb457f81f9..19607724c0 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -90,6 +90,7 @@ 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,25 @@ package." (define inferior-package-transitive-native-search-paths (cut %inferior-package-search-paths <> 'package-transitive-native-search-paths)) +(define (inferior-package-replacement package) + (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."