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 3/4] upstream: Define ‘preferred-upstream-source’.
Date: Fri, 27 Dec 2024 11:56:42 +0100 [thread overview]
Message-ID: <a6ea94d01b5a0dba7b94ce82b9c4d233b3835a5d.1735296761.git.ludo@gnu.org> (raw)
In-Reply-To: <cover.1735296761.git.ludo@gnu.org>
* 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 <ludo@gnu.org>
+;;; Copyright © 2016, 2023-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2022 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; 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
next prev parent reply other threads:[~2024-12-27 10:58 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 ` [bug#75137] [PATCH 2/4] upstream: Extract ‘preferred-upstream-source-url’ Ludovic Courtès
2024-12-27 10:56 ` Ludovic Courtès [this message]
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a6ea94d01b5a0dba7b94ce82b9c4d233b3835a5d.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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).