2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
2017-11-17 07:16:05 +01:00
|
|
|
set -eu
|
2016-11-22 07:00:12 +01:00
|
|
|
|
|
|
|
usage() {
|
2020-04-24 22:26:32 +02:00
|
|
|
echo "Usage: $0 <ZULIP_VERSION>" >&2
|
2016-11-22 07:00:12 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2020-04-24 22:26:32 +02:00
|
|
|
args="$(getopt -o '' -l 'help' -n "$0" -- "$@")"
|
2016-11-22 07:00:12 +01:00
|
|
|
eval "set -- $args"
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
--) shift; break;;
|
|
|
|
*) usage;;
|
|
|
|
esac
|
|
|
|
done
|
2013-10-29 20:04:55 +01:00
|
|
|
|
2016-11-22 07:00:12 +01:00
|
|
|
if [ -z "${1:-}" ]; then
|
|
|
|
usage
|
2013-11-13 22:50:40 +01:00
|
|
|
fi
|
2017-11-17 07:16:05 +01:00
|
|
|
|
2013-11-13 22:50:40 +01:00
|
|
|
version="$1"
|
|
|
|
prefix="zulip-server-$version"
|
|
|
|
|
2017-11-17 07:16:05 +01:00
|
|
|
set -x
|
|
|
|
GITID=$(git rev-parse HEAD)
|
|
|
|
|
2015-09-21 00:09:51 +02:00
|
|
|
if ! git diff --exit-code >/dev/null; then
|
|
|
|
set +x
|
2017-03-10 20:49:32 +01:00
|
|
|
echo "ERROR: tarballs builds are based on a commit hash so your changes "
|
|
|
|
echo "will not be included; you should commit or stash them based on "
|
|
|
|
echo "what you want and then try again."
|
|
|
|
echo
|
2017-11-17 07:17:12 +01:00
|
|
|
git diff
|
2017-03-10 20:49:32 +01:00
|
|
|
exit 1
|
2015-09-21 00:09:51 +02:00
|
|
|
fi
|
|
|
|
|
2020-06-08 21:52:13 +02:00
|
|
|
umask 022
|
|
|
|
|
2017-11-16 23:13:34 +01:00
|
|
|
TMPDIR=$(mktemp -d)
|
2013-11-13 22:50:40 +01:00
|
|
|
TARBALL=$TMPDIR/$prefix.tar
|
2017-10-12 06:20:06 +02:00
|
|
|
BASEDIR=$(pwd)
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
git archive -o "$TARBALL" "--prefix=$prefix/" HEAD
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2017-10-12 06:20:06 +02:00
|
|
|
cd "$TMPDIR"
|
|
|
|
tar -xf "$TARBALL"
|
2018-08-03 02:14:48 +02:00
|
|
|
while read -r i; do
|
|
|
|
rm -r --interactive=never "${TMPDIR:?}/$prefix/$i";
|
|
|
|
done < "$TMPDIR/$prefix/tools/release-tarball-exclude.txt"
|
2017-10-12 06:20:06 +02:00
|
|
|
tar -cf "$TARBALL" "$prefix"
|
|
|
|
rm -rf "$prefix"
|
2013-11-13 00:46:35 +01:00
|
|
|
|
2017-08-16 05:06:53 +02:00
|
|
|
if tar -tf "$TARBALL" | grep -q -e ^zerver/tests; then
|
2017-07-29 06:13:51 +02:00
|
|
|
set +x
|
2017-10-12 06:20:06 +02:00
|
|
|
echo "BUG: Excluded files remain in tarball!"
|
|
|
|
exit 1
|
2013-11-13 00:46:35 +01:00
|
|
|
fi
|
2017-10-12 06:20:06 +02:00
|
|
|
cd "$BASEDIR"
|
2016-11-22 07:00:12 +01:00
|
|
|
|
2013-11-12 17:13:19 +01:00
|
|
|
# Check out a temporary full copy of the index to generate static files
|
2017-11-16 23:25:16 +01:00
|
|
|
git checkout-index -f -a --prefix "$TMPDIR/$prefix/"
|
2019-04-21 05:51:20 +02:00
|
|
|
|
|
|
|
# Add the git version information file
|
|
|
|
./tools/cache-zulip-git-version
|
|
|
|
mv zulip-git-version "$TMPDIR/$prefix/"
|
|
|
|
|
2017-11-16 23:25:16 +01:00
|
|
|
cd "$TMPDIR/$prefix"
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2019-07-21 00:40:34 +02:00
|
|
|
ln -s "$BASEDIR/zulip-py3-venv" .
|
|
|
|
|
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
|
2017-09-29 02:30:17 +02:00
|
|
|
# sort of environment hack so that we 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
|
|
|
|
|
2020-04-24 22:26:32 +02:00
|
|
|
./tools/update-prod-static
|
2013-11-01 20:54:41 +01:00
|
|
|
|
2013-11-14 16:36:29 +01:00
|
|
|
# We don't need duplicate copies of emoji with hashed paths, and they would break bugdown
|
2016-12-28 05:07:10 +01:00
|
|
|
find prod-static/serve/generated/emoji/images/emoji/ -regex '.*\.[0-9a-f]+\.png' -delete
|
2013-11-14 16:36:29 +01:00
|
|
|
|
2017-07-29 06:15:33 +02:00
|
|
|
echo "$GITID" > build_id
|
|
|
|
echo "$version" > version
|
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
cd "$TMPDIR"
|
2013-11-12 17:13:19 +01:00
|
|
|
|
2019-07-02 22:38:09 +02:00
|
|
|
tar --append -f "$TARBALL" "$prefix/prod-static" "$prefix/build_id" "$prefix/version" "$prefix/zulip-git-version" "$prefix/locale" "$prefix/staticfiles.json" "$prefix/templates/zerver/emails/compiled" "$prefix/webpack-stats-production.json"
|
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"
|
2017-07-29 06:13:51 +02:00
|
|
|
|
|
|
|
set +x
|
2013-11-12 17:13:19 +01:00
|
|
|
echo "Generated $TARBALL.gz"
|