summaryrefslogtreecommitdiff
path: root/guix/scripts/download.scm
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2019-09-27 19:11:27 +0200
committerMarius Bakke <mbakke@fastmail.com>2019-09-27 19:11:27 +0200
commite7f62a41b245ca30404c54f3f77930336627c2f7 (patch)
tree4b2a24dcc84f137b92ca581dba96cf7abac70439 /guix/scripts/download.scm
parent1fdab9d3b3e78b0c90b52567be5535a861a7273d (diff)
parentb48eb1e934f1d457ff6a0fec1c572bb12ed15fab (diff)
downloadguix-patches-e7f62a41b245ca30404c54f3f77930336627c2f7.tar
guix-patches-e7f62a41b245ca30404c54f3f77930336627c2f7.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/scripts/download.scm')
-rw-r--r--guix/scripts/download.scm15
1 files changed, 15 insertions, 0 deletions
diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index d8fe71ce12..22cd75ea0b 100644
--- a/guix/scripts/download.scm
+++ b/guix/scripts/download.scm
@@ -33,6 +33,7 @@
#:use-module (web uri)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-14)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-37)
#:use-module (rnrs bytevectors)
@@ -54,9 +55,23 @@
(url-fetch url file #:mirrors %mirrors)))
file))
+(define (ensure-valid-store-file-name name)
+ "Replace any character not allowed in a stror name by an underscore."
+
+ (define valid
+ ;; according to nix/libstore/store-api.cc
+ (string->char-set (string-append "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789" "+-._?=")))
+ (string-map (lambda (c)
+ (if (char-set-contains? valid c) c #\_))
+ name))
+
+
(define* (download-to-store* url #:key (verify-certificate? #t))
(with-store store
(download-to-store store url
+ (ensure-valid-store-file-name (basename url))
#:verify-certificate? verify-certificate?)))
(define %default-options