GNU bug report logs - #47986
[PATCH] inferior: Support querying package replacements.

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Sat, 24 Apr 2021 05:46:02 UTC

Severity: normal

Tags: patch

Done: Christopher Baines <mail <at> cbaines.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47986 in the body.
You can then email your comments to 47986 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#47986; Package guix-patches. (Sat, 24 Apr 2021 05:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Baines <mail <at> cbaines.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 24 Apr 2021 05:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: guix-patches <at> gnu.org
Subject: [PATCH] inferior: Support querying package replacements.
Date: Sat, 24 Apr 2021 06:45:09 +0100
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.
---
 guix/inferior.scm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

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."
-- 
2.30.1





Information forwarded to guix-patches <at> gnu.org:
bug#47986; Package guix-patches. (Mon, 03 May 2021 20:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 47986 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Christopher Baines <mail <at> cbaines.net>
Cc: 47986 <at> debbugs.gnu.org
Subject: Re: bug#47986: [PATCH] inferior: Support querying package
 replacements.
Date: Mon, 03 May 2021 22:50:59 +0200
Hi,

Christopher Baines <mail <at> 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’.




Information forwarded to guix-patches <at> gnu.org:
bug#47986; Package guix-patches. (Fri, 14 May 2021 08:43:01 GMT) Full text and rfc822 format available.

Message #11 received at 47986 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: 47986 <at> debbugs.gnu.org
Subject: [PATCH v2] inferior: Support querying package replacements.
Date: Fri, 14 May 2021 09:42:00 +0100
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





Information forwarded to guix-patches <at> gnu.org:
bug#47986; Package guix-patches. (Fri, 14 May 2021 08:46:02 GMT) Full text and rfc822 format available.

Message #14 received at 47986 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 47986 <at> debbugs.gnu.org
Subject: Re: bug#47986: [PATCH] inferior: Support querying package
 replacements.
Date: Fri, 14 May 2021 09:45:31 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Christopher Baines <mail <at> 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.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47986; Package guix-patches. (Sat, 15 May 2021 10:13:01 GMT) Full text and rfc822 format available.

Message #17 received at 47986 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Christopher Baines <mail <at> cbaines.net>
Cc: 47986 <at> debbugs.gnu.org
Subject: Re: bug#47986: [PATCH] inferior: Support querying package
 replacements.
Date: Sat, 15 May 2021 12:11:56 +0200
Hi,

Christopher Baines <mail <at> 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.
> * tests/inferior.scm ("inferior-package-replacement"): New test.

[...]

> +(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")))))

Problem is that this test assumes sqlite has a replacement.  Maybe
precede it:

  (unless (package-replacement sqlite)
    (test-skip 1))

and remove (or (package-replacement …) …) and similar.

That way we’ll notice when the test is skipped.

Otherwise LGTM, thanks!

Ludo’.




Reply sent to Christopher Baines <mail <at> cbaines.net>:
You have taken responsibility. (Sat, 15 May 2021 11:16:02 GMT) Full text and rfc822 format available.

Notification sent to Christopher Baines <mail <at> cbaines.net>:
bug acknowledged by developer. (Sat, 15 May 2021 11:16:02 GMT) Full text and rfc822 format available.

Message #22 received at 47986-done <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 47986-done <at> debbugs.gnu.org
Subject: Re: bug#47986: [PATCH] inferior: Support querying package
 replacements.
Date: Sat, 15 May 2021 12:15:49 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi,
>
> Christopher Baines <mail <at> 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.
>> * tests/inferior.scm ("inferior-package-replacement"): New test.
>
> [...]
>
>> +(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")))))
>
> Problem is that this test assumes sqlite has a replacement.  Maybe
> precede it:
>
>   (unless (package-replacement sqlite)
>     (test-skip 1))
>
> and remove (or (package-replacement …) …) and similar.
>
> That way we’ll notice when the test is skipped.

Sure, I've made those changes now.

> Otherwise LGTM, thanks!

Great, I've pushed this as 97d615b1761c2054561057f6b56e2a0caed13aa4.
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 12 Jun 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.