From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id WEfIFVKIbmcTHwEAe85BDQ:P1 (envelope-from ) for ; Fri, 27 Dec 2024 10:58:26 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id WEfIFVKIbmcTHwEAe85BDQ (envelope-from ) for ; Fri, 27 Dec 2024 11:58:26 +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="n/5rdSbF"; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=ZzXKG7QA; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1735297106; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=RTWZ57pnH1octakJPOtakRXEzLzV4TgFGPPTJchsQ1c=; b=lQ2e0PL3kI8dErwOtHk4qgFz9FifZhcaXfyyuNl513LHxoMea1Zws24KNiBSE711mhHot7 J0pyqKkEfK5JiRT57Rs8xzJPIEgZwDC+RICo+JHB24Tc2nM20PAWd3c+xo/XygR/HwJFXS 6m0yyabZm6eQNScbmW/3hxa5Sr+GZsZdXyv0vs2pD7ifBDf5MWyaNO9E4Qr2ztQ/9fwauy 9GpHzkf6tS62aHaEFoKQkvrVV+My5RY3H/iPY/ueJpFvGZl3hcLn6FYjD6PY9yLqyKdiQN el9WzzaODVhaJ0JyOORTsJv05S7gwqOeQPvJeTaIOp2L5m+lVeVtZr1hz0/kTg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b="n/5rdSbF"; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=ZzXKG7QA; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1735297106; a=rsa-sha256; cv=none; b=ltX2J6GpQmTSW3SZmTNwjppUSgHlMyrwSPSewmtwrhwEbulGTfogkRx1nXMetRGp0LcrI2 U6rv7Ec6HdXZr8Zi79v3nlQ7qs0VMyxf658fvaL0JYoZH5kfw4ciZ6snKB9guduc+y5Sjv I/layvWTcx3wjvAqOwcip4jESKVyXuXIaeaReB8ct9OauQMkld6Pm+4vew03iQ8yuWrtbq 3Iq2XGoxu0JcFOMpR2R1EU3E0Jq5r9dtIk51Gg1USnVlDIKQwNCh7yviWHbCao8piuXeBi 3O1Rg5dxT15eB6pS4y40GKH7NbMxlXXJ9Owsh578hcgdbgx4FQXLdIaAeGTCxg== 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 AD0E391A67 for ; Fri, 27 Dec 2024 11:58:25 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tR82f-00030P-K0; Fri, 27 Dec 2024 05:58:05 -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 1tR82e-000304-1h for guix-patches@gnu.org; Fri, 27 Dec 2024 05:58:04 -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 1tR82d-0003yX-Lg; Fri, 27 Dec 2024 05:58:03 -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=RTWZ57pnH1octakJPOtakRXEzLzV4TgFGPPTJchsQ1c=; b=n/5rdSbFKrLcOf7ROoKgN/62OwTvg9F5beaVC7CjP3vWVVrCfUMHlK9BpnOP7mFJgTJ0PhMKCQIkjduQYQBGeplkIEkfiVt5N3AkQup13ZBdmjW07A40xVVkX/7PN6gJQcrChhMywyTgMNwpjkQkLtR1Wc1grxVpLrBWWX0UK+LfvhEta1rIpzWxcIeJMQ8+1yAw1/406MVwSGpHsybzHUEXbuezpZ9pHPgW3pzefUdXznTGHDnLP6j3hudiqULBLH900EIc8ZuM3mqzAEUBfRa/O4/tpidl5R5YHXLAVGtdJigVe5D19cVfp+E3FlRj8z9UgZ/w70qkSabsAG3ZtA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tR82b-0001fa-Vp; Fri, 27 Dec 2024 05:58:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75137] [PATCH 3/4] upstream: Define =?UTF-8?Q?=E2=80=98preferred-upstream-source=E2=80=99.?= 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, 27 Dec 2024 10:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75137 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75137@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 75137-submit@debbugs.gnu.org id=B75137.17352970296335 (code B ref 75137); Fri, 27 Dec 2024 10:58:01 +0000 Received: (at 75137) by debbugs.gnu.org; 27 Dec 2024 10:57:09 +0000 Received: from localhost ([127.0.0.1]:44824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tR81j-0001e1-Dz for submit@debbugs.gnu.org; Fri, 27 Dec 2024 05:57:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32850) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tR81a-0001cT-QO for 75137@debbugs.gnu.org; Fri, 27 Dec 2024 05:56:59 -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 1tR81V-0003uE-Ja; Fri, 27 Dec 2024 05:56:53 -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=RTWZ57pnH1octakJPOtakRXEzLzV4TgFGPPTJchsQ1c=; b=ZzXKG7QAWNcLc5QmDQD+ Sq/wG2Ar6OeEAdBDS0C5+pDNtJMBNAJOp/oGIKrwlLpZb9OG7vhfo9VD6Y7Zh0+ZXA/cXa6fv/sz0 HC/HgZHVtHtysOio7RpM8/SLXwu19jKt4o4ckRwWLTPiXV6SZg8zXDC8CclYY7AnAk8yPkrnMOx68 MQ741ErwuD2GG69nQhZxTQqw/q43BIz+wDRnjOF9dBgFq0LUNRWUq1dW0Duz1FViTpYrx3NmRZPGc 2MRavjv59Jk1pq9b0g1DcaBKWRGYeA93aDMsxHJVvgtaScDlcVY3a2cVfb3y8sbWNOkQ/D6uVCpqK xzPjpJJm8jeN8Q==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 27 Dec 2024 11:56:42 +0100 Message-ID: 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -6.11 X-Spam-Score: -6.11 X-Migadu-Queue-Id: AD0E391A67 X-Migadu-Scanner: mx10.migadu.com X-TUID: G++qlBiz9FuI * guix/upstream.scm (preferred-upstream-source): New procedure. * tests/upstream.scm ("preferred-upstream-source"): New test. Change-Id: I4b48b44f1aa233d2e99bfe2e1359a670297efae8 --- guix/upstream.scm | 12 ++++++++++++ tests/upstream.scm | 21 ++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/guix/upstream.scm b/guix/upstream.scm index a6659c3b14..19c5efc21b 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -76,6 +76,7 @@ (define-module (guix upstream) url-predicate url-prefix-predicate coalesce-sources + preferred-upstream-source upstream-updater upstream-updater? @@ -445,6 +446,17 @@ (define (preferred-upstream-source-url source package) (or (upstream-source-signature-urls source) (circular-list #f))))) +(define (preferred-upstream-source source package) + "Return a variant of SOURCE that uses the same archive type as PACKAGE's +source (gz, xz, zst, etc.). Return SOURCE if this is not applicable." + (let ((url signature-url (preferred-upstream-source-url source package))) + (if url + (upstream-source + (inherit source) + (urls (list url)) + (signature-urls (and=> signature-url list))) + source))) + (define* (package-update/url-fetch store package source #:key key-download key-server) "Return the version, tarball, and SOURCE, to update PACKAGE to diff --git a/tests/upstream.scm b/tests/upstream.scm index a94bb66068..c75ab091e5 100644 --- a/tests/upstream.scm +++ b/tests/upstream.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016, 2023 Ludovic Courtès +;;; Copyright © 2016, 2023-2024 Ludovic Courtès ;;; Copyright © 2022 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. @@ -26,6 +26,7 @@ (define-module (test-upstream) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix upstream) #:use-module (guix tests) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-64) #:use-module (ice-9 match)) @@ -55,4 +56,22 @@ (define-module (test-upstream) (signature-urls '("ftp://example.org/foo-1.tar.xz.sig"))))))) +(test-equal "preferred-upstream-source" + '(("http://example.org/foo-2.0.tar.xz") + ("http://example.org/foo-2.0.tar.xz.sig")) + (let* ((package (dummy-package + "foo" + (version "1.0") + (source + (dummy-origin (uri "http://example.org/foo-1.0.tar.xz"))))) + (source (upstream-source + (package "foo") + (version "2.0") + (urls '("http://example.org/foo-2.0.tar.gz" + "http://example.org/foo-2.0.tar.xz")) + (signature-urls (map (cut string-append <> ".sig") urls)))) + (preferred (preferred-upstream-source source package))) + (list (upstream-source-urls preferred) + (upstream-source-signature-urls preferred)))) + (test-end) -- 2.46.0