build_tgz.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. GZIP=-9 tar --transform "s,^,blender-$VERSION/,g" -zcf "$BASE_DIR/$TARBALL" -T "$BASE_DIR/$MANIFEST"
  46. echo "OK"
  47. # Create checksum file
  48. cd "$BASE_DIR"
  49. echo -n "Createing checksum: \"$BASE_DIR/$TARBALL.md5sum\" ..."
  50. md5sum "$TARBALL" > "$TARBALL.md5sum"
  51. echo "OK"
  52. # Cleanup
  53. echo -n "Cleaning up ..."
  54. rm "$BASE_DIR/$MANIFEST"
  55. echo "OK"
  56. echo "Done!"