From 6750877f46e684688075674c6e342895a24a52c9 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 27 Jun 2014 23:04:48 +0200 Subject: git-download: Support recursive clones. * guix/git-download.scm ()[recursive?]: New field. (git-fetch): Add 'inputs' variable. Add it to the #:inputs argument of 'build-expression->derivation'. Augment builder with call to 'set-path-environment-variable', and pass #:recursive? to 'git-fetch'. * guix/build/git.scm (git-fetch): Add #:recursive? parameter. Pass --recursive when RECURSIVE? is true, and delete all the '.git' files. --- guix/build/git.scm | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'guix/build/git.scm') diff --git a/guix/build/git.scm b/guix/build/git.scm index 68b132265b..121f07a7fa 100644 --- a/guix/build/git.scm +++ b/guix/build/git.scm @@ -28,23 +28,32 @@ ;;; Code: (define* (git-fetch url commit directory - #:key (git-command "git")) + #:key (git-command "git") recursive?) "Fetch COMMIT from URL into DIRECTORY. COMMIT must be a valid Git commit -identifier. Return #t on success, #f otherwise." +identifier. When RECURSIVE? is true, all the sub-modules of URL are fetched, +recursively. Return #t on success, #f otherwise." ;; Disable TLS certificate verification. The hash of the checkout is known ;; in advance anyway. (setenv "GIT_SSL_NO_VERIFY" "true") - (and (zero? (system* git-command "clone" url directory)) - (with-directory-excursion directory - (system* git-command "tag" "-l") - (and (zero? (system* git-command "checkout" commit)) - (begin - ;; The contents of '.git' vary as a function of the current - ;; status of the Git repo. Since we want a fixed output, this - ;; directory needs to be taken out. - (delete-file-recursively ".git") - #t))))) + (let ((args `("clone" ,@(if recursive? '("--recursive") '()) + ,url ,directory))) + (and (zero? (apply system* git-command args)) + (with-directory-excursion directory + (system* git-command "tag" "-l") + (and (zero? (system* git-command "checkout" commit)) + (begin + ;; The contents of '.git' vary as a function of the current + ;; status of the Git repo. Since we want a fixed output, this + ;; directory needs to be taken out. + (delete-file-recursively ".git") + + (when recursive? + ;; In sub-modules, '.git' is a flat file, not a directory, + ;; so we can use 'find-files' here. + (for-each delete-file-recursively + (find-files directory "^\\.git$"))) + #t)))))) ;;; git.scm ends here -- cgit v1.2.3