From: "Ludovic Courtès" <ludo@gnu.org>
To: 75137@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>,
"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#75137] [PATCH 2/4] upstream: Extract ‘preferred-upstream-source-url’.
Date: Fri, 27 Dec 2024 11:56:41 +0100 [thread overview]
Message-ID: <bc5541c46b8720e0f34a58bea557b751de388915.1735296761.git.ludo@gnu.org> (raw)
In-Reply-To: <cover.1735296761.git.ludo@gnu.org>
* 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 <ludo@gnu.org>
+;;; Copyright © 2010-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
;;; Copyright © 2019, 2022-2024 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
@@ -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 <upstream-source>."
(match source
(($ <upstream-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
next prev parent reply other threads:[~2024-12-27 10:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-27 10:55 [bug#75137] [PATCH 0/4] 'package-with-upstream-version' can preserve archive type Ludovic Courtès
2024-12-27 10:56 ` [bug#75137] [PATCH 1/4] upstream: Switch to SRFI-71 Ludovic Courtès
2024-12-27 10:56 ` Ludovic Courtès [this message]
2024-12-27 10:56 ` [bug#75137] [PATCH 3/4] upstream: Define ‘preferred-upstream-source’ Ludovic Courtès
2024-12-27 10:56 ` [bug#75137] [PATCH 4/4] transformations: ‘package-with-upstream-version’ can preserve archive type Ludovic Courtès
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bc5541c46b8720e0f34a58bea557b751de388915.1735296761.git.ludo@gnu.org \
--to=ludo@gnu.org \
--cc=75137@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=guix@cbaines.net \
--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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.