unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#75302] [PATCH] packages: Match renamed origin fields.
@ 2025-01-02 21:03 Herman Rimm via Guix-patches via
  2025-01-04 20:59 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Herman Rimm via Guix-patches via @ 2025-01-02 21:03 UTC (permalink / raw)
  To: 75302
  Cc: Christopher Baines, Josselin Poiret, Ludovic Courtès,
	Mathieu Othacehe, Simon Tournier, Tobias Geerinckx-Rice

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





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

end of thread, other threads:[~2025-01-08 10:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-02 21:03 [bug#75302] [PATCH] packages: Match renamed origin fields Herman Rimm via Guix-patches via
2025-01-04 20:59 ` Ludovic Courtès
2025-01-06 18:48   ` Herman Rimm via Guix-patches via
2025-01-08 10:06     ` Ludovic Courtès

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