unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Herman Rimm via Guix-patches via <guix-patches@gnu.org>
To: 75302@debbugs.gnu.org
Cc: "Christopher Baines" <guix@cbaines.net>,
	"Josselin Poiret" <dev@jpoiret.xyz>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Mathieu Othacehe" <othacehe@gnu.org>,
	"Simon Tournier" <zimon.toutoune@gmail.com>,
	"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#75302] [PATCH] packages: Match renamed origin fields.
Date: Thu,  2 Jan 2025 22:03:30 +0100	[thread overview]
Message-ID: <18c0be606434165893e9566caa34aff0f3776a0e.1735851535.git.herman@rimm.ee> (raw)

* 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





             reply	other threads:[~2025-01-02 21:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-02 21:03 Herman Rimm via Guix-patches via [this message]
2025-01-04 20:59 ` [bug#75302] [PATCH] packages: Match renamed origin fields Ludovic Courtès
2025-01-06 18:48   ` Herman Rimm via Guix-patches via
2025-01-08 10:06     ` Ludovic Courtès
2025-01-21 18:32       ` Herman Rimm via Guix-patches via
2025-01-21 20:21       ` Herman Rimm via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18c0be606434165893e9566caa34aff0f3776a0e.1735851535.git.herman@rimm.ee \
    --to=guix-patches@gnu.org \
    --cc=75302@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=herman@rimm.ee \
    --cc=ludo@gnu.org \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).