2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
set -x
|
2013-10-29 20:04:55 +01:00
|
|
|
|
2013-11-01 20:54:41 +01:00
|
|
|
GITID=$(git rev-parse HEAD)
|
|
|
|
|
2013-11-13 22:50:40 +01:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Usage: $0 <ZULIP_VERSION>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
version="$1"
|
|
|
|
prefix="zulip-server-$version"
|
|
|
|
|
2013-11-06 19:15:04 +01:00
|
|
|
if [ "$(uname)" = "Darwin" ]; then
|
2015-08-21 11:48:43 +02:00
|
|
|
TMPDIR=/tmp/voyager-build
|
2015-09-26 03:47:30 +02:00
|
|
|
rm -Rf "$TMPDIR"
|
|
|
|
mkdir -p "$TMPDIR"
|
2013-11-06 19:15:04 +01:00
|
|
|
else
|
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
fi
|
|
|
|
|
2015-09-21 00:09:51 +02:00
|
|
|
if ! git diff --exit-code >/dev/null; then
|
|
|
|
set +x
|
|
|
|
echo; echo "\033[31mWARNING: tarballs builds are based on a commit hash so your changes will not be included\033[0m"; echo
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
2013-11-13 22:50:40 +01:00
|
|
|
TMP_CHECKOUT=$TMPDIR/$prefix/
|
|
|
|
TARBALL=$TMPDIR/$prefix.tar
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2013-11-12 17:13:19 +01:00
|
|
|
# .gitattributes lists the files that are not exported
|
2015-09-26 03:47:30 +02:00
|
|
|
git archive -o "$TARBALL" "--prefix=$prefix/" HEAD
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2013-11-13 00:46:35 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
if tar -tf "$TARBALL" | grep -q -e zilencer -e zproject/local_settings.py -e puppet/zulip_internal; then
|
2013-11-13 00:46:35 +01:00
|
|
|
echo "Excluded files remain in tarball!";
|
|
|
|
echo "Versions of git 1.8.1.1 - 1.8.1.6 have broken .gitattributes syntax";
|
|
|
|
exit 1;
|
|
|
|
else
|
|
|
|
echo "Check for excluded files passed";
|
|
|
|
fi
|
|
|
|
|
2013-11-12 17:13:19 +01:00
|
|
|
# Check out a temporary full copy of the index to generate static files
|
2015-09-26 03:47:30 +02:00
|
|
|
git checkout-index -f -a --prefix "$TMP_CHECKOUT"
|
|
|
|
cd "$TMP_CHECKOUT"
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2016-07-09 09:08:41 +02:00
|
|
|
# create var/log directory in the new temporary checkout
|
|
|
|
mkdir -p "var/log"
|
|
|
|
|
2015-08-21 01:27:35 +02:00
|
|
|
# Some settings need to be updated for update-prod-static to work
|
|
|
|
#
|
|
|
|
# TODO: Would be much better to instead run the below tools with some
|
2015-08-21 11:24:18 +02:00
|
|
|
# sort of environment hack to make settings.VOYAGER=True so that we
|
2015-08-21 01:27:35 +02:00
|
|
|
# don't need to create this dummy secrets file.
|
2016-07-20 05:45:50 +02:00
|
|
|
cat >> zproject/prod_settings_template.py <<EOF
|
2013-11-12 20:37:23 +01:00
|
|
|
DEBUG = False
|
2015-08-21 01:27:35 +02:00
|
|
|
EOF
|
|
|
|
cat >> zproject/dev-secrets.conf <<EOF
|
|
|
|
[secrets]
|
|
|
|
local_database_password = ''
|
|
|
|
secret_key = 'not_used_here'
|
|
|
|
shared_secret = 'not_used_here'
|
|
|
|
avatar_salt = 'not_used_here'
|
|
|
|
rabbitmq_password = 'not_used_here'
|
|
|
|
initial_password_salt = 'not_used_here'
|
2013-11-12 20:37:23 +01:00
|
|
|
EOF
|
|
|
|
|
2013-11-01 20:54:41 +01:00
|
|
|
# update-prod-static generates the prod-static directory.
|
|
|
|
# See COLLECTSTATIC in settings.py
|
2015-09-21 00:09:51 +02:00
|
|
|
set +x
|
|
|
|
echo; echo "\033[33mRunning update-prod-static; check ${TMP_CHECKOUT}update-prod-static.log if it fails\033[0m"; echo
|
|
|
|
set -x
|
|
|
|
|
2013-11-01 20:54:41 +01:00
|
|
|
./tools/update-prod-static
|
2015-09-26 03:47:30 +02:00
|
|
|
echo "$GITID" > build_id
|
|
|
|
echo "$version" > version
|
2016-07-19 15:52:15 +02:00
|
|
|
mv var/log/update-prod-static.log ../
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2015-08-21 01:27:35 +02:00
|
|
|
rm -f zproject/dev-secrets.conf
|
|
|
|
|
2013-11-14 16:36:29 +01:00
|
|
|
# We don't need duplicate copies of emoji with hashed paths, and they would break bugdown
|
|
|
|
find prod-static/serve/third/gemoji/images/emoji/ -regex '.*\.[0-9a-f]+\.png' -delete
|
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
cd "$TMPDIR"
|
2013-11-12 17:13:19 +01:00
|
|
|
|
2016-07-14 12:00:26 +02:00
|
|
|
tar --append -f "$TARBALL" "$prefix/prod-static" "$prefix/build_id" "$prefix/version"
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
rm -rf "$prefix"
|
2013-11-12 17:13:19 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
gzip "$TARBALL"
|
2013-11-12 17:13:19 +01:00
|
|
|
echo "Generated $TARBALL.gz"
|