unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#47986] [PATCH] inferior: Support querying package replacements.
@ 2021-04-24  5:45 Christopher Baines
  2021-05-03 20:50 ` Ludovic Courtès
  2021-05-14  8:42 ` [bug#47986] [PATCH v2] " Christopher Baines
  0 siblings, 2 replies; 6+ messages in thread
From: Christopher Baines @ 2021-04-24  5:45 UTC (permalink / raw)
  To: 47986

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





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#47986] [PATCH] inferior: Support querying package replacements.
  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 ` [bug#47986] [PATCH v2] " Christopher Baines
  1 sibling, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2021-05-03 20:50 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 47986

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’.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#47986] [PATCH v2] inferior: Support querying package replacements.
  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:42 ` Christopher Baines
  2021-05-15 10:11   ` [bug#47986] [PATCH] " Ludovic Courtès
  1 sibling, 1 reply; 6+ messages in thread
From: Christopher Baines @ 2021-05-14  8:42 UTC (permalink / raw)
  To: 47986

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





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#47986] [PATCH] inferior: Support querying package replacements.
  2021-05-03 20:50 ` Ludovic Courtès
@ 2021-05-14  8:45   ` Christopher Baines
  0 siblings, 0 replies; 6+ messages in thread
From: Christopher Baines @ 2021-05-14  8:45 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 47986

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]


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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#47986] [PATCH] inferior: Support querying package replacements.
  2021-05-14  8:42 ` [bug#47986] [PATCH v2] " Christopher Baines
@ 2021-05-15 10:11   ` Ludovic Courtès
  2021-05-15 11:15     ` bug#47986: " Christopher Baines
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2021-05-15 10:11 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 47986

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.
> * 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’.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#47986: [PATCH] inferior: Support querying package replacements.
  2021-05-15 10:11   ` [bug#47986] [PATCH] " Ludovic Courtès
@ 2021-05-15 11:15     ` Christopher Baines
  0 siblings, 0 replies; 6+ messages in thread
From: Christopher Baines @ 2021-05-15 11:15 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 47986-done

[-- Attachment #1: Type: text/plain, Size: 1707 bytes --]


Ludovic Courtès <ludo@gnu.org> writes:

> 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.
>> * 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-15 11:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [bug#47986] [PATCH v2] " Christopher Baines
2021-05-15 10:11   ` [bug#47986] [PATCH] " Ludovic Courtès
2021-05-15 11:15     ` bug#47986: " Christopher Baines

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).