rspamd/dist.sh

30 lines
828 B
Bash
Raw Normal View History

2014-09-05 12:08:03 +02:00
#!/bin/sh
# Creates a tarball with the concatenation of a git tree and the submodules.
# Hidden files such as .gitignore are skipped.
2014-09-05 12:08:03 +02:00
# GNU tar
2015-06-30 15:50:31 +02:00
TAR=${2:-"tar"}
if [ $# -lt 1 ] ; then
echo "Usage: dist.sh <filename> [tar_command]"
2014-09-05 12:08:03 +02:00
exit 1
fi
2014-09-05 12:21:42 +02:00
FNAME=$1
2014-09-05 12:08:03 +02:00
PREFIX=`basename $FNAME | sed -e 's/\.tar.*$//'`
ALL_TAR=$(mktemp) || { echo "mktemp is missing!"; exit 1; }
TMP_TAR=$(mktemp) || { echo "mktemp is missing!"; exit 1; }
trap 'rm -f "$TMP_TAR" "$ALL_TAR"' EXIT
2014-09-05 12:08:03 +02:00
# Create tarball for main repo contents.
git archive --prefix="$PREFIX/" HEAD ":!.*" ":!**/.*" > "$ALL_TAR"
2014-09-05 12:08:03 +02:00
# Append submodule contents, if any.
export PREFIX TMP_TAR ALL_TAR
git submodule --quiet foreach --recursive \
'git archive --prefix="$PREFIX/$displaypath/" HEAD ":!.*" ":!**/.*" > "$TMP_TAR";
tar Af "$ALL_TAR" "$TMP_TAR"'
2014-09-05 12:08:03 +02:00
xz < "$ALL_TAR" > "$FNAME"