From 30ac571eac98b491b84a17a38c2401eea98d834e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 17 Oct 2022 22:52:11 +0200 Subject: 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'. --- guix/svn-download.scm | 62 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 18 deletions(-) (limited to 'guix') 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") -- cgit v1.2.3