From f69c420f65c41fb39aa3d2c013a7affa67fafe94 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 14 May 2012 11:39:29 -0500 Subject: [PATCH 53/55] Rewrite source tarball script. --- archive.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/archive.sh b/archive.sh index 6f7a048..b440001 100755 --- a/archive.sh +++ b/archive.sh @@ -1,16 +1,33 @@ #!/bin/sh # usage: sh archive.sh tree-ish +# Archives a Git revision with all of its submodules. recursivearchivefiles () { # recursivearchivefiles directory prefix tree-ish output-file + cd "$1" - for f in `git ls-files`; do - if test -d "$f/.git"; then - recursivearchivefiles "$PWD"/"$f" "$2""$f"/ "`git rev-parse HEAD:$f`" "$4" - cd "$1" + + echo Archiving: "$1" + + # recurse into submodules + git ls-tree -r "$3"|grep '^[^ ]* commit'|while read line; do + if test "x$line" = x; then + continue + fi + + obj=`echo "$line"|sed -e 's/^[^ ]* [^ ]* \([^ ]*\) .*$/\1/'` + filename=`echo "$line"|sed -e 's/^[^ ]* [^ ]* [^ ]* \(.*\)$/\1/'` + + if ! test -e "$1"/"$filename"/.git; then + echo Missing submodule: "$1"/"$filename" + continue fi + + recursivearchivefiles "$1"/"$filename" "$2""$filename"/ "$obj" "$4" + + cd "$1" done TEMPFILE=`tempfile` @@ -21,9 +38,10 @@ recursivearchivefiles () OUTPUT_FILE="$PWD/$1.tar" -rm "$OUTPUT_FILE" +rm -f "$OUTPUT_FILE" recursivearchivefiles "$PWD" "$1"/ "$1" "$OUTPUT_FILE" +rm -f "$OUTPUT_FILE.gz" gzip "$OUTPUT_FILE" -- 1.7.10.2