From: Christopher Baines <mail@cbaines.net>
To: 47986@debbugs.gnu.org
Subject: [bug#47986] [PATCH v2] inferior: Support querying package replacements.
Date: Fri, 14 May 2021 09:42:00 +0100 [thread overview]
Message-ID: <20210514084200.5896-1-mail@cbaines.net> (raw)
In-Reply-To: <20210424054509.7740-1-mail@cbaines.net>
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.
---
guix/inferior.scm | 22 ++++++++++++++++++++++
tests/inferior.scm | 18 ++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/guix/inferior.scm b/guix/inferior.scm
index eb457f81f9..7c8e478f2a 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,27 @@ package."
(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."
diff --git a/tests/inferior.scm b/tests/inferior.scm
index f227e0b749..864bab86da 100644
--- a/tests/inferior.scm
+++ b/tests/inferior.scm
@@ -26,6 +26,7 @@
#: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,23 @@
(list (inferior-package-derivation %store guile "x86_64-linux")
(inferior-package-derivation %store guile "armhf-linux")))))
+(test-equal "inferior-package-replacement"
+ (package-derivation %store
+ (or (package-replacement sqlite) 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
+ (or (inferior-package-replacement
+ inferior-sqlite)
+ 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))))
--
2.30.1
next prev parent reply other threads:[~2021-05-14 8:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-24 5:45 [bug#47986] [PATCH] inferior: Support querying package replacements Christopher Baines
2021-05-03 20:50 ` Ludovic Courtès
2021-05-14 8:45 ` Christopher Baines
2021-05-14 8:42 ` Christopher Baines [this message]
2021-05-15 10:11 ` Ludovic Courtès
2021-05-15 11:15 ` bug#47986: " Christopher Baines
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210514084200.5896-1-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=47986@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).