aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-10-17 22:52:11 +0200
committerLudovic Courtès <ludo@gnu.org>2022-10-17 23:15:07 +0200
commit30ac571eac98b491b84a17a38c2401eea98d834e (patch)
tree58bad13b613e82451e2117d054b3a00d68a509f5
parent8599fccef84a2930280a5b2844829cfbafd593b0 (diff)
downloadguix-30ac571eac98b491b84a17a38c2401eea98d834e.tar
guix-30ac571eac98b491b84a17a38c2401eea98d834e.tar.gz
svn-download: Pass multi-fetch parameters through environment variables.
* guix/svn-download.scm (svn-multi-fetch)[build]: Check for environment variables instead of splicing REF fields. Pass #:script-name and #:env-vars to 'gexp->derivation'.
-rw-r--r--guix/svn-download.scm62
1 files changed, 44 insertions, 18 deletions
diff --git a/guix/svn-download.scm b/guix/svn-download.scm
index 1c369e7f9a..c507c00caa 100644
--- a/guix/svn-download.scm
+++ b/guix/svn-download.scm
@@ -145,27 +145,53 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
#~(begin
(use-modules (guix build svn)
(guix build utils)
- (srfi srfi-1))
- (every (lambda (location)
- ;; The directory must exist if we are to fetch only a
- ;; single file.
- (unless (string-suffix? "/" location)
- (mkdir-p (string-append #$output "/" (dirname location))))
- (svn-fetch (string-append '#$(svn-multi-reference-url ref)
- "/" location)
- '#$(svn-multi-reference-revision ref)
- (if (string-suffix? "/" location)
- (string-append #$output "/" location)
- (string-append #$output "/" (dirname location)))
- #:svn-command (string-append #+svn "/bin/svn")
- #:recursive?
- #$(svn-multi-reference-recursive? ref)
- #:user-name #$(svn-multi-reference-user-name ref)
- #:password #$(svn-multi-reference-password ref)))
- '#$(sexp->gexp (svn-multi-reference-locations ref))))))
+ (srfi srfi-1)
+ (ice-9 match))
+
+ (for-each (lambda (location)
+ ;; The directory must exist if we are to fetch only a
+ ;; single file.
+ (unless (string-suffix? "/" location)
+ (mkdir-p (string-append #$output "/" (dirname location))))
+ (svn-fetch (string-append (getenv "svn url") "/" location)
+ (string->number (getenv "svn revision"))
+ (if (string-suffix? "/" location)
+ (string-append #$output "/" location)
+ (string-append #$output "/" (dirname location)))
+ #:svn-command #+(file-append svn "/bin/svn")
+ #:recursive? (match (getenv "svn recursive?")
+ ("yes" #t)
+ (_ #f))
+ #:user-name (getenv "svn user name")
+ #:password (getenv "svn password")))
+ (call-with-input-string (getenv "svn locations")
+ read)))))
(mlet %store-monad ((guile (package->derivation guile system)))
(gexp->derivation (or name "svn-checkout") build
+
+ ;; Use environment variables and a fixed script name so
+ ;; there's only one script in store for all the
+ ;; downloads.
+ #:script-name "svn-multi-download"
+ #:env-vars
+ `(("svn url" . ,(svn-multi-reference-url ref))
+ ("svn locations"
+ . ,(object->string (svn-multi-reference-locations ref)))
+ ("svn revision"
+ . ,(number->string (svn-multi-reference-revision ref)))
+ ,@(if (svn-multi-reference-recursive? ref)
+ `(("svn recursive?" . "yes"))
+ '())
+ ,@(if (svn-multi-reference-user-name ref)
+ `(("svn user name"
+ . ,(svn-multi-reference-user-name ref)))
+ '())
+ ,@(if (svn-multi-reference-password ref)
+ `(("svn password"
+ . ,(svn-multi-reference-password ref)))
+ '()))
+
#:leaked-env-vars '("http_proxy" "https_proxy"
"LC_ALL" "LC_MESSAGES" "LANG"
"COLUMNS")