From 20ec7169dae4527c7641aa4dab0850d23f74b173 Mon Sep 17 00:00:00 2001 From: Dan Callahan Date: Mon, 12 Apr 2021 11:24:47 +0100 Subject: [PATCH 1/4] Update debian scripts for debhelper-compat 12 This is part removing support for Debian Stretch and Ubuntu Xenial following the end of life for Python 3.5. Other notable changes: - Architecture is set to `any` to allow (but not mandate) ARM builds - The dh-virtualenv Dockerfile was overhauled to more closely follow the example provided upstream, including a necessary tweak to ensure builds work on Ubuntu bionic. Signed-off-by: Dan Callahan --- changelog.d/9792.misc | 1 + debian/build_virtualenv | 5 ++- debian/changelog | 6 ++++ debian/compat | 2 +- debian/control | 10 +++--- debian/matrix-synapse-py3.preinst | 31 ----------------- debian/matrix-synapse-py3.triggers | 3 +- debian/rules | 16 ++++----- debian/test/.gitignore | 2 -- debian/test/provision.sh | 23 ------------- debian/test/stretch/Vagrantfile | 13 ------- debian/test/xenial/Vagrantfile | 10 ------ docker/Dockerfile-dhvirtualenv | 54 ++++++++++++------------------ 13 files changed, 45 insertions(+), 131 deletions(-) create mode 100644 changelog.d/9792.misc delete mode 100644 debian/matrix-synapse-py3.preinst delete mode 100644 debian/test/.gitignore delete mode 100644 debian/test/provision.sh delete mode 100644 debian/test/stretch/Vagrantfile delete mode 100644 debian/test/xenial/Vagrantfile diff --git a/changelog.d/9792.misc b/changelog.d/9792.misc new file mode 100644 index 000000000000..27c1b55b894a --- /dev/null +++ b/changelog.d/9792.misc @@ -0,0 +1 @@ +Update Debian build scripts to support debhelper-compat level 12. diff --git a/debian/build_virtualenv b/debian/build_virtualenv index cad7d1688398..bad88b9374c0 100755 --- a/debian/build_virtualenv +++ b/debian/build_virtualenv @@ -33,15 +33,14 @@ esac # Use --builtin-venv to use the better `venv` module from CPython 3.4+ rather # than the 2/3 compatible `virtualenv`. -# Pin pip to 20.3.4 to fix breakage in 21.0 on py3.5 (xenial) - dh_virtualenv \ --install-suffix "matrix-synapse" \ --builtin-venv \ --python "$SNAKE" \ - --upgrade-pip-to="20.3.4" \ + --upgrade-pip \ --preinstall="lxml" \ --preinstall="mock" \ + --preinstall="wheel" \ --extra-pip-arg="--no-cache-dir" \ --extra-pip-arg="--compile" \ --extras="all,systemd,test" diff --git a/debian/changelog b/debian/changelog index 09602ff54bdd..601e73402327 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +matrix-synapse-py3 (1.31.0+nmu1) UNRELEASED; urgency=medium + + * Update Debian build scripts for debhelper-compat level 12. + + -- Dan Callahan Mon, 12 Apr 2021 10:39:59 +0000 + matrix-synapse-py3 (1.31.0) stable; urgency=medium * New synapse release 1.31.0. diff --git a/debian/compat b/debian/compat index ec635144f600..48082f72f087 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -9 +12 diff --git a/debian/control b/debian/control index 8167a901a4f1..c541bd54c6ae 100644 --- a/debian/control +++ b/debian/control @@ -3,12 +3,10 @@ Section: contrib/python Priority: extra Maintainer: Synapse Packaging team # keep this list in sync with the build dependencies in docker/Dockerfile-dhvirtualenv. -# TODO: Remove the dependency on dh-systemd after dropping support for Ubuntu xenial -# On all other supported releases, it's merely a transitional package which -# does nothing but depends on debhelper (> 9.20160709) Build-Depends: - debhelper (>= 9.20160709) | dh-systemd, - dh-virtualenv (>= 1.1), + debhelper, + dh-virtualenv (>= 1.2.2), + dh-python, libsystemd-dev, libpq-dev, lsb-release, @@ -22,7 +20,7 @@ Standards-Version: 3.9.8 Homepage: https://github.com/matrix-org/synapse Package: matrix-synapse-py3 -Architecture: amd64 +Architecture: any Provides: matrix-synapse Conflicts: matrix-synapse (<< 0.34.0.1-0matrix2), diff --git a/debian/matrix-synapse-py3.preinst b/debian/matrix-synapse-py3.preinst deleted file mode 100644 index 4b5612f050e4..000000000000 --- a/debian/matrix-synapse-py3.preinst +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -e - -# Attempt to undo some of the braindamage caused by -# https://github.com/matrix-org/package-synapse-debian/issues/18. -# -# Due to reasons [1], the old python2 matrix-synapse package will not stop the -# service when the package is uninstalled. Our maintainer scripts will do the -# right thing in terms of ensuring the service is enabled and unmasked, but -# then do a `systemctl start matrix-synapse`, which of course does nothing - -# leaving the old (py2) service running. -# -# There should normally be no reason for the service to be running during our -# preinst, so we assume that if it *is* running, it's due to that situation, -# and stop it. -# -# [1] dh_systemd_start doesn't do anything because it sees that there is an -# init.d script with the same name, so leaves it to dh_installinit. -# -# dh_installinit doesn't do anything because somebody gave it a --no-start -# for unknown reasons. - -if [ -x /bin/systemctl ]; then - if /bin/systemctl --quiet is-active -- matrix-synapse; then - echo >&2 "stopping existing matrix-synapse service" - /bin/systemctl stop matrix-synapse || true - fi -fi - -#DEBHELPER# - -exit 0 diff --git a/debian/matrix-synapse-py3.triggers b/debian/matrix-synapse-py3.triggers index f8c1fdb021c9..e488ca3d3a75 100644 --- a/debian/matrix-synapse-py3.triggers +++ b/debian/matrix-synapse-py3.triggers @@ -1,9 +1,10 @@ # Register interest in Python interpreter changes and # don't make the Python package dependent on the virtualenv package # processing (noawait) -interest-noawait /usr/bin/python3.5 interest-noawait /usr/bin/python3.6 interest-noawait /usr/bin/python3.7 +interest-noawait /usr/bin/python3.8 +interest-noawait /usr/bin/python3.9 # Also provide a symbolic trigger for all dh-virtualenv packages interest dh-virtualenv-interpreter-update diff --git a/debian/rules b/debian/rules index c744060a57ae..a93beacc48fa 100755 --- a/debian/rules +++ b/debian/rules @@ -6,14 +6,12 @@ # assume we only have one package PACKAGE_NAME:=`dh_listpackages` -override_dh_systemd_enable: - dh_systemd_enable --name=matrix-synapse +override_dh_installsystemd: + dh_installsystemd --name=matrix-synapse -override_dh_installinit: - dh_installinit --name=matrix-synapse - -# we don't really want to strip the symbols from our object files. +# we don't really want to strip or compress the symbols from our object files. override_dh_strip: +override_dh_dwz: # dh_shlibdeps calls dpkg-shlibdeps, which finds all the binary files # (executables and shared libs) in the package, and looks for the shared @@ -51,7 +49,7 @@ override_dh_shlibdeps: override_dh_virtualenv: ./debian/build_virtualenv -# We are restricted to compat level 9 (because xenial), so have to -# enable the systemd bits manually. %: - dh $@ --with python-virtualenv --with systemd + # TODO: Experiment with --buildsystem=dh_virtualenv + # https://dh-virtualenv.readthedocs.io/en/latest/usage.html#experimental-buildsystem-support + dh $@ --with python-virtualenv --buildsystem=pybuild diff --git a/debian/test/.gitignore b/debian/test/.gitignore deleted file mode 100644 index 95eda73fcc30..000000000000 --- a/debian/test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.vagrant -*.log diff --git a/debian/test/provision.sh b/debian/test/provision.sh deleted file mode 100644 index a5c7f59712a1..000000000000 --- a/debian/test/provision.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# provisioning script for vagrant boxes for testing the matrix-synapse debs. -# -# Will install the most recent matrix-synapse-py3 deb for this platform from -# the /debs directory. - -set -e - -apt-get update -apt-get install -y lsb-release - -deb=`ls /debs/matrix-synapse-py3_*+$(lsb_release -cs)*.deb | sort | tail -n1` - -debconf-set-selections < Date: Mon, 12 Apr 2021 15:06:54 +0100 Subject: [PATCH 2/4] Update docker/Dockerfile-dhvirtualenv Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> --- docker/Dockerfile-dhvirtualenv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index aa0441cc941e..f9d3afd783bc 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -25,7 +25,7 @@ RUN apt-get update -qq -o Acquire::Languages=none \ build-essential debhelper devscripts equivs lsb-release \ python3-setuptools \ python3-sphinx python3-mock dh-exec dh-python python3-sphinx-rtd-theme \ - && if test "$(lsb_release -cs)" = 'bionic' ; then \ + && if test "$(lsb_release -cs)" = "bionic" ; then \ apt-get install -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ -t bionic-backports debhelper; fi \ && apt-get clean && rm -rf "/var/lib/apt/lists"/* From 22020dc1a152c98e183bae76bd7a1fe484ff04fe Mon Sep 17 00:00:00 2001 From: Dan Callahan Date: Mon, 12 Apr 2021 15:13:33 +0100 Subject: [PATCH 3/4] Re-order comment to avoid log spam Signed-off-by: Dan Callahan --- debian/rules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index a93beacc48fa..4efe663933a7 100755 --- a/debian/rules +++ b/debian/rules @@ -49,7 +49,7 @@ override_dh_shlibdeps: override_dh_virtualenv: ./debian/build_virtualenv +# TODO: Experiment with --buildsystem=dh_virtualenv +# https://dh-virtualenv.readthedocs.io/en/latest/usage.html#experimental-buildsystem-support %: - # TODO: Experiment with --buildsystem=dh_virtualenv - # https://dh-virtualenv.readthedocs.io/en/latest/usage.html#experimental-buildsystem-support dh $@ --with python-virtualenv --buildsystem=pybuild From bd9a08b249723bb0f6219d4e189ab81aeedceadb Mon Sep 17 00:00:00 2001 From: Dan Callahan Date: Mon, 12 Apr 2021 21:12:34 +0100 Subject: [PATCH 4/4] Make /etc/default/matrix-synapse optional This file goes away with dh_installsystemd and the removal of sysv init. Our systemd service files will still read and use it if present. Signed-off-by: Dan Callahan --- debian/matrix-synapse.default | 2 -- debian/matrix-synapse.service | 2 +- docs/systemd-with-workers/system/matrix-synapse-worker@.service | 2 +- docs/systemd-with-workers/system/matrix-synapse.service | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 debian/matrix-synapse.default diff --git a/debian/matrix-synapse.default b/debian/matrix-synapse.default deleted file mode 100644 index f402d73bbf6b..000000000000 --- a/debian/matrix-synapse.default +++ /dev/null @@ -1,2 +0,0 @@ -# Specify environment variables used when running Synapse -# SYNAPSE_CACHE_FACTOR=0.5 (default) diff --git a/debian/matrix-synapse.service b/debian/matrix-synapse.service index 553babf5492d..bde1c6cb9fd9 100644 --- a/debian/matrix-synapse.service +++ b/debian/matrix-synapse.service @@ -5,7 +5,7 @@ Description=Synapse Matrix homeserver Type=notify User=matrix-synapse WorkingDirectory=/var/lib/matrix-synapse -EnvironmentFile=/etc/default/matrix-synapse +EnvironmentFile=-/etc/default/matrix-synapse ExecStartPre=/opt/venvs/matrix-synapse/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --generate-keys ExecStart=/opt/venvs/matrix-synapse/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ ExecReload=/bin/kill -HUP $MAINPID diff --git a/docs/systemd-with-workers/system/matrix-synapse-worker@.service b/docs/systemd-with-workers/system/matrix-synapse-worker@.service index d164e8ce1f88..8f5c44c9d4ef 100644 --- a/docs/systemd-with-workers/system/matrix-synapse-worker@.service +++ b/docs/systemd-with-workers/system/matrix-synapse-worker@.service @@ -15,7 +15,7 @@ Type=notify NotifyAccess=main User=matrix-synapse WorkingDirectory=/var/lib/matrix-synapse -EnvironmentFile=/etc/default/matrix-synapse +EnvironmentFile=-/etc/default/matrix-synapse ExecStart=/opt/venvs/matrix-synapse/bin/python -m synapse.app.generic_worker --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --config-path=/etc/matrix-synapse/workers/%i.yaml ExecReload=/bin/kill -HUP $MAINPID Restart=always diff --git a/docs/systemd-with-workers/system/matrix-synapse.service b/docs/systemd-with-workers/system/matrix-synapse.service index f6b6dfd3ce8e..0c73fb55fb57 100644 --- a/docs/systemd-with-workers/system/matrix-synapse.service +++ b/docs/systemd-with-workers/system/matrix-synapse.service @@ -10,7 +10,7 @@ Type=notify NotifyAccess=main User=matrix-synapse WorkingDirectory=/var/lib/matrix-synapse -EnvironmentFile=/etc/default/matrix-synapse +EnvironmentFile=-/etc/default/matrix-synapse ExecStartPre=/opt/venvs/matrix-synapse/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --generate-keys ExecStart=/opt/venvs/matrix-synapse/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ ExecReload=/bin/kill -HUP $MAINPID