From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id AHt7MayMSWcyLQAAe85BDQ:P1 (envelope-from ) for ; Fri, 29 Nov 2024 09:43:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id AHt7MayMSWcyLQAAe85BDQ (envelope-from ) for ; Fri, 29 Nov 2024 10:43:08 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=cqfTbGal; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=XwJMEH3P; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6B344865F8 for ; Fri, 29 Nov 2024 10:43:08 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGxWS-0000uM-UX; Fri, 29 Nov 2024 04:42:48 -0500 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 1tGxWF-0000kd-2m for guix-patches@gnu.org; Fri, 29 Nov 2024 04:42:37 -0500 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 1tGxVq-0004aM-12; Fri, 29 Nov 2024 04:42:29 -0500 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=8mPyDNRRzYPXx/ZHBp28evdnsI7YwlIPsD3iNYPaD7c=; b=cqfTbGalUugeiwVfP2XUl5deVSfG9YcoyV0tizv+KQD8qiZVWpnU/Q7ptfiJ7FmfdMqtXJ7O/LuAw1RzVegJFMGBJoEVgfuuXIkQGEdGMO4DsOuZ2JXK3IlJ2hF+bCKMyJvf7CAdaQVtXEPRBwK6UDd3Qm69/NDH0LCv4/haqczaDlD9s6gntXX8IRzwJsMG0RQ6cNMX4+5a3P6crdL06pBK3sG1t9sUSGRMD5jRx9RcRhdtdgSBccA4865/tC4tQ2CRW5yH4/58TPyOm8jdUm/BeMDSuSz3d4TBfCv8KgU8e9H4xMgs2p/2yRQZ6Ok9+jfXY1LMlJpKvu1vTBNZQQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tGxVp-0005y3-5R; Fri, 29 Nov 2024 04:42:09 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74542] [PATCH v2 14/16] transformations: =?UTF-8?Q?=E2=80=98package-with-upstream-version=E2=80=99?= can preserve patches. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 29 Nov 2024 09:42:09 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74542 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74542@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 74542-submit@debbugs.gnu.org id=B74542.173287328822743 (code B ref 74542); Fri, 29 Nov 2024 09:42:09 +0000 Received: (at 74542) by debbugs.gnu.org; 29 Nov 2024 09:41:28 +0000 Received: from localhost ([127.0.0.1]:41079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGxVA-0005uf-9u for submit@debbugs.gnu.org; Fri, 29 Nov 2024 04:41:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGxUq-0005rR-Nf for 74542@debbugs.gnu.org; Fri, 29 Nov 2024 04:41:09 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGxUl-0003ve-HH; Fri, 29 Nov 2024 04:41:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=8mPyDNRRzYPXx/ZHBp28evdnsI7YwlIPsD3iNYPaD7c=; b=XwJMEH3PZJ3SgRPumqDq KCdG5Pd0aq5E0AEbvffT/Kmfc/0Of29kKIEqkORxKkbtaMPTHmJLxi0ic44QT+GJtzUBjLNQwh8st j4bR5hzeDZrRagu2kf03gbIKpGoq4Dt6j2CQ3e8RF80SkRxZFEINg7JUJN8eGtW/NjzAH6P8pg1u2 N7UPfEXQlf5oIf1bS2DNhxZ4qYDStyEdDppd0iw7vLzA3L9suYf0NlOmDv8Du7tpRqs4kv5b/gNAy d5XGsEc6jCmLkcQJaIx0YalttKoqDQ6x7RPdbUclo1MvLHG/WIms3hWAsjLtPoAk7VjsdH01LpybY Y51CZvcVtBVOCQ==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 29 Nov 2024 10:40:17 +0100 Message-ID: <16a63273fb59de165d2908bd370e9314b757d13f.1732872499.git.ludo@gnu.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 2.16 X-Spam-Score: 2.16 X-Migadu-Queue-Id: 6B344865F8 X-Migadu-Scanner: mx12.migadu.com X-TUID: /NCkkM1vbdwV * guix/transformations.scm (upstream-fetch): New procedure. (package-with-upstream-version): Add #:preserve-patches? and honor it. Change-Id: Ib56b84957d8bdad2eebe2551e2a6e477506fc55e --- guix/transformations.scm | 25 ++++++++++++++++++++++--- tests/transformations.scm | 31 ++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/guix/transformations.scm b/guix/transformations.scm index 9dfc4402c5..a32aad39f2 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -848,9 +848,20 @@ (define (transform-package-patches specs) (rewrite obj) obj))) -(define* (package-with-upstream-version p #:optional version) +(define* (upstream-fetch source hash-algo hash + #:optional name + #:key (system (%current-system)) + (guile (default-guile)) + executable?) + "This origin method simply downloads SOURCE, an record." + (lower-object source system)) + +(define* (package-with-upstream-version p #:optional version + #:key (preserve-patches? #f)) "Return package P changed to use the given upstream VERSION or, if VERSION -is #f, the latest known upstream version." +is #f, the latest known upstream version. When PRESERVE-PATCHES? is true, +preserve patches and snippets found in the source of P, provided it's an +origin." (let ((source (package-latest-release p #:version version))) (cond ((not source) (if version @@ -885,7 +896,15 @@ (define* (package-with-upstream-version p #:optional version) (package (inherit p) (version (upstream-source-version source)) - (source source)))))) + (source (if (and preserve-patches? + (origin? (package-source p))) + ;; Inherit P's origin so snippets and patches are + ;; applied as if we had run 'guix refresh -u'. + (origin + (inherit (package-source p)) + (method upstream-fetch) + (uri source)) + source))))))) (define (transform-package-latest specs) "Return a procedure that rewrites package graphs such that those in SPECS diff --git a/tests/transformations.scm b/tests/transformations.scm index 755211d65d..5285d98f17 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016-2017, 2019-2023 Ludovic Courtès +;;; Copyright © 2016-2017, 2019-2024 Ludovic Courtès ;;; Copyright © 2021 Marius Bakke ;;; ;;; This file is part of GNU Guix. @@ -497,6 +497,35 @@ (define* (depends-on-toolchain? p #:optional (toolchain "gcc-toolchain")) (let ((new (t coreutils))) (assq-ref (package-properties new) 'transformations)))) +(test-equal "package-with-upstream-version" + '("42.0" "42.0" + ("http://example.org") + ("a" "b") (do something)) + (mock ((guix upstream) %updaters + (delay (list (upstream-updater + (name 'dummy) + (pred (const #t)) + (description "") + (import (const (upstream-source + (package "foo") + (version "42.0") + (urls '("http://example.org"))))))))) + (let* ((old (dummy-package "foo" (version "1.0") + (source (dummy-origin + (patches '("a" "b")) + (snippet '(do something)))))) + (new (package-with-upstream-version old)) + (new+patches (package-with-upstream-version + old #:preserve-patches? #t))) + (list (package-version new) (package-version new+patches) + + ;; Source of NEW is directly an . + (upstream-source-urls (package-source new)) + + ;; Check that #:preserve-patches? #t gave us an origin. + (origin-patches (package-source new+patches)) + (origin-snippet (package-source new+patches)))))) + (test-equal "options->transformation, with-latest" "42.0" (mock ((guix upstream) %updaters -- 2.46.0