Skip to content

Commit 041a46b

Browse files
Archive submodules
When making a release tarball, add a temporary submodules/ directory and create archives for all submodules, using "git submodules foreach". Concatenate the resulting archives into the main one.
1 parent 7a784bf commit 041a46b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

upstream-git.lisp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,33 @@
6363
(:method ((source git-at-commit-source))
6464
(format nil "~A" (commit source))))
6565

66+
(defun submodule-git-archive-command (prefix directory)
67+
(flet ((concat (&rest strings)
68+
(apply #'concatenate 'string strings)))
69+
(let* ((tardir (concat (native-directory-string directory) "$path/"))
70+
(tarfile (concat tardir "$name.tar")))
71+
(format nil
72+
"mkdir -p ~S ~
73+
&& git archive HEAD --format=tar --prefix=~S > ~S"
74+
tardir (concat prefix "$path/") tarfile))))
75+
6676
(defmethod make-release-tarball ((source git-source) output-file)
6777
(let ((prefix (release-tarball-prefix source))
6878
(checkout (ensure-source-cache source)))
6979
(in-temporary-directory prefix
7080
(let ((temptar (merge-pathnames "package.tar"))
71-
(tempgz (merge-pathnames "package.tar.gz")))
81+
(tempgz (merge-pathnames "package.tar.gz"))
82+
(tempsub (merge-pathnames "submodules/")))
83+
(ensure-directories-exist tempsub)
7284
(with-posix-cwd checkout
7385
(with-binary-run-output temptar
7486
(run "git" "archive" :format "tar" :prefix prefix
7587
(target-ref source)))
88+
(without-run-output
89+
(run "git" "submodule" "foreach" :recursive :quiet
90+
(submodule-git-archive-command prefix tempsub)))
91+
(dolist (archive (directory (merge-pathnames "**/*.tar" tempsub)))
92+
(run "tar" "Af" temptar archive))
7693
(run "gzip" "-vn9" temptar)
7794
(copy tempgz output-file))))))
7895

0 commit comments

Comments
 (0)