zulip/tools/build-enterprise-tarball

64 lines
1.5 KiB
Bash
Executable File

#!/bin/sh -ex
GITID=$(git rev-parse HEAD)
if [ -z "$1" ]; then
echo "Usage: $0 <ZULIP_VERSION>"
exit 1
fi
version="$1"
prefix="zulip-server-$version"
if [ "$(uname)" = "Darwin" ]; then
TMPDIR=/tmp/enterprise-build
rm -Rf $TMPDIR
mkdir -p $TMPDIR
else
TMPDIR=$(mktemp -d)
fi
TMP_CHECKOUT=$TMPDIR/$prefix/
TARBALL=$TMPDIR/$prefix.tar
# .gitattributes lists the files that are not exported
git archive -o $TARBALL --prefix=$prefix/ HEAD
if tar -tf $TARBALL | grep -q -e zilencer -e zproject/local_settings.py -e puppet/zulip_internal; then
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
# Check out a temporary full copy of the index to generate static files
git checkout-index -f -a --prefix $TMP_CHECKOUT
cd $TMP_CHECKOUT
# Use default settings so there is no chance of leaking secrets
cp zproject/local_settings_template.py zproject/local_settings.py
# Some settings need values for it to work
cat >> zproject/local_settings.py <<EOF
DEBUG = False
LOCAL_DATABASE_PASSWORD = ''
SECRET_KEY = 'not_used_here'
EOF
# update-prod-static generates the prod-static directory.
# See COLLECTSTATIC in settings.py
./tools/update-prod-static
echo $GITID > build_id
echo $version > version
mv update-prod-static.log ..
cd $TMPDIR
tar --append -f $TARBALL $prefix/prod-static $prefix/build_id $prefix/version
rm -r $prefix
gzip $TARBALL
echo "Generated $TARBALL.gz"