build_tgz.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. # This script can run from any location,
  3. # output is created in the $CWD
  4. BASE_DIR="$PWD"
  5. blender_srcdir=$(dirname -- $0)/../..
  6. blender_version=$(grep "BLENDER_VERSION\s" "$blender_srcdir/source/blender/blenkernel/BKE_blender_version.h" | awk '{print $3}')
  7. blender_version_char=$(grep "BLENDER_VERSION_CHAR\s" "$blender_srcdir/source/blender/blenkernel/BKE_blender_version.h" | awk '{print $3}')
  8. blender_version_cycle=$(grep "BLENDER_VERSION_CYCLE\s" "$blender_srcdir/source/blender/blenkernel/BKE_blender_version.h" | awk '{print $3}')
  9. blender_subversion=$(grep "BLENDER_SUBVERSION\s" "$blender_srcdir/source/blender/blenkernel/BKE_blender_version.h" | awk '{print $3}')
  10. if [ "$blender_version_cycle" = "release" ] ; then
  11. VERSION=$(expr $blender_version / 100).$(expr $blender_version % 100)$blender_version_char
  12. SUBMODULE_EXCLUDE="^\(release/scripts/addons_contrib\)$"
  13. else
  14. VERSION=$(expr $blender_version / 100).$(expr $blender_version % 100)_$blender_subversion
  15. SUBMODULE_EXCLUDE="^$" # dummy regex
  16. fi
  17. MANIFEST="blender-$VERSION-manifest.txt"
  18. TARBALL="blender-$VERSION.tar.gz"
  19. cd "$blender_srcdir"
  20. # not so nice, but works
  21. FILTER_FILES_PY=\
  22. "import os, sys; "\
  23. "[print(l[:-1]) for l in sys.stdin.readlines() "\
  24. "if os.path.isfile(l[:-1]) "\
  25. "if os.path.basename(l[:-1]) not in {"\
  26. "'.gitignore', "\
  27. "'.gitmodules', "\
  28. "'.arcconfig', "\
  29. "}"\
  30. "]"
  31. # Build master list
  32. echo -n "Building manifest of files: \"$BASE_DIR/$MANIFEST\" ..."
  33. git ls-files | python3 -c "$FILTER_FILES_PY" > $BASE_DIR/$MANIFEST
  34. # Enumerate submodules
  35. for lcv in $(git submodule | awk '{print $2}' | grep -v "$SUBMODULE_EXCLUDE"); do
  36. cd "$BASE_DIR"
  37. cd "$blender_srcdir/$lcv"
  38. git ls-files | python3 -c "$FILTER_FILES_PY" | awk '$0="'"$lcv"/'"$0' >> $BASE_DIR/$MANIFEST
  39. cd "$BASE_DIR"
  40. done
  41. echo "OK"
  42. # Create the tarball
  43. cd "$blender_srcdir"
  44. echo -n "Creating archive: \"$BASE_DIR/$TARBALL\" ..."
  45. tar --transform "s,^,blender-$VERSION/,g" \
  46. --use-compress-program="gzip --best" \
  47. --create \
  48. --file="$BASE_DIR/$TARBALL" \
  49. --files-from="$BASE_DIR/$MANIFEST"
  50. echo "OK"
  51. # Create checksum file
  52. cd "$BASE_DIR"
  53. echo -n "Creating checksum: \"$BASE_DIR/$TARBALL.md5sum\" ..."
  54. md5sum "$TARBALL" > "$TARBALL.md5sum"
  55. echo "OK"
  56. # Cleanup
  57. echo -n "Cleaning up ..."
  58. rm "$BASE_DIR/$MANIFEST"
  59. echo "OK"
  60. echo "Done!"