From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.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 KBpEKRiIbmeEOQEA62LTzQ:P1 (envelope-from ) for ; Fri, 27 Dec 2024 10:57:28 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id KBpEKRiIbmeEOQEA62LTzQ (envelope-from ) for ; Fri, 27 Dec 2024 11:57:28 +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=Cg060fGT; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=OnB8wHVj; 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=1735297048; 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=5dhmNPTm6fbis7eIyf3TLOaRsZmZQ9vQmwW7Z+8wvos=; b=sQJo8SzahC6FiY+9H9fZ1ltcEHMjHZcWJWXMqS7VA4IKAbCGjnRfBY+Q3YkSAScIUS3hmi X0XyQyXQs+vWxuSO9VKnXsjw+Bvc+znqUpoKazAs46Csut0DzjzI8b/3dQzMlMJNJozGWD +BAXniBjcrqm6fhlH4nKH+ld6v56gOUKJfcPvUoKjtvmuhuouiZTB/dHAHpO8EufJhV+r1 Dzn2fEG9mg5AefAPv6sFIc5+/9MsFDYeFvdzIojND19kKRYINspD48hGxaJgR9lscMIjmz P2s2Nv5TA0kCp2vaKK9/vXoUqLF7hdg9A7QlfNy4A743tm39uD1x76XmFSijSA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=Cg060fGT; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=OnB8wHVj; 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=1735297048; a=rsa-sha256; cv=none; b=L+wtEAgYudhs5yJb3xVRKAEfkhSATa7RdqwAgP7fmH3V4iQpZt1A85D33Umfi9HxqCnKnR jm41/i8G2bSUzBOp8bytA6sF/sAZEcClPvu1EmX16LPh6gqt3ewDp7aUwG4pyltWyNTroZ fMNKcHeRQFt3Mm/nXIzgHMxMHwUB4uxfXmtvuwx8/UQqEi7pmBF6KOPrM3ZVah7DFm12Oq OtvVyN5WqkrfgbLGNoWvL56ZyJCOahwPwbKuEtCTne/hWnZPNj2yWtMt8vHsJijzfQYwqa iDPAP1Zhvw35aolRQiFChoTganf2s6/isrgyH8V9fmokm5MRhY3ryLxYWFPEvA== 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 401C03025D for ; Fri, 27 Dec 2024 11:57:28 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tR81i-0002md-IW; Fri, 27 Dec 2024 05:57:06 -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 1tR81g-0002lt-R0 for guix-patches@gnu.org; Fri, 27 Dec 2024 05:57: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 1tR81g-0003ux-IJ; Fri, 27 Dec 2024 05:57:04 -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=5dhmNPTm6fbis7eIyf3TLOaRsZmZQ9vQmwW7Z+8wvos=; b=Cg060fGTStPkN0CbG0bg5WcSrzWZp5z5F37INXMF7aX5nlGEW2vLY3tSCT4/cUrmL/OUPdztCqpAWzd9zYTlFKCxHCwFsvBXnYBTB6wcjpdPE54n3LjqfX8EDoBnTxPO/zesGEKrmcJCyEppu1oq3DS1dEE0yadAOT2bRWt2v8ifs70cMg4dCFiJcECqeglPwTnnSD/PMhRK+tXlUxHGuWwhuf68CF82ZzrelWGMakRpzbbPE0IdkXlKUIsHz+uczqllE9uMYPqCFONnC1ZXtpXBVy6EzeR0M/rXrlY7VjVyN+b7xd9KIcXeYvY/faQ45qWL6vwO41k6+JDKBnyZwg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tR81e-0001dX-AZ; Fri, 27 Dec 2024 05:57:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75137] [PATCH 2/4] upstream: Extract =?UTF-8?Q?=E2=80=98preferred-upstream-source-url=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:57:02 +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.17352970206274 (code B ref 75137); Fri, 27 Dec 2024 10:57:02 +0000 Received: (at 75137) by debbugs.gnu.org; 27 Dec 2024 10:57:00 +0000 Received: from localhost ([127.0.0.1]:44812 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tR81b-0001cw-Rs for submit@debbugs.gnu.org; Fri, 27 Dec 2024 05:57:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tR81a-0001cQ-0E for 75137@debbugs.gnu.org; Fri, 27 Dec 2024 05:56:58 -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 1tR81U-0003u3-Ov; Fri, 27 Dec 2024 05:56:52 -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=5dhmNPTm6fbis7eIyf3TLOaRsZmZQ9vQmwW7Z+8wvos=; b=OnB8wHVjaYPDbpwsst9K +AcvcexG/mvQOvRvypztJCLEBJngy3D/FVyYygyNBYygVO91mI1WxbOw61cAzIxkRbV/QlNGurhUr SEpfrrjUtliZAr4fmHn+90KAPH/bE2lSmy14TCzL80ekWcVvPGojzA3bznZqTL4ZBZ8D4/fZaM7vQ qqLm+1MA2FHYA0HdFcDDsojuRMcBj+ETqgnaQhpGuJ8FTK7bVrGYWXm/DZuowPKkEPM4nbEGBUAEL SvIX2+QPenP+lD80k71kFaENC5H+lzmurTOuLN13+4iuAp+E9Hh8Cd+zJkR3wqcWMPQrM9rXkSqNa HDZqnjHetKxxiw==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 27 Dec 2024 11:56:41 +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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: 0.09 X-Spam-Score: 0.09 X-Migadu-Queue-Id: 401C03025D X-TUID: qwCmUggC9IFj * guix/upstream.scm (preferred-upstream-source-url): New procedure. (package-update/url-fetch): Use it. Change-Id: I229cdf7668567e30ca156b3d65b77c90ead8bb05 --- guix/upstream.scm | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/guix/upstream.scm b/guix/upstream.scm index d680199578..a6659c3b14 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2010-2023 Ludovic Courtès +;;; Copyright © 2010-2024 Ludovic Courtès ;;; Copyright © 2015 Alex Kost ;;; Copyright © 2019, 2022-2024 Ricardo Wurmus ;;; Copyright © 2021 Sarah Morgensen @@ -430,23 +430,29 @@ (define (package-archive-type package) (string-contains extension "tar")) extension))))) +(define (preferred-upstream-source-url source package) + "Return two values: a source URL that matches the archive type of +PACKAGE (gz, xz, bz2, etc.) and the corresponding signature URL or #f if there +is no signature. Return #f and #f when this is not applicable." + (let ((archive-type (package-archive-type package))) + (find2 (lambda (url sig-url) + ;; Some URIs lack a file extension, like + ;; 'https://crates.io/???/0.1/download'. In that case, pick the + ;; first URL. + (or (not archive-type) + (string-suffix? archive-type url))) + (upstream-source-urls source) + (or (upstream-source-signature-urls source) + (circular-list #f))))) + (define* (package-update/url-fetch store package source #:key key-download key-server) "Return the version, tarball, and SOURCE, to update PACKAGE to SOURCE, an ." (match source (($ _ version urls signature-urls) - (let* ((archive-type (package-archive-type package)) - (url signature-url - ;; Try to find a URL that matches ARCHIVE-TYPE. - (find2 (lambda (url sig-url) - ;; Some URIs lack a file extension, like - ;; 'https://crates.io/???/0.1/download'. In that - ;; case, pick the first URL. - (or (not archive-type) - (string-suffix? archive-type url))) - urls - (or signature-urls (circular-list #f))))) + (let ((url signature-url + (preferred-upstream-source-url source package))) ;; If none of URLS matches ARCHIVE-TYPE, then URL is #f; in that case, ;; pick up the first element of URLS. (let ((tarball (download-tarball store -- 2.46.0