You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dist.sh 828B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. # Creates a tarball with the concatenation of a git tree and the submodules.
  3. # Hidden files such as .gitignore are skipped.
  4. # GNU tar
  5. TAR=${2:-"tar"}
  6. if [ $# -lt 1 ] ; then
  7. echo "Usage: dist.sh <filename> [tar_command]"
  8. exit 1
  9. fi
  10. FNAME=$1
  11. PREFIX=`basename $FNAME | sed -e 's/\.tar.*$//'`
  12. ALL_TAR=$(mktemp) || { echo "mktemp is missing!"; exit 1; }
  13. TMP_TAR=$(mktemp) || { echo "mktemp is missing!"; exit 1; }
  14. trap 'rm -f "$TMP_TAR" "$ALL_TAR"' EXIT
  15. # Create tarball for main repo contents.
  16. git archive --prefix="$PREFIX/" HEAD ":!.*" ":!**/.*" > "$ALL_TAR"
  17. # Append submodule contents, if any.
  18. export PREFIX TMP_TAR ALL_TAR
  19. git submodule --quiet foreach --recursive \
  20. 'git archive --prefix="$PREFIX/$displaypath/" HEAD ":!.*" ":!**/.*" > "$TMP_TAR";
  21. tar Af "$ALL_TAR" "$TMP_TAR"'
  22. xz < "$ALL_TAR" > "$FNAME"