GNU bug report logs - #75302
[PATCH] packages: Match renamed origin fields.

Previous Next

Package: guix-patches;

Reported by: Herman Rimm <herman <at> rimm.ee>

Date: Thu, 2 Jan 2025 21:05:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 75302 AT debbugs.gnu.org.

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 <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org:
bug#75302; Package guix-patches. (Thu, 02 Jan 2025 21:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Herman Rimm <herman <at> rimm.ee>:
New bug report received and forwarded. Copy sent to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org. (Thu, 02 Jan 2025 21:05:02 GMT) Full text and rfc822 format available.

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

From: Herman Rimm <herman <at> rimm.ee>
To: guix-patches <at> gnu.org
Subject: [PATCH] packages: Match renamed origin fields.
Date: Thu,  2 Jan 2025 22:03:30 +0100
* guix/packages.scm (print-origin, origin->derivation): Use
match-record.

Change-Id: Ia554dd3264f51e549df51f767c754040b3dc7611
---
Hello,

Three tests in (tests packages) fail as before:
"package-source-derivation, local-file"
"package-source-derivation, origin, sha512"
"package-source-derivation, origin, sha3-512"

Cheers,
Herman

 guix/packages.scm | 59 ++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 31 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index ff9fbd84709..6088457b20b 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2022 jgart <jgart <at> dismail.de>
 ;;; Copyright © 2023 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke <at> gnu.org>
+;;; Copyright © 2025 Herman Rimm <herman <at> rimm.ee>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -359,12 +360,10 @@ (define-syntax-rule (origin fields ...)
 
 (define (print-origin origin port)
   "Write a concise representation of ORIGIN to PORT."
-  (match origin
-    (($ <origin> uri method hash file-name patches)
-     (simple-format port "#<origin ~s ~a ~s ~a>"
-                    uri hash
-                    (force patches)
-                    (number->string (object-address origin) 16)))))
+  (match-record origin <origin> (uri method hash file-name patches)
+    (simple-format port "#<origin ~s ~a ~s ~a>"
+                   uri hash patches
+                   (number->string (object-address origin) 16))))
 
 (set-record-type-printer! <origin> print-origin)
 
@@ -2151,31 +2150,29 @@ (define-gexp-compiler (package-compiler (package <package>) system target)
 (define* (origin->derivation origin
                              #:optional (system (%current-system)))
   "Return the derivation corresponding to ORIGIN."
-  (match origin
-    (($ <origin> uri method hash name (= force ()) #f)
-     ;; No patches, no snippet: this is a fixed-output derivation.
-     (method uri
-             (content-hash-algorithm hash)
-             (content-hash-value hash)
-             name #:system system))
-    (($ <origin> uri method hash name (= force (patches ...)) snippet
-                 flags inputs (modules ...) guile-for-build)
-     ;; Patches and/or a snippet.
-     (mlet %store-monad ((source (method uri
-                                         (content-hash-algorithm hash)
-                                         (content-hash-value hash)
-                                         name #:system system))
-                         (guile  (package->derivation (or guile-for-build
-                                                          (default-guile))
-                                                      system
-                                                      #:graft? #f)))
-       (patch-and-repack source patches
-                         #:inputs inputs
-                         #:snippet snippet
-                         #:flags flags
-                         #:system system
-                         #:modules modules
-                         #:guile-for-build guile)))))
+  (match-record origin <origin>
+    (uri method hash file-name patches patch-flags patch-inputs
+     patch-guile snippet modules)
+    (let* ((hash-algo (content-hash-algorithm hash))
+           (hash      (content-hash-value hash))
+           (source    (method uri hash-algo hash file-name
+                              #:system system)))
+      (if (or snippet (pair? patches))
+          (mlet %store-monad
+              ((guile (package->derivation (or patch-guile
+                                               (default-guile))
+                                           system
+                                           #:graft? #f))
+               (source source))
+            (patch-and-repack source patches
+                              #:inputs patch-inputs
+                              #:snippet snippet
+                              #:flags patch-flags
+                              #:system system
+                              #:modules modules
+                              #:guile-for-build guile))
+          ;; This is a fixed-output derivation.
+          source))))
 
 (define-gexp-compiler (origin-compiler (origin <origin>) system target)
   ;; Compile ORIGIN to a derivation for SYSTEM.  This is used when referring

base-commit: 5d7455bb580eed41a4fa7c20b71eaccad9f49e73
-- 
2.45.2





Information forwarded to guix-patches <at> gnu.org:
bug#75302; Package guix-patches. (Sat, 04 Jan 2025 21:00:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Herman Rimm <herman <at> rimm.ee>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>, 75302 <at> debbugs.gnu.org,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Christopher Baines <guix <at> cbaines.net>
Subject: Re: [bug#75302] [PATCH] packages: Match renamed origin fields.
Date: Sat, 04 Jan 2025 21:59:13 +0100
Hi,

Herman Rimm <herman <at> rimm.ee> skribis:

> * guix/packages.scm (print-origin, origin->derivation): Use
> match-record.
>
> Change-Id: Ia554dd3264f51e549df51f767c754040b3dc7611

The patch LGTM but, (1) fields haven’t been renamed recently, and…

> Three tests in (tests packages) fail as before:
> "package-source-derivation, local-file"
> "package-source-derivation, origin, sha512"
> "package-source-derivation, origin, sha3-512"

… (2) I don’t see these failures as of
b8858d8b1344525d0d7ac78d8fb9dc1a577b85d3.

Could you provide more details about these?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#75302; Package guix-patches. (Mon, 06 Jan 2025 18:50:02 GMT) Full text and rfc822 format available.

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

From: Herman Rimm <herman <at> rimm.ee>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 75302 <at> debbugs.gnu.org
Subject: Re: [bug#75302] [PATCH] packages: Match renamed origin fields.
Date: Mon, 6 Jan 2025 19:48:46 +0100
[Message part 1 (text/plain, inline)]
Hello,

On Sat, Jan 04, 2025 at 09:59:13PM +0100, Ludovic Courtès wrote:
> The patch LGTM but, (1) fields haven’t been renamed recently, and…

I misunderstood how (match _ (($ _) _)) works.  Can you amend the commit
to start like: 'packages: Replace match with match-record.', instead?

> > Three tests in (tests packages) fail as before:
> > "package-source-derivation, local-file"
> > "package-source-derivation, origin, sha512"
> > "package-source-derivation, origin, sha3-512"
> 
> … (2) I don’t see these failures as of
> b8858d8b1344525d0d7ac78d8fb9dc1a577b85d3.

In a checkout at b8858d8b1344525d0d7ac78d8fb9dc1a577b85d3 with this
patch applied, running:

guix shell -CPWN
./pre-inst-env guix repl < tests/packages.scm

I get the three errors mentioned, see attached log.  I run the tests
like this because running:

guix shell -CPWN
make check TESTS="tests/packages.scm"

returns:

make  check-recursive
make[1]: Entering directory '/home/herman/git/guix'
Making check in po/guix
make[2]: Entering directory '/home/herman/git/guix/po/guix'
make[2]: Nothing to be done for 'check'.
make[2]: Leaving directory '/home/herman/git/guix/po/guix'
Making check in po/packages
make[2]: Entering directory '/home/herman/git/guix/po/packages'
make[2]: Nothing to be done for 'check'.
make[2]: Leaving directory '/home/herman/git/guix/po/packages'
make[2]: Entering directory '/home/herman/git/guix'
Compiling Scheme modules...
Compiling Scheme modules...
Compiling Scheme modules...
Compiling Scheme modules...
Compiling Scheme modules...
Compiling Scheme modules...
Compiling Scheme modules...
[ 77%] LOAD     gnu.scm
ice-9/eval.scm:293:34: error: diff: unbound variable
hint: Did you forget a `use-modules' form?

make[2]: *** [Makefile:7518: make-system-go] Error 1
make[2]: Leaving directory '/home/herman/git/guix'
make[1]: *** [Makefile:6553: check-recursive] Error 1
make[1]: Leaving directory '/home/herman/git/guix'
make: *** [Makefile:7027: check] Error 2

Cheers,
Herman
[packages.log (text/plain, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#75302; Package guix-patches. (Wed, 08 Jan 2025 10:07:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Herman Rimm <herman <at> rimm.ee>
Cc: 75302 <at> debbugs.gnu.org
Subject: Re: [bug#75302] [PATCH] packages: Match renamed origin fields.
Date: Wed, 08 Jan 2025 11:06:08 +0100
Hi,

Herman Rimm <herman <at> rimm.ee> skribis:

> On Sat, Jan 04, 2025 at 09:59:13PM +0100, Ludovic Courtès wrote:
>> The patch LGTM but, (1) fields haven’t been renamed recently, and…
>
> I misunderstood how (match _ (($ _) _)) works.  Can you amend the commit
> to start like: 'packages: Replace match with match-record.', instead?

OK.

> In a checkout at b8858d8b1344525d0d7ac78d8fb9dc1a577b85d3 with this
> patch applied, running:
>
> guix shell -CPWN
> ./pre-inst-env guix repl < tests/packages.scm

If you really wanted to do this, try:

  ./pre-inst-env guile --no-auto-compile tests/packages.scm

I recommend sticking to the documented procedure though.

> I get the three errors mentioned, see attached log.  I run the tests
> like this because running:
>
> guix shell -CPWN
> make check TESTS="tests/packages.scm"
>
> returns:

[...]

> [ 77%] LOAD     gnu.scm
> ice-9/eval.scm:293:34: error: diff: unbound variable
> hint: Did you forget a `use-modules' form?
> make[2]: *** [Makefile:7518: make-system-go] Error 1

Well, it definitely builds here.  Could it be that you have local
changes in your tree?  Or perhaps you need ‘make clean-go’ first?

>   source-form: (test-assert "package-source-derivation, local-file" (let* ((file (local-file "../guix/base32.scm")) (package (package (inherit (dummy-package "p")) (source file))) (source (package-source-derivation %store (package-source package)))) (and (store-path? source) (string-suffix? "base32.scm" source) (valid-path? %store source) (equal? (call-with-input-file source get-bytevector-all) (call-with-input-file (search-path %load-path "guix/base32.scm") get-bytevector-all)))))
> Test end:
>   result-kind: fail
>   actual-value: #f
>   actual-error: (system-error "canonicalize-path" "~A: ~S" ("No such file or directory" "../guix/base32.scm") (2))

Probably has to do with running the test through standard input ‘guix
repl’: in that case it cannot correctly determine what the current file
name is, and so relative file name resolution fails.

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#75302; Package guix-patches. (Tue, 21 Jan 2025 18:34:02 GMT) Full text and rfc822 format available.

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

From: Herman Rimm <herman <at> rimm.ee>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 75302 <at> debbugs.gnu.org
Subject: Re: [bug#75302] [PATCH] packages: Match renamed origin fields.
Date: Tue, 21 Jan 2025 19:32:44 +0100
Hi,

On Wed, Jan 08, 2025 at 11:06:08AM +0100, Ludovic Courtès wrote:
> If you really wanted to do this, try:
> 
>   ./pre-inst-env guile --no-auto-compile tests/packages.scm
> 

Thanks, I'll use this from now on.

> > guix shell -CPWN
> > make check TESTS="tests/packages.scm"
> >
> > returns:
> 
> [...]
> 
> > [ 77%] LOAD     gnu.scm
> > ice-9/eval.scm:293:34: error: diff: unbound variable
> > hint: Did you forget a `use-modules' form?
> > make[2]: *** [Makefile:7518: make-system-go] Error 1
> 
> Well, it definitely builds here.  Could it be that you have local
> changes in your tree?  Or perhaps you need ‘make clean-go’ first?

With ae217b7159ee202229eab39cd49adb9254cd4a96 checked out out and the
patch applied, I get the same result running:

guix shell -CPWN
make clean-go
make check TESTS="tests/packages.scm"

> >   source-form: (test-assert "package-source-derivation, local-file" (let* ((file (local-file "../guix/base32.scm")) (package (package (inherit (dummy-package "p")) (source file))) (source (package-source-derivation %store (package-source package)))) (and (store-path? source) (string-suffix? "base32.scm" source) (valid-path? %store source) (equal? (call-with-input-file source get-bytevector-all) (call-with-input-file (search-path %load-path "guix/base32.scm") get-bytevector-all)))))
> > Test end:
> >   result-kind: fail
> >   actual-value: #f
> >   actual-error: (system-error "canonicalize-path" "~A: ~S" ("No such file or directory" "../guix/base32.scm") (2))
> 
> Probably has to do with running the test through standard input ‘guix
> repl’: in that case it cannot correctly determine what the current file
> name is, and so relative file name resolution fails.

Yeah, now this test passes.  Another test fails instead:

Test begin:
  test-name: "fold-available-packages with/without cache"
  source-file: "tests/packages.scm"
  source-line: 1819
  source-form: (test-assert "fold-available-packages with/without cache" (let () (define no-cache (fold-available-packages (lambda* (name version result #:rest rest) (cons (cons* name version rest) result)) (quote ()))) (define from-cache (call-with-temporary-directory (lambda (cache) (generate-package-cache cache) (mock ((guix describe) current-profile (const cache)) (mock ((gnu packages) cache-is-authoritative? (const #t)) (fold-available-packages (lambda* (name version result #:rest rest) (cons (cons* name version rest) result)) (quote ()))))))) (define (list->set* lst) (let loop ((lst lst) (duplicates (quote ())) (seen (set))) (match lst (() (values seen duplicates)) ((head . tail) (if (set-contains? seen head) (loop tail (cons head duplicates) seen) (loop tail duplicates (set-insert head seen))))))) (let ((set1 duplicates1 (list->set* from-cache)) (set2 duplicates2 (list->set* no-cache))) (pk (quote from-cache-duplicates:) duplicates1) (pk (quote no-cache-duplicates:) duplicates2) (and (null? duplicates1) (null? duplicates2) (every (cut set-contains? set1 <>) no-cache) (every (cut set-contains? set2 <>) from-cache)))))
Test end:
  result-kind: fail
  actual-value: #f

Cheers,
Herman




Information forwarded to guix-patches <at> gnu.org:
bug#75302; Package guix-patches. (Tue, 21 Jan 2025 20:23:02 GMT) Full text and rfc822 format available.

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

From: Herman Rimm <herman <at> rimm.ee>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 75302 <at> debbugs.gnu.org
Subject: Re: [bug#75302] [PATCH] packages: Match renamed origin fields.
Date: Tue, 21 Jan 2025 21:21:24 +0100
Hi again,

On Wed, Jan 08, 2025 at 11:06:08AM +0100, Ludovic Courtès wrote:
> > guix shell -CPWN
> > make check TESTS="tests/packages.scm"
> >
> > returns:
> 
> [...]
> 
> > [ 77%] LOAD     gnu.scm
> > ice-9/eval.scm:293:34: error: diff: unbound variable
> > hint: Did you forget a `use-modules' form?
> > make[2]: *** [Makefile:7518: make-system-go] Error 1
> 
> Well, it definitely builds here.  Could it be that you have local
> changes in your tree?  Or perhaps you need ‘make clean-go’ first?

Does the above error occur, if you run:

ln -s .git git
rm gnu.go
guix shell -D guix -CPWN
make check TESTS="tests/packages.scm"

Removing the git symlink lets me run the final command without any
errors!  Now only "fold-available-packages with/without cache" fails,
with or without the patch applied.

Cheers,
Herman




Information forwarded to guix-patches <at> gnu.org:
bug#75302; Package guix-patches. (Sun, 26 Jan 2025 16:35:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Herman Rimm <herman <at> rimm.ee>
Cc: 75302 <at> debbugs.gnu.org
Subject: Re: [bug#75302] [PATCH] packages: Match renamed origin fields.
Date: Sun, 26 Jan 2025 17:34:32 +0100
Hi,

Herman Rimm <herman <at> rimm.ee> skribis:

> Removing the git symlink lets me run the final command without any
> errors!  Now only "fold-available-packages with/without cache" fails,
> with or without the patch applied.

Fixed in 9f9e89a8ca0c18d0ca0292a3eb58d1da9a8cc119.

Ludo’.




This bug report was last modified 139 days ago.

Previous Next


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