Subject: [PATCH] guix: svn: Allow dropping externals
From: Julien Lepiller <[email-masked]>
To: [email-masked]
Date: Mon, 21 Oct 2019 21:55:38 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

A subversion repository can contain externals, references to other
projects that also use subversion. This is very similar to git
submodules. When checking out a repository, svn will automatically
check these external repositories too. However, if the externals are
not pinned to a specific revision, svn will fetch the latest sources
for the external, leading to non reproducibility of the sources' hash.

This patch adds a fetch-externals? field to svn-reference and
svn-multi-reference, defaulting to #t for preserving the old behavior.
Setting it to #f will prevent fetching any external from the project.
This is useful for josm for instance.
From 0ac412a3c912b2fe7ebd05d178120db50d47184e Mon Sep 17 00:00:00 2001
From: Julien Lepiller <[email-masked]>
Date: Mon, 21 Oct 2019 21:48:31 +0200
Subject: [PATCH] guix: svn: Allow dropping externals.

* guix/build/svn.scm (svn-fetch): Allow to ignore externals.
* guix/svn-download.scm (svn-reference, svn-multi-reference): Add
fetch-externals? field.
---
 guix/build/svn.scm    |  4 ++++
 guix/svn-download.scm | 25 ++++++++++++++++---------
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/guix/build/svn.scm b/guix/build/svn.scm
index e3188add3e..ff3ca3a666 100644
--- a/guix/build/svn.scm
+++ b/guix/build/svn.scm
@@ -31,6 +31,7 @@
 
 (define* (svn-fetch url revision directory
                     #:key (svn-command "svn")
+                    (fetch-externals? #t)
                     (user-name #f)
                     (password #f))
   "Fetch REVISION from URL into DIRECTORY.  REVISION must be an integer, and a
@@ -45,6 +46,9 @@ valid Subversion revision.  Return #t on success, #f otherwise."
                  (list (string-append "--username=" user-name)
                        (string-append "--password=" password))
                  '())
+           ,@(if fetch-externals?
+                 '()
+                 (list "--ignore-externals"))
            ,url ,directory))
   #t)
 
diff --git a/guix/svn-download.scm b/guix/svn-download.scm
index 4139cbc2e2..16da2102d6 100644
--- a/guix/svn-download.scm
+++ b/guix/svn-download.scm
@@ -31,6 +31,7 @@
             svn-reference?
             svn-reference-url
             svn-reference-revision
+            svn-reference-fetch-externals?
             svn-fetch
             download-svn-to-store
 
@@ -39,6 +40,7 @@
             svn-multi-reference-url
             svn-multi-reference-revision
             svn-multi-reference-locations
+            svn-multi-reference-fetch-externals?
             svn-multi-fetch))
 
 ;;; Commentary:
@@ -52,10 +54,11 @@
 (define-record-type* <svn-reference>
   svn-reference make-svn-reference
   svn-reference?
-  (url       svn-reference-url)                    ; string
-  (revision  svn-reference-revision)               ; number
-  (user-name svn-reference-user-name (default #f))
-  (password  svn-reference-password (default #f)))
+  (url              svn-reference-url)                    ; string
+  (revision         svn-reference-revision)               ; number
+  (fetch-externals? svn-reference-fetch-externals? (default #t))
+  (user-name        svn-reference-user-name (default #f))
+  (password         svn-reference-password (default #f)))
 
 (define (subversion-package)
   "Return the default Subversion package."
@@ -78,6 +81,7 @@ HASH-ALGO (a symbol).  Use NAME as the file name, or a generic name if #f."
                      '#$(svn-reference-revision ref)
                      #$output
                      #:svn-command (string-append #+svn "/bin/svn")
+                     #:fetch-externals? #$(svn-reference-fetch-externals? ref)
                      #:user-name #$(svn-reference-user-name ref)
                      #:password #$(svn-reference-password ref)))))
 
@@ -93,11 +97,12 @@ HASH-ALGO (a symbol).  Use NAME as the file name, or a generic name if #f."
 (define-record-type* <svn-multi-reference>
   svn-multi-reference make-svn-multi-reference
   svn-multi-reference?
-  (url        svn-multi-reference-url)                 ; string
-  (revision   svn-multi-reference-revision)            ; number
-  (locations  svn-multi-reference-locations)           ; list of strings
-  (user-name  svn-multi-reference-user-name (default #f))
-  (password   svn-multi-reference-password (default #f)))
+  (url              svn-multi-reference-url)                 ; string
+  (revision         svn-multi-reference-revision)            ; number
+  (locations        svn-multi-reference-locations)           ; list of strings
+  (fetch-externals? svn-multi-reference-fetch-externals? (default #t))
+  (user-name        svn-multi-reference-user-name (default #f))
+  (password         svn-multi-reference-password (default #f)))
 
 (define* (svn-multi-fetch ref hash-algo hash
                           #:optional name
@@ -125,6 +130,8 @@ HASH-ALGO (a symbol).  Use NAME as the file name, or a generic name if #f."
                                   (string-append #$output "/" location)
                                   (string-append #$output "/" (dirname location)))
                               #:svn-command (string-append #+svn "/bin/svn")
+                              #:fetch-externals?
+                              #$(svn-reference-fetch-externals? ref)
                               #:user-name #$(svn-multi-reference-user-name ref)
                               #:password #$(svn-multi-reference-password ref)))
                  '#$(svn-multi-reference-locations ref)))))
-- 
2.22.0