[PATCH] packages: Match renamed origin fields.

  • Open
  • quality assurance status badge
Details
2 participants
  • Herman Rimm
  • Ludovic Courtès
Owner
unassigned
Submitted by
Herman Rimm
Severity
normal
H
H
Herman Rimm wrote on 2 Jan 22:03 +0100
(address . guix-patches@gnu.org)
18c0be606434165893e9566caa34aff0f3776a0e.1735851535.git.herman@rimm.ee
* 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(-)

Toggle diff (88 lines)
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@dismail.de>
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2025 Herman Rimm <herman@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
L
L
Ludovic Courtès wrote 5 days ago
(name . Herman Rimm)(address . herman@rimm.ee)
87h66epa72.fsf@gnu.org
Hi,

Herman Rimm <herman@rimm.ee> skribis:

Toggle quote (5 lines)
> * 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…

Toggle quote (5 lines)
> 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’.
H
H
Herman Rimm wrote 3 days ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 75302@debbugs.gnu.org)
pir4su3fxpi27nh4zsrly5bzu4a6zadjruod6uct7phdm3eikf@xiblxxsl7a4q
Hello,

On Sat, Jan 04, 2025 at 09:59:13PM +0100, Ludovic Courtès wrote:
Toggle quote (2 lines)
> 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?

Toggle quote (8 lines)
> > 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
Attachment: packages.log
L
L
Ludovic Courtès wrote 45 hours ago
(name . Herman Rimm)(address . herman@rimm.ee)(address . 75302@debbugs.gnu.org)
87r05dvcvj.fsf@gnu.org
Hi,

Herman Rimm <herman@rimm.ee> skribis:

Toggle quote (6 lines)
> 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.

Toggle quote (6 lines)
> 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.

Toggle quote (8 lines)
> 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:

[...]

Toggle quote (5 lines)
> [ 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?

Toggle quote (6 lines)
> 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’.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 75302@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 75302
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch