summaryrefslogtreecommitdiff
path: root/guix/substitutes.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-12-11 23:22:47 +0100
committerLudovic Courtès <ludo@gnu.org>2021-12-12 00:27:53 +0100
commite68466de122d94ac3fa75aae234cd5fd89482a5a (patch)
treeb285a7f9729ccf430e4319276b151d00da279d7f /guix/substitutes.scm
parent4dca1bae2767b049532e7434151686fdb7fab256 (diff)
downloadguix-patches-e68466de122d94ac3fa75aae234cd5fd89482a5a.tar
guix-patches-e68466de122d94ac3fa75aae234cd5fd89482a5a.tar.gz
substitutes: Build correct narinfo URLs for cache URLs without trailing slash.
Fixes <https://issues.guix.gnu.org/51441>. Reported by Z572 <873216071@qq.com> and Peng Mei Yu <pengmeiyu@riseup.net>. Previously, passing '--substitute-urls=https://mirror.sjtu.edu.cn/guix', without a trailing slash, would fail due to incorrectly constructed narinfo URLs. Users would have to explicitly add a trailing slash. * guix/substitutes.scm (narinfo-request): Ensure BASE has a trailing slash.
Diffstat (limited to 'guix/substitutes.scm')
-rw-r--r--guix/substitutes.scm6
1 files changed, 5 insertions, 1 deletions
diff --git a/guix/substitutes.scm b/guix/substitutes.scm
index a5c554acff..9014cf61ec 100644
--- a/guix/substitutes.scm
+++ b/guix/substitutes.scm
@@ -156,7 +156,11 @@ indicates that PATH is unavailable at CACHE-URL."
(define (narinfo-request cache-url path)
"Return an HTTP request for the narinfo of PATH at CACHE-URL."
- (let* ((base (string->uri cache-url))
+ ;; Ensure BASE has a trailing slash so that REF is correct regardless of
+ ;; whether the user-provided CACHE-URL has a trailing slash.
+ (let* ((base (string->uri (if (string-suffix? "/" cache-url)
+ cache-url
+ (string-append cache-url "/"))))
(ref (build-relative-ref
#:path (string-append (store-path-hash-part path) ".narinfo")))
(url (resolve-uri-reference ref base))