From patchwork Sat Jul 26 02:39:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 43279 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D8F6627BC4B; Sat, 26 Jul 2025 03:42:50 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2E7EB27BC4D for ; Sat, 26 Jul 2025 03:42:50 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufUqp-0000Jz-5k; Fri, 25 Jul 2025 22:41:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufUqk-0000Ek-Ke for guix-patches@gnu.org; Fri, 25 Jul 2025 22:41:26 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ufUqk-0005RP-Bd for guix-patches@gnu.org; Fri, 25 Jul 2025 22:41:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=XC/0DGPZEuAco+0f4PlDOP96qV1K7oVgrSzbFdmH88g=; b=ZYxruwAg5TxTGdw91m/l1S58HU5ImQNazorMXPaIGjHyXkOg+UUz0Su7QLj5MIKbVUUGrlOqliSK5Gh7wh/xUhk8+C/cMHvdXXlau405ljiBnbIzvQJesn3PkhoG/VAM5I6OibvLAN/JsR2IAHOlG+xE1t1KGvjzXWQiGnGavf4LIe53rVgUkAVwqHZp4kMnKNtu0bYPoSkaR+p497p2SXn9GWWXIqt4boL/CRLGSMl2IhnxD4FgRE4GSu8SjvL/Nwc+Sxh/nnVLwOrhyRzUT1uwzmPdp2Ul1IEQtOElpFA+Qcen0FaSJU2U7OsEziaUpVS4qvCU4plCGftld1c+Lw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ufUqj-0007u5-Oi for guix-patches@gnu.org; Fri, 25 Jul 2025 22:41:26 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#79099] [PATCH 04/34] POC git-version Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 26 Jul 2025 02:41:25 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79099 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 79099@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 79099-submit@debbugs.gnu.org id=B79099.175349767730311 (code B ref 79099); Sat, 26 Jul 2025 02:41:25 +0000 Received: (at 79099) by debbugs.gnu.org; 26 Jul 2025 02:41:17 +0000 Received: from localhost ([127.0.0.1]:38129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ufUqZ-0007sW-A3 for submit@debbugs.gnu.org; Fri, 25 Jul 2025 22:41:17 -0400 Received: from 10.mo563.mail-out.ovh.net ([46.105.78.6]:37599) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ufUpQ-0007eC-Fq for 79099@debbugs.gnu.org; Fri, 25 Jul 2025 22:40:33 -0400 Received: from director3.derp.mail-out.ovh.net (director3.derp.mail-out.ovh.net [152.228.215.222]) by mo563.mail-out.ovh.net (Postfix) with ESMTPS id 4bppqh30Rlz5xkp; Sat, 26 Jul 2025 02:40:00 +0000 (UTC) Received: from director3.derp.mail-out.ovh.net (director3.derp.mail-out.ovh.net. [127.0.0.1]) by director3.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for <79099@debbugs.gnu.org>; Sat, 26 Jul 2025 02:40:00 +0000 (UTC) Received: from mta3.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.110.0.122]) by director3.derp.mail-out.ovh.net (Postfix) with ESMTPS id 4bppqh0Nx2z5wFQ; Sat, 26 Jul 2025 02:40:00 +0000 (UTC) Received: from ngraves.fr (unknown [10.1.6.6]) by mta3.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id 97D22942E1A; Sat, 26 Jul 2025 02:39:59 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-114S008fd3a3c8a-7a1f-4693-9c49-681515cef854, 7BFD41D65738CBEA4850BE66907D66307393418F) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 90.92.117.144 Date: Sat, 26 Jul 2025 04:39:10 +0200 Message-ID: <20250726023951.11862-4-ngraves@ngraves.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250726023951.11862-1-ngraves@ngraves.fr> References: <20250726023951.11862-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 4611686020151239394 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdekhedvfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpedvffdviedtheelfeetfeevtdffueffvddtgfejkefggfetgeeigfegudeijedvheenucffohhmrghinhepghhnuhdrohhrghenucfkphepuddvjedrtddrtddruddpledtrdelvddruddujedrudeggeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepjeeltdelleesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpoffvtefjohhsthepmhhoheeifegmpdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=XC/0DGPZEuAco+0f4PlDOP96qV1K7oVgrSzbFdmH88g=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1753497600; v=1; b=44ruGYiFFioB9+52Vlork4n13/VdT4CmZylZqOg8sU0w9zUiFlSL/9Xii+aSJJlI08V4kz94 BdNbC80yJkjCGx2akksMF0fSRlcOxPC03jG4hthXDq3xLp5+chaohKWK5EIVFYKPFwZtnm0oDbN PcejA3UAW20OFsIuh+R6i6y4Vjlo2Rgxh4OA3NadHC3XClXlljLyZz0kjhttHf3yy1cysZePaln uKUZgsiMwK7/bqws7AXjuXgQb6vUKt7R3ZOr3rBocKOYJx6J9/HopAdpCoLRz5GIFj4Zkiyidk4 Md3ORz7BlAWur+oOo0orSPlAETG/pCMUXSg34bc5Qe/ag== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches --- guix/git-download.scm | 30 +++++++++++++++++++++---- guix/packages.scm | 51 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 72 insertions(+), 9 deletions(-) diff --git a/guix/git-download.scm b/guix/git-download.scm index ae2073ea06c..838bf336b97 100644 --- a/guix/git-download.scm +++ b/guix/git-download.scm @@ -22,6 +22,7 @@ ;;; along with GNU Guix. If not, see . (define-module (guix git-download) + #:use-module (guix deprecation) #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix monads) @@ -59,7 +60,14 @@ (define-module (guix git-download) git-fetch/lfs git-version git-file-name - git-predicate)) + git-predicate + vc-version) + #:re-export (git-version* + git-version? + make-git-version + git-version-semantic + git-version-revision + git-version-commit)) ;;; Commentary: ;;; @@ -283,8 +291,8 @@ (define* (git-fetch ref hash-algo hash #:guile guile #:git git)))) -(define (git-version version revision commit) - "Return the version string for packages using git-download." +(define (vc-version version revision commit) + "Return the canonical version string for packages using version control." ;; git-version is almost exclusively executed while modules are being loaded. ;; This makes any errors hide their backtrace. Avoid the mysterious error ;; "Value out of range 0 to N: 7" when the commit ID is too short, which @@ -296,9 +304,23 @@ (define (git-version version revision commit) (&message (message "git-version: commit ID unexpectedly short"))))) (string-append version "-" revision "." (string-take commit 7))) +(define-deprecated (git-version version revision commit) + ;; XXX: Should actually recommend git-version* instead, but the macro + ;; expander doesn't like that. Still, it's OK to migrate to + ;; make-git-version in the meantime. + make-git-version + (vc-version version revision commit)) + (define (git-file-name name version) "Return the file-name for packages using git-download." - (string-append name "-" version "-checkout")) + (string-append + name "-" + (match version + (($ semantic revision commit) + (vc-version semantic revision commit)) + (semantic + semantic)) + "-checkout")) ;;; diff --git a/guix/packages.scm b/guix/packages.scm index 1d5986c5f42..a430f4ebc22 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -44,8 +44,9 @@ (define-module (guix packages) #:use-module (guix search-paths) #:use-module (guix sets) #:use-module (guix deprecation) - #:use-module ((guix diagnostics) - #:select (formatted-message define-with-syntax-properties)) + #:use-module ((guix diagnostics) #:select (define-with-syntax-properties + formatted-message + leave)) #:autoload (guix licenses) (license?) #:use-module (guix i18n) #:use-module (ice-9 match) @@ -201,7 +202,15 @@ (define-module (guix packages) package-file package->derivation package->cross-derivation - origin->derivation)) + origin->derivation + + + git-version* + git-version? + make-git-version + git-version-semantic + git-version-revision + git-version-commit)) ;; The 'source-module-closure' procedure ca. 1.2.0 did not recognize ;; #:re-export-and-replace: . @@ -614,7 +623,8 @@ (define-record-type* package? this-package (name package-name) ; string - (version package-version) ; string + (version %package-version ; instance or string + (sanitize warn-unexpected-package-version)) (source package-source) ; instance (build-system package-build-system) ; instance (arguments package-arguments ; arguments for the build method @@ -1786,7 +1796,9 @@ (define* (package->bag package #:optional ;; name from the package version in various user-facing parts ;; of Guix, checkStoreName (in nix/libstore/store-api.cc) ;; prohibits the use of "@", so use "-" instead. - (or (make-bag build-system (string-append name "-" version) + (or (make-bag build-system + (string-append name "-" + (package-version package)) #:system system #:target target #:source source @@ -2201,3 +2213,32 @@ (define package-source-derivation ;somewhat deprecated (add-to-store store (basename file) #t "sha256" file)) (_ (lower store source system)))))) + +(define-record-type* + git-version* ; TODO Rename to git-version at the end of the deprecation. + make-git-version + git-version? this-git-version + (semantic git-version-semantic) ; string + (revision git-version-revision) ; string + (commit git-version-commit)) ; string + +(define (package-version package) + "Return the canonical string version of the package." + (match (%package-version package) + (($ version revision commit) + ;; XXX: Copied from (@ (guix git-download) git-version). + (when (< (string-length commit) 7) + (raise + (condition + (&message (message "git-version: commit ID unexpectedly short"))))) + (string-append version "-" revision "." (string-take commit 7))) + (version + version))) + +(define-with-syntax-properties (warn-unexpected-package-version + (value properties)) + (unless (or (string? value) (git-version? value)) + (leave (source-properties->location properties) + (G_ "The package-version object's implementation field supports \ +only instances and strings."))) + value)