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() {
|
2017-11-17 07:17:12 +01:00
|
|
|
echo "Usage: $0 <ZULIP_VERSION> [--authors-not-required]" >&2
|
2016-11-22 07:00:12 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-11-17 07:16:05 +01:00
|
|
|
args="$(getopt -o '' -l 'authors-not-required,help' -n "$0" -- "$@")"
|
2016-11-22 07:00:12 +01:00
|
|
|
eval "set -- $args"
|
|
|
|
|
2017-11-17 00:09:39 +01:00
|
|
|
authors_not_required=
|
2016-11-22 07:00:12 +01:00
|
|
|
while true; do
|
|
|
|
case "$1" in
|
2017-11-17 00:09:39 +01:00
|
|
|
--authors-not-required)
|
|
|
|
authors_not_required=--authors-not-required; shift;;
|
2016-11-22 07:00:12 +01:00
|
|
|
--) 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
|
|
|
|
|
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"
|
2017-11-16 23:25:16 +01:00
|
|
|
for i in `cat "$TMPDIR/$prefix/tools/release-tarball-exclude.txt"`; do
|
|
|
|
rm -r --interactive=never "$TMPDIR/$prefix/$i";
|
2017-10-12 06:20:06 +02:00
|
|
|
done
|
|
|
|
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/"
|
|
|
|
cd "$TMPDIR/$prefix"
|
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
|
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
|
|
|
|
|
2016-08-23 01:35:46 +02:00
|
|
|
# We do a bit of gymnastics to have update-prod-static.log be easily
|
|
|
|
# visible to the user and end up in the same directory as the final
|
|
|
|
# release tarball.
|
2017-11-16 23:25:16 +01:00
|
|
|
USER_PROD_STATIC_LOGPATH="$TMPDIR/update-prod-static.log"
|
|
|
|
BUILD_PROD_STATIC_LOGPATH="$TMPDIR/$prefix/var/log/update-prod-static.log"
|
2016-08-23 01:35:46 +02:00
|
|
|
ln -nfs "$BUILD_PROD_STATIC_LOGPATH" "$USER_PROD_STATIC_LOGPATH"
|
2015-09-21 00:09:51 +02:00
|
|
|
|
2017-11-17 00:09:39 +01:00
|
|
|
./tools/update-prod-static $authors_not_required || (
|
2017-05-25 00:33:30 +02:00
|
|
|
set +x
|
|
|
|
echo; echo -ne "\033[33mRunning update-prod-static failed. "
|
2017-11-16 23:25:16 +01:00
|
|
|
echo -e "Check $TMPDIR/update-prod-static.log for more information.\033[0m"
|
2017-05-25 00:33:30 +02:00
|
|
|
exit 1
|
|
|
|
)
|
2016-08-23 01:35:46 +02:00
|
|
|
rm -f "$USER_PROD_STATIC_LOGPATH"
|
|
|
|
mv "$BUILD_PROD_STATIC_LOGPATH" "$USER_PROD_STATIC_LOGPATH"
|
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
|
|
|
|
2017-10-20 22:42:55 +02:00
|
|
|
tar --append -f "$TARBALL" "$prefix/prod-static" "$prefix/build_id" "$prefix/version" "$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"
|