make_tarball.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. if [ ! -e "version.py" ]; then
  3. echo "This script should be ran from the root folder of the Godot repository."
  4. exit 1
  5. fi
  6. while getopts "h?sv:g:" opt; do
  7. case "$opt" in
  8. h|\?)
  9. echo "Usage: $0 [OPTIONS...]"
  10. echo
  11. echo " -s script friendly file name (godot.tar.gz)"
  12. echo " -v godot version for file name (e.g. 4.0-stable)"
  13. echo " -g git treeish to archive (e.g. master)"
  14. echo
  15. exit 1
  16. ;;
  17. s)
  18. script_friendly_name=1
  19. ;;
  20. v)
  21. godot_version=$OPTARG
  22. ;;
  23. g)
  24. git_treeish=$OPTARG
  25. ;;
  26. esac
  27. done
  28. if [ ! -z "$git_treeish" ]; then
  29. HEAD=$(git rev-parse $git_treeish)
  30. else
  31. HEAD=$(git rev-parse HEAD)
  32. fi
  33. if [ ! -z "$script_friendly_name" ]; then
  34. NAME=godot
  35. else
  36. if [ ! -z "$godot_version" ]; then
  37. NAME=godot-$godot_version
  38. else
  39. NAME=godot-$HEAD
  40. fi
  41. fi
  42. CURDIR=$(pwd)
  43. TMPDIR=$(mktemp -d -t godot-XXXXXX)
  44. echo "Generating tarball for revision $HEAD with folder name '$NAME'."
  45. echo
  46. echo "The tarball will be written to the parent folder:"
  47. echo " $(dirname $CURDIR)/$NAME.tar.gz"
  48. git archive $HEAD --prefix=$NAME/ -o $TMPDIR/$NAME.tar
  49. # Adding custom .git/HEAD to tarball so that we can generate VERSION_HASH.
  50. cd $TMPDIR
  51. mkdir -p $NAME/.git
  52. echo $HEAD > $NAME/.git/HEAD
  53. tar -uf $NAME.tar $NAME
  54. cd $CURDIR
  55. gzip -c $TMPDIR/$NAME.tar > ../$NAME.tar.gz
  56. rm -rf $TMPDIR