2018-12-20 12:33:29 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# runs dh_virtualenv to build the virtualenv in the build directory,
|
|
|
|
# and then runs the trial tests against the installed synapse.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
export DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs
|
2019-01-23 12:43:04 +01:00
|
|
|
|
|
|
|
# make sure that the virtualenv links to the specific version of python, by
|
|
|
|
# dereferencing the python3 symlink.
|
|
|
|
#
|
|
|
|
# Otherwise, if somebody tries to install (say) the stretch package on buster,
|
|
|
|
# they will get a confusing error about "No module named 'synapse'", because
|
|
|
|
# python won't look in the right directory. At least this way, the error will
|
|
|
|
# be a *bit* more obvious.
|
|
|
|
#
|
|
|
|
SNAKE=`readlink -e /usr/bin/python3`
|
2018-12-20 12:33:29 +01:00
|
|
|
|
|
|
|
# try to set the CFLAGS so any compiled C extensions are compiled with the most
|
|
|
|
# generic as possible x64 instructions, so that compiling it on a new Intel chip
|
|
|
|
# doesn't enable features not available on older ones or AMD.
|
|
|
|
#
|
|
|
|
# TODO: add similar things for non-amd64, or figure out a more generic way to
|
|
|
|
# do this.
|
|
|
|
|
|
|
|
case `dpkg-architecture -q DEB_HOST_ARCH` in
|
|
|
|
amd64)
|
|
|
|
export CFLAGS=-march=x86-64
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Use --builtin-venv to use the better `venv` module from CPython 3.4+ rather
|
|
|
|
# than the 2/3 compatible `virtualenv`.
|
|
|
|
|
2021-01-29 15:56:04 +01:00
|
|
|
# Pin pip to 20.3.4 to fix breakage in 21.0 on py3.5 (xenial)
|
|
|
|
|
2018-12-20 12:33:29 +01:00
|
|
|
dh_virtualenv \
|
|
|
|
--install-suffix "matrix-synapse" \
|
|
|
|
--builtin-venv \
|
|
|
|
--python "$SNAKE" \
|
2021-01-29 15:56:04 +01:00
|
|
|
--upgrade-pip-to="20.3.4" \
|
2018-12-20 12:33:29 +01:00
|
|
|
--preinstall="lxml" \
|
|
|
|
--preinstall="mock" \
|
|
|
|
--extra-pip-arg="--no-cache-dir" \
|
2019-01-02 08:17:39 +01:00
|
|
|
--extra-pip-arg="--compile" \
|
2020-10-12 18:44:11 +02:00
|
|
|
--extras="all,systemd,test"
|
2018-12-20 12:33:29 +01:00
|
|
|
|
2019-01-24 14:39:01 +01:00
|
|
|
PACKAGE_BUILD_DIR="debian/matrix-synapse-py3"
|
|
|
|
VIRTUALENV_DIR="${PACKAGE_BUILD_DIR}${DH_VIRTUALENV_INSTALL_ROOT}/matrix-synapse"
|
|
|
|
TARGET_PYTHON="${VIRTUALENV_DIR}/bin/python"
|
|
|
|
|
2018-12-20 12:33:29 +01:00
|
|
|
# we copy the tests to a temporary directory so that we can put them on the
|
|
|
|
# PYTHONPATH without putting the uninstalled synapse on the pythonpath.
|
|
|
|
tmpdir=`mktemp -d`
|
|
|
|
trap "rm -r $tmpdir" EXIT
|
|
|
|
|
|
|
|
cp -r tests "$tmpdir"
|
|
|
|
|
|
|
|
PYTHONPATH="$tmpdir" \
|
2021-02-26 19:30:54 +01:00
|
|
|
"${TARGET_PYTHON}" -m twisted.trial --reporter=text -j2 tests
|
2019-01-24 14:39:01 +01:00
|
|
|
|
|
|
|
# build the config file
|
2021-02-26 19:30:54 +01:00
|
|
|
"${TARGET_PYTHON}" "${VIRTUALENV_DIR}/bin/generate_config" \
|
2019-01-24 14:39:01 +01:00
|
|
|
--config-dir="/etc/matrix-synapse" \
|
|
|
|
--data-dir="/var/lib/matrix-synapse" |
|
|
|
|
perl -pe '
|
|
|
|
# tweak the paths to the tls certs and signing keys
|
|
|
|
/^tls_.*_path:/ and s/SERVERNAME/homeserver/;
|
|
|
|
/^signing_key_path:/ and s/SERVERNAME/homeserver/;
|
|
|
|
|
|
|
|
# tweak the pid file location
|
|
|
|
/^pid_file:/ and s#:.*#: "/var/run/matrix-synapse.pid"#;
|
|
|
|
|
|
|
|
# tweak the path to the log config
|
|
|
|
/^log_config:/ and s/SERVERNAME\.log\.config/log.yaml/;
|
|
|
|
|
|
|
|
# tweak the path to the media store
|
|
|
|
/^media_store_path:/ and s#/media_store#/media#;
|
|
|
|
|
|
|
|
# remove the server_name setting, which is set in a separate file
|
|
|
|
/^server_name:/ and $_ = "#\n# This is set in /etc/matrix-synapse/conf.d/server_name.yaml for Debian installations.\n# $_";
|
|
|
|
|
|
|
|
# remove the report_stats setting, which is set in a separate file
|
|
|
|
/^# report_stats:/ and $_ = "";
|
|
|
|
|
|
|
|
' > "${PACKAGE_BUILD_DIR}/etc/matrix-synapse/homeserver.yaml"
|
|
|
|
|
2020-01-03 18:14:00 +01:00
|
|
|
# build the log config file
|
2021-02-26 19:30:54 +01:00
|
|
|
"${TARGET_PYTHON}" "${VIRTUALENV_DIR}/bin/generate_log_config" \
|
2020-01-03 18:14:00 +01:00
|
|
|
--output-file="${PACKAGE_BUILD_DIR}/etc/matrix-synapse/log.yaml"
|
2019-01-23 12:43:04 +01:00
|
|
|
|
|
|
|
# add a dependency on the right version of python to substvars.
|
|
|
|
PYPKG=`basename $SNAKE`
|
|
|
|
echo "synapse:pydepends=$PYPKG" >> debian/matrix-synapse-py3.substvars
|