summaryrefslogtreecommitdiff
path: root/guix/svn-download.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/svn-download.scm')
-rw-r--r--guix/svn-download.scm107
1 files changed, 81 insertions, 26 deletions
diff --git a/guix/svn-download.scm b/guix/svn-download.scm
index 55ce0d7351..e0a26b73ee 100644
--- a/guix/svn-download.scm
+++ b/guix/svn-download.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014-2016, 2019, 2021-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
;;; Copyright © 2017, 2019, 2021 Ricardo Wurmus <rekado@elephly.net>
;;;
@@ -34,6 +34,8 @@
svn-reference-url
svn-reference-revision
svn-reference-recursive?
+ svn-reference-user-name
+ svn-reference-password
svn-fetch
download-svn-to-store
@@ -43,6 +45,8 @@
svn-multi-reference-revision
svn-multi-reference-locations
svn-multi-reference-recursive?
+ svn-multi-reference-user-name
+ svn-multi-reference-password
svn-multi-fetch
download-multi-svn-to-store))
@@ -79,17 +83,42 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
(with-imported-modules '((guix build svn)
(guix build utils))
#~(begin
- (use-modules (guix build svn))
- (svn-fetch '#$(svn-reference-url ref)
- '#$(svn-reference-revision ref)
+ (use-modules (guix build svn)
+ (ice-9 match))
+
+ (svn-fetch (getenv "svn url")
+ (string->number (getenv "svn revision"))
#$output
- #:svn-command (string-append #+svn "/bin/svn")
- #:recursive? #$(svn-reference-recursive? ref)
- #:user-name #$(svn-reference-user-name ref)
- #:password #$(svn-reference-password ref)))))
+ #: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")))))
(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-download"
+ #:env-vars
+ `(("svn url" . ,(svn-reference-url ref))
+ ("svn revision"
+ . ,(number->string (svn-reference-revision ref)))
+ ,@(if (svn-reference-recursive? ref)
+ `(("svn recursive?" . "yes"))
+ '())
+ ,@(if (svn-reference-user-name ref)
+ `(("svn user name"
+ . ,(svn-reference-user-name ref)))
+ '())
+ ,@(if (svn-reference-password ref)
+ `(("svn password"
+ . ,(svn-reference-password ref)))
+ '()))
+
#:system system
#:hash-algo hash-algo
#:hash hash
@@ -120,27 +149,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")