Fix tgz script, addons_contrib was in release
[blender.git] / build_files / utils / build_tgz.sh
1 #!/bin/sh
2
3 # This script can run from any location,
4 # output is created in the $CWD
5
6 BASE_DIR="$PWD"
7
8 blender_srcdir=$(dirname -- $0)/../..
9 blender_version=$(grep "BLENDER_VERSION\s" "$blender_srcdir/source/blender/blenkernel/BKE_blender.h" | awk '{print $3}')
10 blender_version_char=$(grep "BLENDER_VERSION_CHAR\s" "$blender_srcdir/source/blender/blenkernel/BKE_blender.h" | awk '{print $3}')
11 blender_version_cycle=$(grep "BLENDER_VERSION_CYCLE\s" "$blender_srcdir/source/blender/blenkernel/BKE_blender.h" | awk '{print $3}')
12 blender_subversion=$(grep "BLENDER_SUBVERSION\s" "$blender_srcdir/source/blender/blenkernel/BKE_blender.h" | awk '{print $3}')
13
14 if [ "$blender_version_cycle" = "release" ] ; then
15         VERSION=$(expr $blender_version / 100).$(expr $blender_version % 100)$blender_version_char
16         SUBMODULE_EXCLUDE="^\(release/scripts/addons_contrib\)$"
17 else
18         VERSION=$(expr $blender_version / 100).$(expr $blender_version % 100)_$blender_subversion
19         SUBMODULE_EXCLUDE="^$"  # dummy regex
20 fi
21
22 MANIFEST="blender-$VERSION-manifest.txt"
23 TARBALL="blender-$VERSION.tar.gz"
24
25 cd "$blender_srcdir"
26
27 # not so nice, but works
28 FILTER_FILES_PY="import os, sys; [print(l[:-1]) for l in sys.stdin.readlines() if os.path.isfile(l[:-1])]"
29
30 # Build master list
31 echo -n "Building manifest of files:  \"$BASE_DIR/$MANIFEST\" ..."
32 git ls-files | python3 -c "$FILTER_FILES_PY" > $BASE_DIR/$MANIFEST
33
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
43
44 # Create the tarball
45 cd "$blender_srcdir"
46 echo -n "Creating archive:            \"$BASE_DIR/$TARBALL\" ..."
47 GZIP=-9 tar --transform "s,^,blender-$VERSION/,g" -zcf "$BASE_DIR/$TARBALL" -T "$BASE_DIR/$MANIFEST"
48 echo "OK"
49
50
51 # Create checksum file
52 cd "$BASE_DIR"
53 echo -n "Createing checksum:          \"$BASE_DIR/$TARBALL.md5sum\" ..."
54 md5sum "$TARBALL" > "$TARBALL.md5sum"
55 echo "OK"
56
57
58 # Cleanup
59 echo -n "Cleaning up ..."
60 rm "$BASE_DIR/$MANIFEST"
61 echo "OK"
62
63 echo "Done!"