From 16e941bab7b1941a7d062df92f37b43506af1615 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Wed, 14 Nov 2018 17:41:06 -0600 Subject: [PATCH 01/17] debianz --- build_debian.sh | 2 ++ debian/.gitignore | 8 +++++ debian/changelog | 5 ++++ debian/compat | 1 + debian/control | 20 +++++++++++++ debian/cookiecutter.json | 13 +++++++++ debian/copyright | 5 ++++ debian/matrix-synapse.debhelper.log | 45 +++++++++++++++++++++++++++++ debian/matrix-synapse.links | 1 + debian/matrix-synapse.postinst | 15 ++++++++++ debian/matrix-synapse.triggers | 12 ++++++++ debian/rules | 36 +++++++++++++++++++++++ docker/Dockerfile-dhvirtualenv | 17 +++++++++++ 13 files changed, 180 insertions(+) create mode 100755 build_debian.sh create mode 100644 debian/.gitignore create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/cookiecutter.json create mode 100644 debian/copyright create mode 100644 debian/matrix-synapse.debhelper.log create mode 100644 debian/matrix-synapse.links create mode 100644 debian/matrix-synapse.postinst create mode 100644 debian/matrix-synapse.triggers create mode 100755 debian/rules create mode 100644 docker/Dockerfile-dhvirtualenv diff --git a/build_debian.sh b/build_debian.sh new file mode 100755 index 000000000000..97e1214f15b5 --- /dev/null +++ b/build_debian.sh @@ -0,0 +1,2 @@ + +dpkg-buildpackage -us -uc -b diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 000000000000..86763ef35371 --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,8 @@ +matrix-synapse.*.debhelper +matrix-synapse.substvars +matrix-synapse/ +matrix-synapse-*/ +files +debhelper-build-stamp +source/ +.debhelper \ No newline at end of file diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 000000000000..6e6d4ca3b518 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +matrix-synapse (0.33.8) bionic; urgency=low + + * matrix-synapse: Initial debian packaging + + -- Synapse Developers Day, 01 Jan 2014 12:34:56 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 000000000000..ec635144f600 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 000000000000..38fe8075b160 --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: matrix-synapse +Section: contrib/python +Priority: extra +Maintainer: Synapse Developers +Build-Depends: debhelper (>= 9), python3, python3-dev, libffi-dev, libssl-dev, libjpeg-dev, libxslt1-dev, dh-virtualenv (>= 0.10), tar +Standards-Version: 3.9.5 +Homepage: https://github.com/matrix-org/synapse + +Package: matrix-synapse +Architecture: any +Pre-Depends: dpkg (>= 1.16.1), python3, ${misc:Pre-Depends} +Depends: ${python:Depends}, ${misc:Depends}, sqlite3, libpq, libffi, libjpeg, libxslt1, libssl +Description: A Python package and its dependencies packaged up as DEB in an isolated virtualenv. + . + This is a distribution of "matrix-synapse" as a self-contained + Python virtualenv wrapped into a Debian package ("omnibus" package, + all passengers on board). The packaged virtualenv is kept in sync with + the host's interpreter automatically. + . + See https://github.com/spotify/dh-virtualenv for more details. diff --git a/debian/cookiecutter.json b/debian/cookiecutter.json new file mode 100644 index 000000000000..0b38cbc6a527 --- /dev/null +++ b/debian/cookiecutter.json @@ -0,0 +1,13 @@ +{ + "_template": "https://github.com/Springerle/dh-virtualenv-mold.git", + "distro": "bionic", + "email": "synapse@matrix.org", + "full_name": "Synapse Developers", + "package": "matrix-synapse", + "repo_name": "debian", + "short_description": "A Python package and its dependencies packaged up as DEB in an isolated virtualenv.", + "snake": "/usr/bin/python3", + "url": "https://github.com/matrix-org/synapse", + "version": "0.33.8", + "year": "2018" +} diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 000000000000..9030615ca433 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,5 @@ +Copyright (c) 2018, Synapse Developers + +Some rights reserved. + +**TODO** Copy main project's license file here. diff --git a/debian/matrix-synapse.debhelper.log b/debian/matrix-synapse.debhelper.log new file mode 100644 index 000000000000..1687bf04529d --- /dev/null +++ b/debian/matrix-synapse.debhelper.log @@ -0,0 +1,45 @@ +dh_update_autotools_config +dh_auto_configure +dh_prep +dh_installdirs +dh_install +dh_installdocs +dh_installchangelogs +dh_installexamples +dh_installman +dh_installcatalogs +dh_installcron +dh_installdebconf +dh_installemacsen +dh_installifupdown +dh_installinfo +dh_installinit +dh_installmenu +dh_installmime +dh_installmodules +dh_installlogcheck +dh_installlogrotate +dh_installpam +dh_installppp +dh_installudev +dh_installgsettings +dh_bugfiles +dh_ucf +dh_lintian +dh_gconf +dh_icons +dh_perl +dh_usrlocal +dh_link +dh_installwm +dh_installxfonts +dh_strip_nondeterminism +dh_compress +dh_fixperms +dh_missing +dh_strip +dh_makeshlibs +dh_shlibdeps +dh_installdeb +dh_gencontrol +dh_md5sums diff --git a/debian/matrix-synapse.links b/debian/matrix-synapse.links new file mode 100644 index 000000000000..0884e067239f --- /dev/null +++ b/debian/matrix-synapse.links @@ -0,0 +1 @@ +# opt/venvs/matrix-synapse/bin/matrix-synapse usr/bin/matrix-synapse diff --git a/debian/matrix-synapse.postinst b/debian/matrix-synapse.postinst new file mode 100644 index 000000000000..51dfbae800ae --- /dev/null +++ b/debian/matrix-synapse.postinst @@ -0,0 +1,15 @@ +#!/bin/sh +# +# "matrix-synapse" postinst script +# +set -e + +#DEBHELPER# + +# Add your own code here, note that some "dh_venv_*" env vars are available, +# at least these ones: +# +# dh_venv_package Name of the Debian package +# dh_venv_install_dir Root directory for the installed virtualenv + +exit 0 diff --git a/debian/matrix-synapse.triggers b/debian/matrix-synapse.triggers new file mode 100644 index 000000000000..c55a28718391 --- /dev/null +++ b/debian/matrix-synapse.triggers @@ -0,0 +1,12 @@ +# Register interest in Python interpreter changes (Python 2 for now); and +# don't make the Python package dependent on the virtualenv package +# processing (noawait) +interest-noawait /usr/bin/python2.6 +interest-noawait /usr/bin/python2.7 +interest-noawait /usr/bin/python3.3 +interest-noawait /usr/bin/python3.4 +interest-noawait /usr/bin/python3.5 +interest-noawait /usr/bin/python3.6 + +# Also provide a symbolic trigger for all dh-virtualenv packages +interest dh-virtualenv-interpreter-update diff --git a/debian/rules b/debian/rules new file mode 100755 index 000000000000..4061cb1ff2b8 --- /dev/null +++ b/debian/rules @@ -0,0 +1,36 @@ +#!/usr/bin/make -f +# +# Build Debian package using https://github.com/spotify/dh-virtualenv +# +# The below targets create a clean copy of the workdir via +# using "sdist", else "pip" goes haywire when installing from +# sourcedir ".", because that includes the debian build stage, +# and a recursive explosion ensues when symlinks are followed. +# +# It also ensures your MANIFEST is complete and at least covers +# all files needed for a release build. + +# Increase trace logging, see debhelper(7) (uncomment to enable) +#DH_VERBOSE=1 + +export DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs +SNAKE=/usr/bin/python3 +EXTRA_REQUIREMENTS=--preinstall "setuptools>=17.1" --preinstall "pip>=7" --preinstall "wheel" --preinstall "no-manylinux1" --preinstall "lxml" +DH_VENV_ARGS=--with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) #-v +PACKAGE=$(shell dh_listpackages) +VERSION=$(shell $(SNAKE) setup.py --version) +SDIST_DIR=debian/$(PACKAGE)-$(VERSION) + +clean: + test ! -d dist || rm -rf dist + test ! -d $(SDIST_DIR) || rm -rf $(SDIST_DIR) + dh $@ $(DH_VENV_ARGS) + +build-arch: + $(SNAKE) setup.py sdist --formats tar + mkdir -p $(SDIST_DIR) + tar -x -C $(SDIST_DIR) --strip-components=1 --exclude '*.egg-info' -f dist/*.tar + dh $@ $(DH_VENV_ARGS) --sourcedir $(SDIST_DIR) + +%: + dh $@ $(DH_VENV_ARGS) --sourcedir $(SDIST_DIR) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv new file mode 100644 index 000000000000..e047510dc4a5 --- /dev/null +++ b/docker/Dockerfile-dhvirtualenv @@ -0,0 +1,17 @@ +# Build dh-virtualenv's Debian package within a container for any platform +# +# docker build --tag dh-venv-builder --build-arg distro=debian:9 . +# docker build --tag dh-venv-builder --build-arg distro=ubuntu:bionic . +# +# mkdir -p dist && docker run --rm dh-venv-builder tar -C /dpkg -c . | tar -C dist -xv + +ARG distro="debian:stable" +FROM ${distro} AS dpkg-build +RUN apt-get update -qq -o Acquire::Languages=none \ + && env DEBIAN_FRONTEND=noninteractive apt-get install \ + -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ + build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev libxslt1-dev python3-setuptools libssl-dev\ + && apt-get clean && rm -rf "/var/lib/apt/lists"/* +WORKDIR /build +ENTRYPOINT ['/build/build_debian.sh'] + From 81326fcd5a23e397c41ba706ca74382aaf3a1ddd Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Thu, 15 Nov 2018 11:05:57 -0600 Subject: [PATCH 02/17] proper deps --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 38fe8075b160..8a1a5c6c87e7 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Homepage: https://github.com/matrix-org/synapse Package: matrix-synapse Architecture: any Pre-Depends: dpkg (>= 1.16.1), python3, ${misc:Pre-Depends} -Depends: ${python:Depends}, ${misc:Depends}, sqlite3, libpq, libffi, libjpeg, libxslt1, libssl +Depends: ${python:Depends}, ${misc:Depends}, sqlite3, libpq5, libffi6, libjpeg-turbo8, libxslt1.1, openssl Description: A Python package and its dependencies packaged up as DEB in an isolated virtualenv. . This is a distribution of "matrix-synapse" as a self-contained From 859cc6da2ac9c93664c6990d8442b32dd41ef5a6 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Mon, 19 Nov 2018 15:18:01 -0600 Subject: [PATCH 03/17] port over some things --- MANIFEST.in | 2 + debian/changelog | 2 +- debian/config | 9 ++ debian/control | 4 +- debian/copyright | 119 ++++++++++++++++++++++++++- debian/dirs | 3 + debian/hash_password.1 | 90 ++++++++++++++++++++ debian/hash_password.ronn | 69 ++++++++++++++++ debian/install | 3 + debian/log.yaml | 35 ++++++++ debian/manpages | 4 + debian/matrix-synapse.default | 2 + debian/matrix-synapse.postinst | 46 ++++++++--- debian/matrix-synapse.service | 15 ++++ debian/matrix-synapse.triggers | 5 +- debian/po/POTFILES.in | 1 + debian/po/templates.pot | 56 +++++++++++++ debian/register_new_matrix_user.1 | 72 ++++++++++++++++ debian/register_new_matrix_user.ronn | 61 ++++++++++++++ debian/rules | 6 ++ debian/synapse_port_db.1 | 98 ++++++++++++++++++++++ debian/synapse_port_db.ronn | 87 ++++++++++++++++++++ debian/synctl.1 | 63 ++++++++++++++ debian/synctl.ronn | 70 ++++++++++++++++ debian/templates | 19 +++++ docker/Dockerfile-dhvirtualenv | 2 +- tox.ini | 1 + 27 files changed, 922 insertions(+), 22 deletions(-) create mode 100755 debian/config create mode 100644 debian/dirs create mode 100644 debian/hash_password.1 create mode 100644 debian/hash_password.ronn create mode 100644 debian/install create mode 100644 debian/log.yaml create mode 100644 debian/manpages create mode 100644 debian/matrix-synapse.default create mode 100644 debian/matrix-synapse.service create mode 100644 debian/po/POTFILES.in create mode 100644 debian/po/templates.pot create mode 100644 debian/register_new_matrix_user.1 create mode 100644 debian/register_new_matrix_user.ronn create mode 100644 debian/synapse_port_db.1 create mode 100644 debian/synapse_port_db.ronn create mode 100644 debian/synctl.1 create mode 100644 debian/synctl.ronn create mode 100644 debian/templates diff --git a/MANIFEST.in b/MANIFEST.in index d0e49713daec..4ce7c6367445 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -26,6 +26,7 @@ recursive-include synapse/static *.js exclude Dockerfile exclude .dockerignore exclude test_postgresql.sh +exclude build_debian.sh include pyproject.toml recursive-include changelog.d * @@ -35,6 +36,7 @@ prune demo/etc prune docker prune .circleci prune .coveragerc +prune debian exclude jenkins* recursive-exclude jenkins *.sh diff --git a/debian/changelog b/debian/changelog index 6e6d4ca3b518..7c85eba4fd7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -matrix-synapse (0.33.8) bionic; urgency=low +matrix-synapse (0.33.9) bionic; urgency=low * matrix-synapse: Initial debian packaging diff --git a/debian/config b/debian/config new file mode 100755 index 000000000000..9fb69132987f --- /dev/null +++ b/debian/config @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule + +db_input high matrix-synapse/server-name || true +db_input high matrix-synapse/report-stats || true +db_go diff --git a/debian/control b/debian/control index 8a1a5c6c87e7..95ebad4102fd 100644 --- a/debian/control +++ b/debian/control @@ -2,14 +2,14 @@ Source: matrix-synapse Section: contrib/python Priority: extra Maintainer: Synapse Developers -Build-Depends: debhelper (>= 9), python3, python3-dev, libffi-dev, libssl-dev, libjpeg-dev, libxslt1-dev, dh-virtualenv (>= 0.10), tar +Build-Depends: debhelper (>= 9), python3, python3-dev, libffi-dev, libssl-dev, libjpeg-dev, libxslt1-dev, dh-virtualenv (>= 0.10), tar, lsb-release Standards-Version: 3.9.5 Homepage: https://github.com/matrix-org/synapse Package: matrix-synapse Architecture: any Pre-Depends: dpkg (>= 1.16.1), python3, ${misc:Pre-Depends} -Depends: ${python:Depends}, ${misc:Depends}, sqlite3, libpq5, libffi6, libjpeg-turbo8, libxslt1.1, openssl +Depends: ${python:Depends}, ${misc:Depends}, adduser, sqlite3, libpq5, libffi6, libjpeg-turbo8, libxslt1.1, openssl Description: A Python package and its dependencies packaged up as DEB in an isolated virtualenv. . This is a distribution of "matrix-synapse" as a self-contained diff --git a/debian/copyright b/debian/copyright index 9030615ca433..95c21ea12a89 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,5 +1,118 @@ -Copyright (c) 2018, Synapse Developers +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: synapse +Source: https://github.com/matrix-org/synapse -Some rights reserved. +Files: * +Copyright: 2014-2017, OpenMarket Ltd, 2017-2018 New Vector Ltd +License: Apache-2.0 -**TODO** Copy main project's license file here. +Files: synapse/config/saml2.py +Copyright: 2015, Ericsson +License: Apache-2.0 + +Files: synapse/config/jwt.py +Copyright: 2015, Niklas Riekenbrauck +License: Apache-2.0 + +Files: synapse/config/workers.py +Copyright: 2016, matrix.org +License: Apache-2.0 + +Files: synapse/config/repository.py +Copyright: 2014-2015, matrix.org +License: Apache-2.0 + +Files: contrib/jitsimeetbridge/unjingle/strophe/base64.js +Copyright: Public Domain (Tyler Akins http://rumkin.com) +License: public-domain + This code was written by Tyler Akins and has been placed in the + public domain. It would be nice if you left this header intact. + Base64 code from Tyler Akins -- http://rumkin.com + +Files: contrib/jitsimeetbridge/unjingle/strophe/md5.js +Copyright: 1999-2002, Paul Johnston & Contributors +License: BSD-3-clause + +Files: contrib/jitsimeetbridge/unjingle/strophe/strophe.js +Copyright: 2006-2008, OGG, LLC +License: Expat + +Files: contrib/jitsimeetbridge/unjingle/strophe/XMLHttpRequest.js +Copyright: 2010 passive.ly LLC +License: Expat + +Files: contrib/jitsimeetbridge/unjingle/*.js +Copyright: 2014 Jitsi +License: Apache-2.0 + +Files: debian/* +Copyright: 2016-2017, Erik Johnston + 2017, Rahul De + 2017, Sunil Mohan Adapa +License: Apache-2.0 + +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the full text of the Apache License version + 2.0 can be found in the file + `/usr/share/common-licenses/Apache-2.0'. + +License: BSD-3-clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + . + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following + disclaimer. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided with + the distribution. + . + Neither the name of the author nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License: Expat + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + . + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 000000000000..9d2a980c928f --- /dev/null +++ b/debian/dirs @@ -0,0 +1,3 @@ +etc/matrix-synapse +var/lib/matrix-synapse +var/log/matrix-synapse diff --git a/debian/hash_password.1 b/debian/hash_password.1 new file mode 100644 index 000000000000..383f4529915c --- /dev/null +++ b/debian/hash_password.1 @@ -0,0 +1,90 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "HASH_PASSWORD" "1" "February 2017" "" "" +. +.SH "NAME" +\fBhash_password\fR \- Calculate the hash of a new password, so that passwords can be reset +. +.SH "SYNOPSIS" +\fBhash_password\fR [\fB\-p\fR|\fB\-\-password\fR [password]] [\fB\-c\fR|\fB\-\-config\fR \fIfile\fR] +. +.SH "DESCRIPTION" +\fBhash_password\fR calculates the hash of a supplied password using bcrypt\. +. +.P +\fBhash_password\fR takes a password as an parameter either on the command line or the \fBSTDIN\fR if not supplied\. +. +.P +It accepts an YAML file which can be used to specify parameters like the number of rounds for bcrypt and password_config section having the pepper value used for the hashing\. By default \fBbcrypt_rounds\fR is set to \fB10\fR\. +. +.P +The hashed password is written on the \fBSTDOUT\fR\. +. +.SH "FILES" +A sample YAML file accepted by \fBhash_password\fR is described below: +. +.P +bcrypt_rounds: 17 password_config: pepper: "random hashing pepper" +. +.SH "OPTIONS" +. +.TP +\fB\-p\fR, \fB\-\-password\fR +Read the password form the command line if [password] is supplied\. If not, prompt the user and read the password form the \fBSTDIN\fR\. It is not recommended to type the password on the command line directly\. Use the STDIN instead\. +. +.TP +\fB\-c\fR, \fB\-\-config\fR +Read the supplied YAML \fIfile\fR containing the options \fBbcrypt_rounds\fR and the \fBpassword_config\fR section containing the \fBpepper\fR value\. +. +.SH "EXAMPLES" +Hash from the command line: +. +.IP "" 4 +. +.nf + +$ hash_password \-p "p@ssw0rd" +$2b$12$VJNqWQYfsWTEwcELfoSi4Oa8eA17movHqqi8\.X8fWFpum7SxZ9MFe +. +.fi +. +.IP "" 0 +. +.P +Hash from the STDIN: +. +.IP "" 4 +. +.nf + +$ hash_password +Password: +Confirm password: +$2b$12$AszlvfmJl2esnyhmn8m/kuR2tdXgROWtWxnX\.rcuAbM8ErLoUhybG +. +.fi +. +.IP "" 0 +. +.P +Using a config file: +. +.IP "" 4 +. +.nf + +$ hash_password \-c config\.yml +Password: +Confirm password: +$2b$12$CwI\.wBNr\.w3kmiUlV3T5s\.GT2wH7uebDCovDrCOh18dFedlANK99O +. +.fi +. +.IP "" 0 +. +.SH "COPYRIGHT" +This man page was written by Rahul De <\fIrahulde@swecha\.net\fR> for Debian GNU/Linux distribution\. +. +.SH "SEE ALSO" +synctl(1), synapse_port_db(1), register_new_matrix_user(1) diff --git a/debian/hash_password.ronn b/debian/hash_password.ronn new file mode 100644 index 000000000000..0b2afa737463 --- /dev/null +++ b/debian/hash_password.ronn @@ -0,0 +1,69 @@ +hash_password(1) -- Calculate the hash of a new password, so that passwords can be reset +======================================================================================== + +## SYNOPSIS + +`hash_password` [`-p`|`--password` [password]] [`-c`|`--config` ] + +## DESCRIPTION + +**hash_password** calculates the hash of a supplied password using bcrypt. + +`hash_password` takes a password as an parameter either on the command line +or the `STDIN` if not supplied. + +It accepts an YAML file which can be used to specify parameters like the +number of rounds for bcrypt and password_config section having the pepper +value used for the hashing. By default `bcrypt_rounds` is set to **10**. + +The hashed password is written on the `STDOUT`. + +## FILES + +A sample YAML file accepted by `hash_password` is described below: + + bcrypt_rounds: 17 + password_config: + pepper: "random hashing pepper" + +## OPTIONS + + * `-p`, `--password`: + Read the password form the command line if [password] is supplied. + If not, prompt the user and read the password form the `STDIN`. + It is not recommended to type the password on the command line + directly. Use the STDIN instead. + + * `-c`, `--config`: + Read the supplied YAML containing the options `bcrypt_rounds` + and the `password_config` section containing the `pepper` value. + +## EXAMPLES + +Hash from the command line: + + $ hash_password -p "p@ssw0rd" + $2b$12$VJNqWQYfsWTEwcELfoSi4Oa8eA17movHqqi8.X8fWFpum7SxZ9MFe + +Hash from the STDIN: + + $ hash_password + Password: + Confirm password: + $2b$12$AszlvfmJl2esnyhmn8m/kuR2tdXgROWtWxnX.rcuAbM8ErLoUhybG + +Using a config file: + + $ hash_password -c config.yml + Password: + Confirm password: + $2b$12$CwI.wBNr.w3kmiUlV3T5s.GT2wH7uebDCovDrCOh18dFedlANK99O + +## COPYRIGHT + +This man page was written by Rahul De <> +for Debian GNU/Linux distribution. + +## SEE ALSO + +synctl(1), synapse_port_db(1), register_new_matrix_user(1) diff --git a/debian/install b/debian/install new file mode 100644 index 000000000000..d4427cf9d1e9 --- /dev/null +++ b/debian/install @@ -0,0 +1,3 @@ +../homeserver.yaml etc/matrix-synapse +../log.yaml etc/matrix-synapse +../*.service lib/systemd/system \ No newline at end of file diff --git a/debian/log.yaml b/debian/log.yaml new file mode 100644 index 000000000000..b44a8901f656 --- /dev/null +++ b/debian/log.yaml @@ -0,0 +1,35 @@ + +version: 1 + +formatters: + precise: + format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s- %(message)s' + +filters: + context: + (): synapse.util.logcontext.LoggingContextFilter + request: "" + +handlers: + file: + class: logging.handlers.RotatingFileHandler + formatter: precise + filename: /var/log/matrix-synapse/homeserver.log + maxBytes: 104857600 + backupCount: 10 + filters: [context] + console: + class: logging.StreamHandler + formatter: precise + level: WARN + +loggers: + synapse: + level: INFO + + synapse.storage.SQL: + level: INFO + +root: + level: INFO + handlers: [file, console] diff --git a/debian/manpages b/debian/manpages new file mode 100644 index 000000000000..2c3058353060 --- /dev/null +++ b/debian/manpages @@ -0,0 +1,4 @@ +debian/hash_password.1 +debian/register_new_matrix_user.1 +debian/synapse_port_db.1 +debian/synctl.1 diff --git a/debian/matrix-synapse.default b/debian/matrix-synapse.default new file mode 100644 index 000000000000..65dc2f33d855 --- /dev/null +++ b/debian/matrix-synapse.default @@ -0,0 +1,2 @@ +# Specify environment variables used when running Synapse +# SYNAPSE_CACHE_FACTOR=1 (default) diff --git a/debian/matrix-synapse.postinst b/debian/matrix-synapse.postinst index 51dfbae800ae..0509acd0a4fd 100644 --- a/debian/matrix-synapse.postinst +++ b/debian/matrix-synapse.postinst @@ -1,15 +1,39 @@ -#!/bin/sh -# -# "matrix-synapse" postinst script -# -set -e +#!/bin/sh -e -#DEBHELPER# +. /usr/share/debconf/confmodule + +CONFIGFILE_SERVERNAME="/etc/matrix-synapse/conf.d/server_name.yaml" +CONFIGFILE_REPORTSTATS="/etc/matrix-synapse/conf.d/report_stats.yaml" +USER="matrix-synapse" + +case "$1" in + configure|reconfigure) + # Set server name in config file + mkdir -p "/etc/matrix-synapse/conf.d/" + db_get matrix-synapse/server-name + + if [ "$RET" ]; then + echo "server_name: $RET" > $CONFIGFILE_SERVERNAME + fi + + db_get matrix-synapse/report-stats + if [ "$RET" ]; then + echo "report_stats: $RET" > $CONFIGFILE_REPORTSTATS + fi -# Add your own code here, note that some "dh_venv_*" env vars are available, -# at least these ones: -# -# dh_venv_package Name of the Debian package -# dh_venv_install_dir Root directory for the installed virtualenv + if ! getent passwd $USER >/dev/null; then + adduser --quiet --system --no-create-home --home /var/lib/matrix-synapse $USER + fi + + for DIR in /var/lib/matrix-synapse /var/log/matrix-synapse /etc/matrix-synapse; do + if ! dpkg-statoverride --list --quiet $DIR >/dev/null; then + dpkg-statoverride --force --quiet --update --add $USER nogroup 0755 $DIR + fi + done + + ;; +esac + +#DEBHELPER# exit 0 diff --git a/debian/matrix-synapse.service b/debian/matrix-synapse.service new file mode 100644 index 000000000000..ab94e073a610 --- /dev/null +++ b/debian/matrix-synapse.service @@ -0,0 +1,15 @@ +[Unit] +Description=Synapse Matrix homeserver + +[Service] +Type=simple +User=matrix-synapse +WorkingDirectory=/var/lib/matrix-synapse +EnvironmentFile=/etc/default/matrix-synapse +ExecStartPre=/usr/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --generate-keys +ExecStart=/usr/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target diff --git a/debian/matrix-synapse.triggers b/debian/matrix-synapse.triggers index c55a28718391..4fac39bff95e 100644 --- a/debian/matrix-synapse.triggers +++ b/debian/matrix-synapse.triggers @@ -1,12 +1,9 @@ # Register interest in Python interpreter changes (Python 2 for now); and # don't make the Python package dependent on the virtualenv package # processing (noawait) -interest-noawait /usr/bin/python2.6 -interest-noawait /usr/bin/python2.7 -interest-noawait /usr/bin/python3.3 -interest-noawait /usr/bin/python3.4 interest-noawait /usr/bin/python3.5 interest-noawait /usr/bin/python3.6 +interest-noawait /usr/bin/python3.7 # Also provide a symbolic trigger for all dh-virtualenv packages interest dh-virtualenv-interpreter-update diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in new file mode 100644 index 000000000000..cef83a3407df --- /dev/null +++ b/debian/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] templates diff --git a/debian/po/templates.pot b/debian/po/templates.pot new file mode 100644 index 000000000000..84d960761a8e --- /dev/null +++ b/debian/po/templates.pot @@ -0,0 +1,56 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the matrix-synapse package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: matrix-synapse\n" +"Report-Msgid-Bugs-To: matrix-synapse@packages.debian.org\n" +"POT-Creation-Date: 2017-02-21 07:51+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: string +#. Description +#: ../templates:1001 +msgid "Name of the server:" +msgstr "" + +#. Type: string +#. Description +#: ../templates:1001 +msgid "" +"The name that this homeserver will appear as, to clients and other servers " +"via federation. This name should match the SRV record published in DNS." +msgstr "" + +#. Type: boolean +#. Description +#: ../templates:2001 +msgid "Report anonymous statistics?" +msgstr "" + +#. Type: boolean +#. Description +#: ../templates:2001 +msgid "" +"Developers of Matrix and Synapse really appreciate helping the project out " +"by reporting anonymized usage statistics from this homeserver. Only very " +"basic aggregate data (e.g. number of users) will be reported, but it helps " +"track the growth of the Matrix community, and helps in making Matrix a " +"success, as well as to convince other networks that they should peer with " +"Matrix." +msgstr "" + +#. Type: boolean +#. Description +#: ../templates:2001 +msgid "Thank you." +msgstr "" diff --git a/debian/register_new_matrix_user.1 b/debian/register_new_matrix_user.1 new file mode 100644 index 000000000000..99156a73541d --- /dev/null +++ b/debian/register_new_matrix_user.1 @@ -0,0 +1,72 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "REGISTER_NEW_MATRIX_USER" "1" "February 2017" "" "" +. +.SH "NAME" +\fBregister_new_matrix_user\fR \- Used to register new users with a given home server when registration has been disabled +. +.SH "SYNOPSIS" +\fBregister_new_matrix_user\fR options\.\.\. +. +.SH "DESCRIPTION" +\fBregister_new_matrix_user\fR registers new users with a given home server when registration has been disabled\. For this to work, the home server must be configured with the \'registration_shared_secret\' option set\. +. +.P +This accepts the user credentials like the username, password, is user an admin or not and registers the user onto the homeserver database\. Also, a YAML file containing the shared secret can be provided\. If not, the shared secret can be provided via the command line\. +. +.P +By default it assumes the home server URL to be \fBhttps://localhost:8448\fR\. This can be changed via the \fBserver_url\fR command line option\. +. +.SH "FILES" +A sample YAML file accepted by \fBregister_new_matrix_user\fR is described below: +. +.IP "" 4 +. +.nf + +registration_shared_secret: "s3cr3t" +. +.fi +. +.IP "" 0 +. +.SH "OPTIONS" +. +.TP +\fB\-u\fR, \fB\-\-user\fR +Local part of the new user\. Will prompt if omitted\. +. +.TP +\fB\-p\fR, \fB\-\-password\fR +New password for user\. Will prompt if omitted\. Supplying the password on the command line is not recommended\. Use the STDIN instead\. +. +.TP +\fB\-a\fR, \fB\-\-admin\fR +Register new user as an admin\. Will prompt if omitted\. +. +.TP +\fB\-c\fR, \fB\-\-config\fR +Path to server config file containing the shared secret\. +. +.TP +\fB\-k\fR, \fB\-\-shared\-secret\fR +Shared secret as defined in server config file\. This is an optional parameter as it can be also supplied via the YAML file\. +. +.TP +\fBserver_url\fR +URL of the home server\. Defaults to \'https://localhost:8448\'\. +. +.SH "EXAMPLES" +. +.nf + +$ register_new_matrix_user \-u user1 \-p p@ssword \-a \-c config\.yaml +. +.fi +. +.SH "COPYRIGHT" +This man page was written by Rahul De <\fIrahulde@swecha\.net\fR> for Debian GNU/Linux distribution\. +. +.SH "SEE ALSO" +synctl(1), synapse_port_db(1), hash_password(1) diff --git a/debian/register_new_matrix_user.ronn b/debian/register_new_matrix_user.ronn new file mode 100644 index 000000000000..4c22e74dde64 --- /dev/null +++ b/debian/register_new_matrix_user.ronn @@ -0,0 +1,61 @@ +register_new_matrix_user(1) -- Used to register new users with a given home server when registration has been disabled +====================================================================================================================== + +## SYNOPSIS + +`register_new_matrix_user` options... + +## DESCRIPTION + +**register_new_matrix_user** registers new users with a given home server when +registration has been disabled. For this to work, the home server must be +configured with the 'registration_shared_secret' option set. + +This accepts the user credentials like the username, password, is user an +admin or not and registers the user onto the homeserver database. Also, +a YAML file containing the shared secret can be provided. If not, the +shared secret can be provided via the command line. + +By default it assumes the home server URL to be `https://localhost:8448`. +This can be changed via the `server_url` command line option. + +## FILES + +A sample YAML file accepted by `register_new_matrix_user` is described below: + + registration_shared_secret: "s3cr3t" + +## OPTIONS + + * `-u`, `--user`: + Local part of the new user. Will prompt if omitted. + + * `-p`, `--password`: + New password for user. Will prompt if omitted. Supplying the password + on the command line is not recommended. Use the STDIN instead. + + * `-a`, `--admin`: + Register new user as an admin. Will prompt if omitted. + + * `-c`, `--config`: + Path to server config file containing the shared secret. + + * `-k`, `--shared-secret`: + Shared secret as defined in server config file. This is an optional + parameter as it can be also supplied via the YAML file. + + * `server_url`: + URL of the home server. Defaults to 'https://localhost:8448'. + +## EXAMPLES + + $ register_new_matrix_user -u user1 -p p@ssword -a -c config.yaml + +## COPYRIGHT + +This man page was written by Rahul De <> +for Debian GNU/Linux distribution. + +## SEE ALSO + +synctl(1), synapse_port_db(1), hash_password(1) diff --git a/debian/rules b/debian/rules index 4061cb1ff2b8..7bc4f4578da7 100755 --- a/debian/rules +++ b/debian/rules @@ -15,11 +15,13 @@ export DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs SNAKE=/usr/bin/python3 +DEB_BUILD_OPTIONS=noddebs EXTRA_REQUIREMENTS=--preinstall "setuptools>=17.1" --preinstall "pip>=7" --preinstall "wheel" --preinstall "no-manylinux1" --preinstall "lxml" DH_VENV_ARGS=--with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) #-v PACKAGE=$(shell dh_listpackages) VERSION=$(shell $(SNAKE) setup.py --version) SDIST_DIR=debian/$(PACKAGE)-$(VERSION) +RELEASE_VERSION=$(VERSION)~$(shell lsb_release -c -s) clean: test ! -d dist || rm -rf dist @@ -32,5 +34,9 @@ build-arch: tar -x -C $(SDIST_DIR) --strip-components=1 --exclude '*.egg-info' -f dist/*.tar dh $@ $(DH_VENV_ARGS) --sourcedir $(SDIST_DIR) + +override_dh_gencontrol: + dh_gencontrol -- -v$(RELEASE_VERSION) + %: dh $@ $(DH_VENV_ARGS) --sourcedir $(SDIST_DIR) diff --git a/debian/synapse_port_db.1 b/debian/synapse_port_db.1 new file mode 100644 index 000000000000..4e6bc0482761 --- /dev/null +++ b/debian/synapse_port_db.1 @@ -0,0 +1,98 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "SYNAPSE_PORT_DB" "1" "February 2017" "" "" +. +.SH "NAME" +\fBsynapse_port_db\fR \- A script to port an existing synapse SQLite database to a new PostgreSQL database\. +. +.SH "SYNOPSIS" +\fBsynapse_port_db\fR [\-v] \-\-sqlite\-database=\fIdbfile\fR \-\-postgres\-config=\fIyamlconfig\fR [\-\-curses] [\-\-batch\-size=\fIbatch\-size\fR] +. +.SH "DESCRIPTION" +\fBsynapse_port_db\fR ports an existing synapse SQLite database to a new PostgreSQL database\. +. +.P +SQLite database is specified with \fB\-\-sqlite\-database\fR option and PostgreSQL configuration required to connect to PostgreSQL database is provided using \fB\-\-postgres\-config\fR configuration\. The configuration is specified in YAML format\. +. +.SH "OPTIONS" +. +.TP +\fB\-v\fR +Print log messages in \fBdebug\fR level instead of \fBinfo\fR level\. +. +.TP +\fB\-\-sqlite\-database\fR +The snapshot of the SQLite database file\. This must not be currently used by a running synapse server\. +. +.TP +\fB\-\-postgres\-config\fR +The database config file for the PostgreSQL database\. +. +.TP +\fB\-\-curses\fR +Display a curses based progress UI\. +. +.SH "CONFIG FILE" +The postgres configuration file must be a valid YAML file with the following options\. +. +.IP "\(bu" 4 +\fBdatabase\fR: Database configuration section\. This section header can be ignored and the options below may be specified as top level keys\. +. +.IP "\(bu" 4 +\fBname\fR: Connector to use when connecting to the database\. This value must be \fBpsycopg2\fR\. +. +.IP "\(bu" 4 +\fBargs\fR: DB API 2\.0 compatible arguments to send to the \fBpsycopg2\fR module\. +. +.IP "\(bu" 4 +\fBdbname\fR \- the database name +. +.IP "\(bu" 4 +\fBuser\fR \- user name used to authenticate +. +.IP "\(bu" 4 +\fBpassword\fR \- password used to authenticate +. +.IP "\(bu" 4 +\fBhost\fR \- database host address (defaults to UNIX socket if not provided) +. +.IP "\(bu" 4 +\fBport\fR \- connection port number (defaults to 5432 if not provided) +. +.IP "" 0 + +. +.IP "\(bu" 4 +\fBsynchronous_commit\fR: Optional\. Default is True\. If the value is \fBFalse\fR, enable asynchronous commit and don\'t wait for the server to call fsync before ending the transaction\. See: https://www\.postgresql\.org/docs/current/static/wal\-async\-commit\.html +. +.IP "" 0 + +. +.IP "" 0 +. +.P +Following example illustrates the configuration file format\. +. +.IP "" 4 +. +.nf + +database: + name: psycopg2 + args: + dbname: synapsedb + user: synapseuser + password: ORohmi9Eet=ohphi + host: localhost + synchronous_commit: false +. +.fi +. +.IP "" 0 +. +.SH "COPYRIGHT" +This man page was written by Sunil Mohan Adapa <\fIsunil@medhas\.org\fR> for Debian GNU/Linux distribution\. +. +.SH "SEE ALSO" +synctl(1), hash_password(1), register_new_matrix_user(1) diff --git a/debian/synapse_port_db.ronn b/debian/synapse_port_db.ronn new file mode 100644 index 000000000000..fcb32ebd0df8 --- /dev/null +++ b/debian/synapse_port_db.ronn @@ -0,0 +1,87 @@ +synapse_port_db(1) -- A script to port an existing synapse SQLite database to a new PostgreSQL database. +============================================= + +## SYNOPSIS + +`synapse_port_db` [-v] --sqlite-database= --postgres-config= [--curses] [--batch-size=] + +## DESCRIPTION + +**synapse_port_db** ports an existing synapse SQLite database to a new +PostgreSQL database. + +SQLite database is specified with `--sqlite-database` option and +PostgreSQL configuration required to connect to PostgreSQL database is +provided using `--postgres-config` configuration. The configuration +is specified in YAML format. + +## OPTIONS + + * `-v`: + Print log messages in `debug` level instead of `info` level. + + * `--sqlite-database`: + The snapshot of the SQLite database file. This must not be + currently used by a running synapse server. + + * `--postgres-config`: + The database config file for the PostgreSQL database. + + * `--curses`: + Display a curses based progress UI. + +## CONFIG FILE + +The postgres configuration file must be a valid YAML file with the +following options. + + * `database`: + Database configuration section. This section header can be + ignored and the options below may be specified as top level + keys. + + * `name`: + Connector to use when connecting to the database. This value must + be `psycopg2`. + + * `args`: + DB API 2.0 compatible arguments to send to the `psycopg2` module. + + * `dbname` - the database name + + * `user` - user name used to authenticate + + * `password` - password used to authenticate + + * `host` - database host address (defaults to UNIX socket if not + provided) + + * `port` - connection port number (defaults to 5432 if not + provided) + + + * `synchronous_commit`: + Optional. Default is True. If the value is `False`, enable + asynchronous commit and don't wait for the server to call fsync + before ending the transaction. See: + https://www.postgresql.org/docs/current/static/wal-async-commit.html + +Following example illustrates the configuration file format. + + database: + name: psycopg2 + args: + dbname: synapsedb + user: synapseuser + password: ORohmi9Eet=ohphi + host: localhost + synchronous_commit: false + +## COPYRIGHT + +This man page was written by Sunil Mohan Adapa <> for +Debian GNU/Linux distribution. + +## SEE ALSO + +synctl(1), hash_password(1), register_new_matrix_user(1) diff --git a/debian/synctl.1 b/debian/synctl.1 new file mode 100644 index 000000000000..437f8f9e0e12 --- /dev/null +++ b/debian/synctl.1 @@ -0,0 +1,63 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "SYNCTL" "1" "February 2017" "" "" +. +.SH "NAME" +\fBsynctl\fR \- Synapse server control interface +. +.SH "SYNOPSIS" +Start, stop or restart synapse server\. +. +.P +\fBsynctl\fR {start|stop|restart} [configfile] [\-w|\-\-worker=\fIWORKERCONFIG\fR] [\-a|\-\-all\-processes=\fIWORKERCONFIGDIR\fR] +. +.SH "DESCRIPTION" +\fBsynctl\fR can be used to start, stop or restart Synapse server\. The control operation can be done on all processes or a single worker process\. +. +.SH "OPTIONS" +. +.TP +\fBaction\fR +The value of action should be one of \fBstart\fR, \fBstop\fR or \fBrestart\fR\. +. +.TP +\fBconfigfile\fR +Optional path of the configuration file to use\. Default value is \fBhomeserver\.yaml\fR\. The configuration file must exist for the operation to succeed\. +. +.TP +\fB\-w\fR, \fB\-\-worker\fR: +. +.IP +Perform start, stop or restart operations on a single worker\. Incompatible with \fB\-a\fR|\fB\-\-all\-processes\fR\. Value passed must be a valid worker\'s configuration file\. +. +.TP +\fB\-a\fR, \fB\-\-all\-processes\fR: +. +.IP +Perform start, stop or restart operations on all the workers in the given directory and the main synapse process\. Incompatible with \fB\-w\fR|\fB\-\-worker\fR\. Value passed must be a directory containing valid work configuration files\. All files ending with \fB\.yaml\fR extension shall be considered as configuration files and all other files in the directory are ignored\. +. +.SH "CONFIGURATION FILE" +Configuration file may be generated as follows: +. +.IP "" 4 +. +.nf + +$ python \-B \-m synapse\.app\.homeserver \-c config\.yaml \-\-generate\-config \-\-server\-name= +. +.fi +. +.IP "" 0 +. +.SH "ENVIRONMENT" +. +.TP +\fBSYNAPSE_CACHE_FACTOR\fR +Synapse\'s architecture is quite RAM hungry currently \- a lot of recent room data and metadata is deliberately cached in RAM in order to speed up common requests\. This will be improved in future, but for now the easiest way to either reduce the RAM usage (at the risk of slowing things down) is to set the SYNAPSE_CACHE_FACTOR environment variable\. Roughly speaking, a SYNAPSE_CACHE_FACTOR of 1\.0 will max out at around 3\-4GB of resident memory \- this is what we currently run the matrix\.org on\. The default setting is currently 0\.1, which is probably around a ~700MB footprint\. You can dial it down further to 0\.02 if desired, which targets roughly ~512MB\. Conversely you can dial it up if you need performance for lots of users and have a box with a lot of RAM\. +. +.SH "COPYRIGHT" +This man page was written by Sunil Mohan Adapa <\fIsunil@medhas\.org\fR> for Debian GNU/Linux distribution\. +. +.SH "SEE ALSO" +synapse_port_db(1), hash_password(1), register_new_matrix_user(1) diff --git a/debian/synctl.ronn b/debian/synctl.ronn new file mode 100644 index 000000000000..a73c832f6278 --- /dev/null +++ b/debian/synctl.ronn @@ -0,0 +1,70 @@ +synctl(1) -- Synapse server control interface +============================================= + +## SYNOPSIS + Start, stop or restart synapse server. + +`synctl` {start|stop|restart} [configfile] [-w|--worker=] [-a|--all-processes=] + +## DESCRIPTION + +**synctl** can be used to start, stop or restart Synapse server. The +control operation can be done on all processes or a single worker +process. + +## OPTIONS + + * `action`: + The value of action should be one of `start`, `stop` or `restart`. + + * `configfile`: + Optional path of the configuration file to use. Default value is + `homeserver.yaml`. The configuration file must exist for the + operation to succeed. + + * `-w`, `--worker`: + + Perform start, stop or restart operations on a single worker. + Incompatible with `-a`|`--all-processes`. Value passed must be a + valid worker's configuration file. + + * `-a`, `--all-processes`: + + Perform start, stop or restart operations on all the workers in + the given directory and the main synapse process. Incompatible + with `-w`|`--worker`. Value passed must be a directory containing + valid work configuration files. All files ending with `.yaml` + extension shall be considered as configuration files and all other + files in the directory are ignored. + +## CONFIGURATION FILE + +Configuration file may be generated as follows: + + $ python -B -m synapse.app.homeserver -c config.yaml --generate-config --server-name= + +## ENVIRONMENT + + * `SYNAPSE_CACHE_FACTOR`: + Synapse's architecture is quite RAM hungry currently - a lot of + recent room data and metadata is deliberately cached in RAM in + order to speed up common requests. This will be improved in + future, but for now the easiest way to either reduce the RAM usage + (at the risk of slowing things down) is to set the + SYNAPSE_CACHE_FACTOR environment variable. Roughly speaking, a + SYNAPSE_CACHE_FACTOR of 1.0 will max out at around 3-4GB of + resident memory - this is what we currently run the matrix.org + on. The default setting is currently 0.1, which is probably around + a ~700MB footprint. You can dial it down further to 0.02 if + desired, which targets roughly ~512MB. Conversely you can dial it + up if you need performance for lots of users and have a box with a + lot of RAM. + +## COPYRIGHT + +This man page was written by Sunil Mohan Adapa <> for +Debian GNU/Linux distribution. + +## SEE ALSO + +synapse_port_db(1), hash_password(1), register_new_matrix_user(1) diff --git a/debian/templates b/debian/templates new file mode 100644 index 000000000000..647358731cd6 --- /dev/null +++ b/debian/templates @@ -0,0 +1,19 @@ +Template: matrix-synapse/server-name +Type: string +_Description: Name of the server: + The name that this homeserver will appear as, to clients and other + servers via federation. This name should match the SRV record + published in DNS. + +Template: matrix-synapse/report-stats +Type: boolean +Default: false +_Description: Report anonymous statistics? + Developers of Matrix and Synapse really appreciate helping the + project out by reporting anonymized usage statistics from this + homeserver. Only very basic aggregate data (e.g. number of users) + will be reported, but it helps track the growth of the Matrix + community, and helps in making Matrix a success, as well as to + convince other networks that they should peer with Matrix. + . + Thank you. diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index e047510dc4a5..b16e1cbb2258 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -10,7 +10,7 @@ FROM ${distro} AS dpkg-build RUN apt-get update -qq -o Acquire::Languages=none \ && env DEBIAN_FRONTEND=noninteractive apt-get install \ -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ - build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev libxslt1-dev python3-setuptools libssl-dev\ + build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev libxslt1-dev python3-setuptools libssl-dev lsb-release\ && apt-get clean && rm -rf "/var/lib/apt/lists"/* WORKDIR /build ENTRYPOINT ['/build/build_debian.sh'] diff --git a/tox.ini b/tox.ini index dfd9afdd495d..125a48f04a2c 100644 --- a/tox.ini +++ b/tox.ini @@ -123,6 +123,7 @@ setenv = [testenv:packaging] +skip_install=True deps = check-manifest commands = From 66b4219be88b54ca4f0e7fc5a2d7aee9c381fb0e Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Mon, 19 Nov 2018 16:50:31 -0600 Subject: [PATCH 04/17] update --- .gitignore | 3 ++ build_debian.sh | 4 +++ debian/.gitignore | 1 + debian/matrix-synapse.debhelper.log | 45 ----------------------------- debian/matrix-synapse.service | 4 +-- debian/rules | 3 +- docker/Dockerfile-dhvirtualenv | 12 ++------ docker/build_debian_packages.sh | 9 ++++++ 8 files changed, 22 insertions(+), 59 deletions(-) delete mode 100644 debian/matrix-synapse.debhelper.log create mode 100644 docker/build_debian_packages.sh diff --git a/.gitignore b/.gitignore index 3b2252ad8a5a..4923451df3ad 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,6 @@ env/ .vscode/ .ropeproject/ + +debs/ +*.deb \ No newline at end of file diff --git a/build_debian.sh b/build_debian.sh index 97e1214f15b5..cd5a438aa75f 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -1,2 +1,6 @@ +#!/bin/bash + +set -e dpkg-buildpackage -us -uc -b +cp ../*.deb /build/debs \ No newline at end of file diff --git a/debian/.gitignore b/debian/.gitignore index 86763ef35371..552b45f8c27b 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1,4 +1,5 @@ matrix-synapse.*.debhelper +matrix-synapse.*.debhelper.log matrix-synapse.substvars matrix-synapse/ matrix-synapse-*/ diff --git a/debian/matrix-synapse.debhelper.log b/debian/matrix-synapse.debhelper.log deleted file mode 100644 index 1687bf04529d..000000000000 --- a/debian/matrix-synapse.debhelper.log +++ /dev/null @@ -1,45 +0,0 @@ -dh_update_autotools_config -dh_auto_configure -dh_prep -dh_installdirs -dh_install -dh_installdocs -dh_installchangelogs -dh_installexamples -dh_installman -dh_installcatalogs -dh_installcron -dh_installdebconf -dh_installemacsen -dh_installifupdown -dh_installinfo -dh_installinit -dh_installmenu -dh_installmime -dh_installmodules -dh_installlogcheck -dh_installlogrotate -dh_installpam -dh_installppp -dh_installudev -dh_installgsettings -dh_bugfiles -dh_ucf -dh_lintian -dh_gconf -dh_icons -dh_perl -dh_usrlocal -dh_link -dh_installwm -dh_installxfonts -dh_strip_nondeterminism -dh_compress -dh_fixperms -dh_missing -dh_strip -dh_makeshlibs -dh_shlibdeps -dh_installdeb -dh_gencontrol -dh_md5sums diff --git a/debian/matrix-synapse.service b/debian/matrix-synapse.service index ab94e073a610..2e9cd83b5fc3 100644 --- a/debian/matrix-synapse.service +++ b/debian/matrix-synapse.service @@ -6,8 +6,8 @@ Type=simple User=matrix-synapse WorkingDirectory=/var/lib/matrix-synapse EnvironmentFile=/etc/default/matrix-synapse -ExecStartPre=/usr/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --generate-keys -ExecStart=/usr/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ +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/ Restart=always RestartSec=3 diff --git a/debian/rules b/debian/rules index 7bc4f4578da7..b44f6154eea1 100755 --- a/debian/rules +++ b/debian/rules @@ -17,7 +17,7 @@ export DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs SNAKE=/usr/bin/python3 DEB_BUILD_OPTIONS=noddebs EXTRA_REQUIREMENTS=--preinstall "setuptools>=17.1" --preinstall "pip>=7" --preinstall "wheel" --preinstall "no-manylinux1" --preinstall "lxml" -DH_VENV_ARGS=--with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) #-v +DH_VENV_ARGS=--with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) --extra-pip-arg="--no-cache-dir" --extra-pip-arg="--no-binary=lxml" PACKAGE=$(shell dh_listpackages) VERSION=$(shell $(SNAKE) setup.py --version) SDIST_DIR=debian/$(PACKAGE)-$(VERSION) @@ -34,7 +34,6 @@ build-arch: tar -x -C $(SDIST_DIR) --strip-components=1 --exclude '*.egg-info' -f dist/*.tar dh $@ $(DH_VENV_ARGS) --sourcedir $(SDIST_DIR) - override_dh_gencontrol: dh_gencontrol -- -v$(RELEASE_VERSION) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index b16e1cbb2258..715a0a031335 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -1,17 +1,9 @@ -# Build dh-virtualenv's Debian package within a container for any platform -# -# docker build --tag dh-venv-builder --build-arg distro=debian:9 . -# docker build --tag dh-venv-builder --build-arg distro=ubuntu:bionic . -# -# mkdir -p dist && docker run --rm dh-venv-builder tar -C /dpkg -c . | tar -C dist -xv - ARG distro="debian:stable" FROM ${distro} AS dpkg-build RUN apt-get update -qq -o Acquire::Languages=none \ && env DEBIAN_FRONTEND=noninteractive apt-get install \ -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ - build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev libxslt1-dev python3-setuptools libssl-dev lsb-release\ - && apt-get clean && rm -rf "/var/lib/apt/lists"/* + build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev zlib1g-dev libxslt1-dev python3-setuptools libssl-dev lsb-release WORKDIR /build -ENTRYPOINT ['/build/build_debian.sh'] +ENTRYPOINT ["bash","/build/build_debian.sh"] diff --git a/docker/build_debian_packages.sh b/docker/build_debian_packages.sh new file mode 100644 index 000000000000..0150a5021b7f --- /dev/null +++ b/docker/build_debian_packages.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +mkdir -p ../debs + +docker build --tag dh-venv-builder:bionic --build-arg distro=ubuntu:bionic -f Dockerfile-dhvirtualenv . +docker build --tag dh-venv-builder:stretch --build-arg distro=debian:stretch -f Dockerfile-dhvirtualenv . + +docker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:bionic +docker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:stretch \ No newline at end of file From 1a45157738a4a507bd606f758d47d89facfba3f0 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Mon, 19 Nov 2018 16:51:17 -0600 Subject: [PATCH 05/17] dockerignore --- .dockerignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.dockerignore b/.dockerignore index 0180602e56fc..fe70a20177a7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,5 @@ demo/etc tox.ini .git/* .tox/* +debian/matrix-synapse/ +debian/matrix-synapse-*/ \ No newline at end of file From f18911718f89488c91015d07944b25cd725bec50 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 20 Nov 2018 15:18:47 -0600 Subject: [PATCH 06/17] more --- debian/.gitignore | 4 ++-- docker/build_debian_packages.sh | 0 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 docker/build_debian_packages.sh diff --git a/debian/.gitignore b/debian/.gitignore index 552b45f8c27b..6b4389a7ab6d 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1,9 +1,9 @@ matrix-synapse.*.debhelper -matrix-synapse.*.debhelper.log +matrix-synapse.debhelper.log matrix-synapse.substvars matrix-synapse/ matrix-synapse-*/ files debhelper-build-stamp source/ -.debhelper \ No newline at end of file +.debhelper diff --git a/docker/build_debian_packages.sh b/docker/build_debian_packages.sh old mode 100644 new mode 100755 From ff5877e386a7db7d20aa793a26552c24a8364ed7 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 27 Nov 2018 18:57:21 +1100 Subject: [PATCH 07/17] changelog --- changelog.d/4212.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4212.misc diff --git a/changelog.d/4212.misc b/changelog.d/4212.misc new file mode 100644 index 000000000000..42f2546cf959 --- /dev/null +++ b/changelog.d/4212.misc @@ -0,0 +1 @@ +Debian packages utilising a virtualenv with bundled dependencies can now be built. From 695d50dd922c389a677466008fe2a9d91f0574aa Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 27 Nov 2018 19:09:32 +1100 Subject: [PATCH 08/17] add --- .gitignore | 3 +- debian/homeserver.yaml | 621 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 623 insertions(+), 1 deletion(-) create mode 100644 debian/homeserver.yaml diff --git a/.gitignore b/.gitignore index 4923451df3ad..8551e39c01b6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ homeserver*.log homeserver*.log.* homeserver*.pid homeserver*.yaml +!debian/homeserver.yaml *.signing.key *.tls.crt @@ -59,4 +60,4 @@ env/ .ropeproject/ debs/ -*.deb \ No newline at end of file +*.deb diff --git a/debian/homeserver.yaml b/debian/homeserver.yaml new file mode 100644 index 000000000000..04ece25d4980 --- /dev/null +++ b/debian/homeserver.yaml @@ -0,0 +1,621 @@ +# vim:ft=yaml +# PEM encoded X509 certificate for TLS. +# You can replace the self-signed certificate that synapse +# autogenerates on launch with your own SSL certificate + key pair +# if you like. Any required intermediary certificates can be +# appended after the primary certificate in hierarchical order. +tls_certificate_path: "/etc/matrix-synapse/homeserver.tls.crt" + +# PEM encoded private key for TLS +tls_private_key_path: "/etc/matrix-synapse/homeserver.tls.key" + +# PEM dh parameters for ephemeral keys +tls_dh_params_path: "/etc/matrix-synapse/homeserver.tls.dh" + +# Don't bind to the https port +no_tls: False + +# List of allowed TLS fingerprints for this server to publish along +# with the signing keys for this server. Other matrix servers that +# make HTTPS requests to this server will check that the TLS +# certificates returned by this server match one of the fingerprints. +# +# Synapse automatically adds the fingerprint of its own certificate +# to the list. So if federation traffic is handled directly by synapse +# then no modification to the list is required. +# +# If synapse is run behind a load balancer that handles the TLS then it +# will be necessary to add the fingerprints of the certificates used by +# the loadbalancers to this list if they are different to the one +# synapse is using. +# +# Homeservers are permitted to cache the list of TLS fingerprints +# returned in the key responses up to the "valid_until_ts" returned in +# key. It may be necessary to publish the fingerprints of a new +# certificate and wait until the "valid_until_ts" of the previous key +# responses have passed before deploying it. +# +# You can calculate a fingerprint from a given TLS listener via: +# openssl s_client -connect $host:$port < /dev/null 2> /dev/null | +# openssl x509 -outform DER | openssl sha256 -binary | base64 | tr -d '=' +# or by checking matrix.org/federationtester/api/report?server_name=$host +# +tls_fingerprints: [] +# tls_fingerprints: [{"sha256": ""}] + + +## Server ## + +# When running as a daemon, the file to store the pid in +pid_file: "/var/run/matrix-synapse.pid" + +# CPU affinity mask. Setting this restricts the CPUs on which the +# process will be scheduled. It is represented as a bitmask, with the +# lowest order bit corresponding to the first logical CPU and the +# highest order bit corresponding to the last logical CPU. Not all CPUs +# may exist on a given system but a mask may specify more CPUs than are +# present. +# +# For example: +# 0x00000001 is processor #0, +# 0x00000003 is processors #0 and #1, +# 0xFFFFFFFF is all processors (#0 through #31). +# +# Pinning a Python process to a single CPU is desirable, because Python +# is inherently single-threaded due to the GIL, and can suffer a +# 30-40% slowdown due to cache blow-out and thread context switching +# if the scheduler happens to schedule the underlying threads across +# different cores. See +# https://www.mirantis.com/blog/improve-performance-python-programs-restricting-single-cpu/. +# +# cpu_affinity: 0xFFFFFFFF + +# Whether to serve a web client from the HTTP/HTTPS root resource. +web_client: False + +# The root directory to server for the above web client. +# If left undefined, synapse will serve the matrix-angular-sdk web client. +# Make sure matrix-angular-sdk is installed with pip if web_client is True +# and web_client_location is undefined +# web_client_location: "/path/to/web/root" + +# The public-facing base URL for the client API (not including _matrix/...) +# public_baseurl: https://example.com:8448/ + +# Set the soft limit on the number of file descriptors synapse can use +# Zero is used to indicate synapse should set the soft limit to the +# hard limit. +soft_file_limit: 0 + +# The GC threshold parameters to pass to `gc.set_threshold`, if defined +# gc_thresholds: [700, 10, 10] + +# Set the limit on the returned events in the timeline in the get +# and sync operations. The default value is -1, means no upper limit. +# filter_timeline_limit: 5000 + +# Whether room invites to users on this server should be blocked +# (except those sent by local server admins). The default is False. +# block_non_admin_invites: True + +# Restrict federation to the following whitelist of domains. +# N.B. we recommend also firewalling your federation listener to limit +# inbound federation traffic as early as possible, rather than relying +# purely on this application-layer restriction. If not specified, the +# default is to whitelist everything. +# +# federation_domain_whitelist: +# - lon.example.com +# - nyc.example.com +# - syd.example.com + +# List of ports that Synapse should listen on, their purpose and their +# configuration. +listeners: + # Main HTTPS listener + # For when matrix traffic is sent directly to synapse. + - + # The port to listen for HTTPS requests on. + port: 8448 + + # Local addresses to listen on. + # On Linux and Mac OS, `::` will listen on all IPv4 and IPv6 + # addresses by default. For most other OSes, this will only listen + # on IPv6. + bind_addresses: + - '::' + - '0.0.0.0' + + # This is a 'http' listener, allows us to specify 'resources'. + type: http + + tls: true + + # Use the X-Forwarded-For (XFF) header as the client IP and not the + # actual client IP. + x_forwarded: false + + # List of HTTP resources to serve on this listener. + resources: + - + # List of resources to host on this listener. + names: + - client # The client-server APIs, both v1 and v2 + - webclient # The bundled webclient. + + # Should synapse compress HTTP responses to clients that support it? + # This should be disabled if running synapse behind a load balancer + # that can do automatic compression. + compress: true + + - names: [federation] # Federation APIs + compress: false + + # optional list of additional endpoints which can be loaded via + # dynamic modules + # additional_resources: + # "/_matrix/my/custom/endpoint": + # module: my_module.CustomRequestHandler + # config: {} + + # Unsecure HTTP listener, + # For when matrix traffic passes through loadbalancer that unwraps TLS. + - port: 8008 + tls: false + bind_addresses: ['::', '0.0.0.0'] + type: http + + x_forwarded: false + + resources: + - names: [client, webclient] + compress: true + - names: [federation] + compress: false + + # Turn on the twisted ssh manhole service on localhost on the given + # port. + # - port: 9000 + # bind_addresses: ['::1', '127.0.0.1'] + # type: manhole + + +# Database configuration +database: + # The database engine name + name: "sqlite3" + # Arguments to pass to the engine + args: + # Path to the database + database: "/var/lib/matrix-synapse/homeserver.db" + +# Number of events to cache in memory. +event_cache_size: "10K" + + +# A yaml python logging config file +log_config: "/etc/matrix-synapse/log.yaml" + + + +## Ratelimiting ## + +# Number of messages a client can send per second +rc_messages_per_second: 0.2 + +# Number of message a client can send before being throttled +rc_message_burst_count: 10.0 + +# The federation window size in milliseconds +federation_rc_window_size: 1000 + +# The number of federation requests from a single server in a window +# before the server will delay processing the request. +federation_rc_sleep_limit: 10 + +# The duration in milliseconds to delay processing events from +# remote servers by if they go over the sleep limit. +federation_rc_sleep_delay: 500 + +# The maximum number of concurrent federation requests allowed +# from a single server +federation_rc_reject_limit: 50 + +# The number of federation requests to concurrently process from a +# single server +federation_rc_concurrent: 3 + + + +# Directory where uploaded images and attachments are stored. +media_store_path: "/var/lib/matrix-synapse/media" + +# Media storage providers allow media to be stored in different +# locations. +# media_storage_providers: +# - module: file_system +# # Whether to write new local files. +# store_local: false +# # Whether to write new remote media +# store_remote: false +# # Whether to block upload requests waiting for write to this +# # provider to complete +# store_synchronous: false +# config: +# directory: /mnt/some/other/directory + +# Directory where in-progress uploads are stored. +uploads_path: "/var/lib/matrix-synapse/uploads" + +# The largest allowed upload size in bytes +max_upload_size: "10M" + +# Maximum number of pixels that will be thumbnailed +max_image_pixels: "32M" + +# Whether to generate new thumbnails on the fly to precisely match +# the resolution requested by the client. If true then whenever +# a new resolution is requested by the client the server will +# generate a new thumbnail. If false the server will pick a thumbnail +# from a precalculated list. +dynamic_thumbnails: false + +# List of thumbnail to precalculate when an image is uploaded. +thumbnail_sizes: +- width: 32 + height: 32 + method: crop +- width: 96 + height: 96 + method: crop +- width: 320 + height: 240 + method: scale +- width: 640 + height: 480 + method: scale +- width: 800 + height: 600 + method: scale + +# Is the preview URL API enabled? If enabled, you *must* specify +# an explicit url_preview_ip_range_blacklist of IPs that the spider is +# denied from accessing. +url_preview_enabled: False + +# List of IP address CIDR ranges that the URL preview spider is denied +# from accessing. There are no defaults: you must explicitly +# specify a list for URL previewing to work. You should specify any +# internal services in your network that you do not want synapse to try +# to connect to, otherwise anyone in any Matrix room could cause your +# synapse to issue arbitrary GET requests to your internal services, +# causing serious security issues. +# +# url_preview_ip_range_blacklist: +# - '127.0.0.0/8' +# - '10.0.0.0/8' +# - '172.16.0.0/12' +# - '192.168.0.0/16' +# - '100.64.0.0/10' +# - '169.254.0.0/16' +# +# List of IP address CIDR ranges that the URL preview spider is allowed +# to access even if they are specified in url_preview_ip_range_blacklist. +# This is useful for specifying exceptions to wide-ranging blacklisted +# target IP ranges - e.g. for enabling URL previews for a specific private +# website only visible in your network. +# +# url_preview_ip_range_whitelist: +# - '192.168.1.1' + +# Optional list of URL matches that the URL preview spider is +# denied from accessing. You should use url_preview_ip_range_blacklist +# in preference to this, otherwise someone could define a public DNS +# entry that points to a private IP address and circumvent the blacklist. +# This is more useful if you know there is an entire shape of URL that +# you know that will never want synapse to try to spider. +# +# Each list entry is a dictionary of url component attributes as returned +# by urlparse.urlsplit as applied to the absolute form of the URL. See +# https://docs.python.org/2/library/urlparse.html#urlparse.urlsplit +# The values of the dictionary are treated as an filename match pattern +# applied to that component of URLs, unless they start with a ^ in which +# case they are treated as a regular expression match. If all the +# specified component matches for a given list item succeed, the URL is +# blacklisted. +# +# url_preview_url_blacklist: +# # blacklist any URL with a username in its URI +# - username: '*' +# +# # blacklist all *.google.com URLs +# - netloc: 'google.com' +# - netloc: '*.google.com' +# +# # blacklist all plain HTTP URLs +# - scheme: 'http' +# +# # blacklist http(s)://www.acme.com/foo +# - netloc: 'www.acme.com' +# path: '/foo' +# +# # blacklist any URL with a literal IPv4 address +# - netloc: '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' + +# The largest allowed URL preview spidering size in bytes +max_spider_size: "10M" + + + + +## Captcha ## +# See docs/CAPTCHA_SETUP for full details of configuring this. + +# This Home Server's ReCAPTCHA public key. +recaptcha_public_key: "YOUR_PUBLIC_KEY" + +# This Home Server's ReCAPTCHA private key. +recaptcha_private_key: "YOUR_PRIVATE_KEY" + +# Enables ReCaptcha checks when registering, preventing signup +# unless a captcha is answered. Requires a valid ReCaptcha +# public/private key. +enable_registration_captcha: False + +# A secret key used to bypass the captcha test entirely. +#captcha_bypass_secret: "YOUR_SECRET_HERE" + +# The API endpoint to use for verifying m.login.recaptcha responses. +recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify" + + +## Turn ## + +# The public URIs of the TURN server to give to clients +turn_uris: [] + +# The shared secret used to compute passwords for the TURN server +turn_shared_secret: "YOUR_SHARED_SECRET" + +# The Username and password if the TURN server needs them and +# does not use a token +#turn_username: "TURNSERVER_USERNAME" +#turn_password: "TURNSERVER_PASSWORD" + +# How long generated TURN credentials last +turn_user_lifetime: "1h" + +# Whether guests should be allowed to use the TURN server. +# This defaults to True, otherwise VoIP will be unreliable for guests. +# However, it does introduce a slight security risk as it allows users to +# connect to arbitrary endpoints without having first signed up for a +# valid account (e.g. by passing a CAPTCHA). +turn_allow_guests: False + + +## Registration ## + +# Enable registration for new users. +enable_registration: False + +# The user must provide all of the below types of 3PID when registering. +# +# registrations_require_3pid: +# - email +# - msisdn + +# Mandate that users are only allowed to associate certain formats of +# 3PIDs with accounts on this server. +# +# allowed_local_3pids: +# - medium: email +# pattern: ".*@matrix\.org" +# - medium: email +# pattern: ".*@vector\.im" +# - medium: msisdn +# pattern: "\+44" + +# If set, allows registration by anyone who also has the shared +# secret, even if registration is otherwise disabled. +# registration_shared_secret: + +# Set the number of bcrypt rounds used to generate password hash. +# Larger numbers increase the work factor needed to generate the hash. +# The default number is 12 (which equates to 2^12 rounds). +# N.B. that increasing this will exponentially increase the time required +# to register or login - e.g. 24 => 2^24 rounds which will take >20 mins. +bcrypt_rounds: 12 + +# Allows users to register as guests without a password/email/etc, and +# participate in rooms hosted on this server which have been made +# accessible to anonymous users. +allow_guest_access: False + +# The list of identity servers trusted to verify third party +# identifiers by this server. +trusted_third_party_id_servers: + - matrix.org + - vector.im + - riot.im + +# Users who register on this homeserver will automatically be joined +# to these rooms +#auto_join_rooms: +# - "#example:example.com" + + +## Metrics ### + +# Enable collection and rendering of performance metrics +enable_metrics: False + +## API Configuration ## + +# A list of event types that will be included in the room_invite_state +room_invite_state_types: + - "m.room.join_rules" + - "m.room.canonical_alias" + - "m.room.avatar" + - "m.room.name" + + +# A list of application service config file to use +app_service_config_files: [] + + +# macaroon_secret_key: + +# Used to enable access token expiration. +expire_access_token: False + +## Signing Keys ## + +# Path to the signing key to sign messages with +signing_key_path: "/etc/matrix-synapse/homeserver.signing.key" + +# The keys that the server used to sign messages with but won't use +# to sign new messages. E.g. it has lost its private key +old_signing_keys: {} +# "ed25519:auto": +# # Base64 encoded public key +# key: "The public part of your old signing key." +# # Millisecond POSIX timestamp when the key expired. +# expired_ts: 123456789123 + +# How long key response published by this server is valid for. +# Used to set the valid_until_ts in /key/v2 APIs. +# Determines how quickly servers will query to check which keys +# are still valid. +key_refresh_interval: "1d" # 1 Day. + +# The trusted servers to download signing keys from. +perspectives: + servers: + "matrix.org": + verify_keys: + "ed25519:auto": + key: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw" + + + +# Enable SAML2 for registration and login. Uses pysaml2 +# config_path: Path to the sp_conf.py configuration file +# idp_redirect_url: Identity provider URL which will redirect +# the user back to /login/saml2 with proper info. +# See pysaml2 docs for format of config. +#saml2_config: +# enabled: true +# config_path: "/home/erikj/git/synapse/sp_conf.py" +# idp_redirect_url: "http://test/idp" + + + +# Enable CAS for registration and login. +#cas_config: +# enabled: true +# server_url: "https://cas-server.com" +# service_url: "https://homeserver.domain.com:8448" +# #required_attributes: +# # name: value + + +# The JWT needs to contain a globally unique "sub" (subject) claim. +# +# jwt_config: +# enabled: true +# secret: "a secret" +# algorithm: "HS256" + + + +# Enable password for login. +password_config: + enabled: true + # Uncomment and change to a secret random string for extra security. + # DO NOT CHANGE THIS AFTER INITIAL SETUP! + #pepper: "" + + + +# Enable sending emails for notification events +# Defining a custom URL for Riot is only needed if email notifications +# should contain links to a self-hosted installation of Riot; when set +# the "app_name" setting is ignored. +# +# If your SMTP server requires authentication, the optional smtp_user & +# smtp_pass variables should be used +# +#email: +# enable_notifs: false +# smtp_host: "localhost" +# smtp_port: 25 +# smtp_user: "exampleusername" +# smtp_pass: "examplepassword" +# require_transport_security: False +# notif_from: "Your Friendly %(app)s Home Server " +# app_name: Matrix +# template_dir: res/templates +# notif_template_html: notif_mail.html +# notif_template_text: notif_mail.txt +# notif_for_new_users: True +# riot_base_url: "http://localhost/riot" + + +# password_providers: +# - module: "ldap_auth_provider.LdapAuthProvider" +# config: +# enabled: true +# uri: "ldap://ldap.example.com:389" +# start_tls: true +# base: "ou=users,dc=example,dc=com" +# attributes: +# uid: "cn" +# mail: "email" +# name: "givenName" +# #bind_dn: +# #bind_password: +# #filter: "(objectClass=posixAccount)" + + + +# Clients requesting push notifications can either have the body of +# the message sent in the notification poke along with other details +# like the sender, or just the event ID and room ID (`event_id_only`). +# If clients choose the former, this option controls whether the +# notification request includes the content of the event (other details +# like the sender are still included). For `event_id_only` push, it +# has no effect. + +# For modern android devices the notification content will still appear +# because it is loaded by the app. iPhone, however will send a +# notification saying only that a message arrived and who it came from. +# +#push: +# include_content: true + + +# spam_checker: +# module: "my_custom_project.SuperSpamChecker" +# config: +# example_option: 'things' + + +# Whether to allow non server admins to create groups on this server +enable_group_creation: false + +# If enabled, non server admins can only create groups with local parts +# starting with this prefix +# group_creation_prefix: "unofficial/" + + + +# User Directory configuration +# +# 'search_all_users' defines whether to search all users visible to your HS +# when searching the user directory, rather than limiting to users visible +# in public rooms. Defaults to false. If you set it True, you'll have to run +# UPDATE user_directory_stream_pos SET stream_id = NULL; +# on your database to tell it to rebuild the user_directory search indexes. +# +#user_directory: +# search_all_users: false From 1c01e04e48f0c2b42ec73d8e804922a93a77d716 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 27 Nov 2018 19:46:08 +1100 Subject: [PATCH 09/17] some cleanups --- debian/control | 4 ++-- debian/cookiecutter.json | 13 ------------- debian/matrix-synapse.links | 5 ++++- debian/rules | 1 + docker/build_debian_packages.sh | 4 ++-- 5 files changed, 9 insertions(+), 18 deletions(-) delete mode 100644 debian/cookiecutter.json diff --git a/debian/control b/debian/control index 95ebad4102fd..9fd5ceeb3a68 100644 --- a/debian/control +++ b/debian/control @@ -8,8 +8,8 @@ Homepage: https://github.com/matrix-org/synapse Package: matrix-synapse Architecture: any -Pre-Depends: dpkg (>= 1.16.1), python3, ${misc:Pre-Depends} -Depends: ${python:Depends}, ${misc:Depends}, adduser, sqlite3, libpq5, libffi6, libjpeg-turbo8, libxslt1.1, openssl +Pre-Depends: dpkg (>= 1.16.1) +Depends: python3, python3-distutils, adduser, sqlite3, libpq5, libffi6, libjpeg-turbo8, libxslt1.1, openssl Description: A Python package and its dependencies packaged up as DEB in an isolated virtualenv. . This is a distribution of "matrix-synapse" as a self-contained diff --git a/debian/cookiecutter.json b/debian/cookiecutter.json deleted file mode 100644 index 0b38cbc6a527..000000000000 --- a/debian/cookiecutter.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "_template": "https://github.com/Springerle/dh-virtualenv-mold.git", - "distro": "bionic", - "email": "synapse@matrix.org", - "full_name": "Synapse Developers", - "package": "matrix-synapse", - "repo_name": "debian", - "short_description": "A Python package and its dependencies packaged up as DEB in an isolated virtualenv.", - "snake": "/usr/bin/python3", - "url": "https://github.com/matrix-org/synapse", - "version": "0.33.8", - "year": "2018" -} diff --git a/debian/matrix-synapse.links b/debian/matrix-synapse.links index 0884e067239f..90d9821d2874 100644 --- a/debian/matrix-synapse.links +++ b/debian/matrix-synapse.links @@ -1 +1,4 @@ -# opt/venvs/matrix-synapse/bin/matrix-synapse usr/bin/matrix-synapse +opt/venvs/matrix-synapse/bin/hash_password usr/bin/hash_password +opt/venvs/matrix-synapse/bin/register_new_matrix_user usr/bin/register_new_matrix_user +opt/venvs/matrix-synapse/bin/synapse_port_db usr/bin/synapse_port_db +opt/venvs/matrix-synapse/bin/synctl usr/bin/synctl \ No newline at end of file diff --git a/debian/rules b/debian/rules index b44f6154eea1..faa701906390 100755 --- a/debian/rules +++ b/debian/rules @@ -14,6 +14,7 @@ #DH_VERBOSE=1 export DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs +export CFLAGS=-march=x86-64 SNAKE=/usr/bin/python3 DEB_BUILD_OPTIONS=noddebs EXTRA_REQUIREMENTS=--preinstall "setuptools>=17.1" --preinstall "pip>=7" --preinstall "wheel" --preinstall "no-manylinux1" --preinstall "lxml" diff --git a/docker/build_debian_packages.sh b/docker/build_debian_packages.sh index 0150a5021b7f..f9228ec8c15c 100755 --- a/docker/build_debian_packages.sh +++ b/docker/build_debian_packages.sh @@ -3,7 +3,7 @@ mkdir -p ../debs docker build --tag dh-venv-builder:bionic --build-arg distro=ubuntu:bionic -f Dockerfile-dhvirtualenv . -docker build --tag dh-venv-builder:stretch --build-arg distro=debian:stretch -f Dockerfile-dhvirtualenv . +#docker build --tag dh-venv-builder:stretch --build-arg distro=debian:stretch -f Dockerfile-dhvirtualenv . docker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:bionic -docker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:stretch \ No newline at end of file +#ocker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:stretch \ No newline at end of file From 6dde62326f28c121506dee42f064db5a5f9d8ee8 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 27 Nov 2018 19:48:31 +1100 Subject: [PATCH 10/17] some cleanups --- debian/changelog | 2 +- docker/build_debian_packages.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7c85eba4fd7d..f49977e6d21a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,4 +2,4 @@ matrix-synapse (0.33.9) bionic; urgency=low * matrix-synapse: Initial debian packaging - -- Synapse Developers Day, 01 Jan 2014 12:34:56 +0000 + -- Synapse Developers Tue, 27 Nov 2018 12:34:56 +0000 diff --git a/docker/build_debian_packages.sh b/docker/build_debian_packages.sh index f9228ec8c15c..58e08b47a356 100755 --- a/docker/build_debian_packages.sh +++ b/docker/build_debian_packages.sh @@ -5,5 +5,5 @@ mkdir -p ../debs docker build --tag dh-venv-builder:bionic --build-arg distro=ubuntu:bionic -f Dockerfile-dhvirtualenv . #docker build --tag dh-venv-builder:stretch --build-arg distro=debian:stretch -f Dockerfile-dhvirtualenv . -docker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:bionic +docker run -it --rm --volume=$(pwd)/../\:/build -u $(id -u):$(id -g) dh-venv-builder:bionic #ocker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:stretch \ No newline at end of file From bc8c2853785a5e3b0333994f48efc148d6e31ed7 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 27 Nov 2018 19:58:23 +1100 Subject: [PATCH 11/17] some cleanups --- build_debian.sh | 6 ------ debian/rules | 3 +++ docker/Dockerfile-dhvirtualenv | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) delete mode 100755 build_debian.sh diff --git a/build_debian.sh b/build_debian.sh deleted file mode 100755 index cd5a438aa75f..000000000000 --- a/build_debian.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -e - -dpkg-buildpackage -us -uc -b -cp ../*.deb /build/debs \ No newline at end of file diff --git a/debian/rules b/debian/rules index faa701906390..c72a32f386eb 100755 --- a/debian/rules +++ b/debian/rules @@ -38,5 +38,8 @@ build-arch: override_dh_gencontrol: dh_gencontrol -- -v$(RELEASE_VERSION) +override_dh_builddeb: + dh_builddeb --destdir=/debs + %: dh $@ $(DH_VENV_ARGS) --sourcedir $(SDIST_DIR) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index 715a0a031335..ad14a51a1ee7 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -5,5 +5,5 @@ RUN apt-get update -qq -o Acquire::Languages=none \ -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev zlib1g-dev libxslt1-dev python3-setuptools libssl-dev lsb-release WORKDIR /build -ENTRYPOINT ["bash","/build/build_debian.sh"] +ENTRYPOINT ["dpkg-buildpackage", "-us", "-uc", "-b"] From 2ce563121f52c7fb724906eb120769a0cc931db4 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Tue, 27 Nov 2018 23:22:09 +1100 Subject: [PATCH 12/17] cleanup --- debian/changelog | 6 +++--- debian/rules | 4 ++-- docker/Dockerfile-dhvirtualenv | 4 ++-- docker/build_debian_packages.sh | 6 ++++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index f49977e6d21a..15fa02b18970 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -matrix-synapse (0.33.9) bionic; urgency=low +matrix-synapse (0.33.9) stretch; urgency=medium - * matrix-synapse: Initial debian packaging + * New upstream version 0.33.9 - -- Synapse Developers Tue, 27 Nov 2018 12:34:56 +0000 + -- Amber Tue, 27 Nov 2018 14:33:26 +0000 \ No newline at end of file diff --git a/debian/rules b/debian/rules index c72a32f386eb..cf6a60b41025 100755 --- a/debian/rules +++ b/debian/rules @@ -18,7 +18,7 @@ export CFLAGS=-march=x86-64 SNAKE=/usr/bin/python3 DEB_BUILD_OPTIONS=noddebs EXTRA_REQUIREMENTS=--preinstall "setuptools>=17.1" --preinstall "pip>=7" --preinstall "wheel" --preinstall "no-manylinux1" --preinstall "lxml" -DH_VENV_ARGS=--with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) --extra-pip-arg="--no-cache-dir" --extra-pip-arg="--no-binary=lxml" +DH_VENV_ARGS=--with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) --extra-pip-arg="--no-cache-dir" --extra-pip-arg="--compile" --extra-pip-arg="--no-binary=lxml" PACKAGE=$(shell dh_listpackages) VERSION=$(shell $(SNAKE) setup.py --version) SDIST_DIR=debian/$(PACKAGE)-$(VERSION) @@ -39,7 +39,7 @@ override_dh_gencontrol: dh_gencontrol -- -v$(RELEASE_VERSION) override_dh_builddeb: - dh_builddeb --destdir=/debs + dh_builddeb -- -z9 %: dh $@ $(DH_VENV_ARGS) --sourcedir $(SDIST_DIR) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index ad14a51a1ee7..6a07ed3ae4cb 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -4,6 +4,6 @@ RUN apt-get update -qq -o Acquire::Languages=none \ && env DEBIAN_FRONTEND=noninteractive apt-get install \ -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev zlib1g-dev libxslt1-dev python3-setuptools libssl-dev lsb-release -WORKDIR /build -ENTRYPOINT ["dpkg-buildpackage", "-us", "-uc", "-b"] +WORKDIR /synapse/build +ENTRYPOINT ["bash","/synapse/build/debian/build_debian.sh"] diff --git a/docker/build_debian_packages.sh b/docker/build_debian_packages.sh index 58e08b47a356..bf091fd8e3af 100755 --- a/docker/build_debian_packages.sh +++ b/docker/build_debian_packages.sh @@ -5,5 +5,7 @@ mkdir -p ../debs docker build --tag dh-venv-builder:bionic --build-arg distro=ubuntu:bionic -f Dockerfile-dhvirtualenv . #docker build --tag dh-venv-builder:stretch --build-arg distro=debian:stretch -f Dockerfile-dhvirtualenv . -docker run -it --rm --volume=$(pwd)/../\:/build -u $(id -u):$(id -g) dh-venv-builder:bionic -#ocker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:stretch \ No newline at end of file +docker run -it --rm --volume=$(pwd)/../\:/synapse/build dh-venv-builder:bionic +#ocker run -it --rm --volume=$(pwd)/../\:/build dh-venv-builder:stretch + +sudo chown $(id -u):$(id -g) -R ../debs/ \ No newline at end of file From 92628f718cb831b2d75db662fb5c07f60633da0d Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Thu, 6 Dec 2018 20:59:11 +1100 Subject: [PATCH 13/17] gitignore fixes --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8551e39c01b6..39b2a6f09d14 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,7 @@ homeserver*.db homeserver*.log homeserver*.log.* homeserver*.pid -homeserver*.yaml -!debian/homeserver.yaml +/homeserver*.yaml *.signing.key *.tls.crt @@ -59,5 +58,4 @@ env/ .vscode/ .ropeproject/ -debs/ *.deb From f88c17694f6836c5cb957cbc457b7e0b9edc010e Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Thu, 6 Dec 2018 21:09:02 +1100 Subject: [PATCH 14/17] cleanup --- debian/.gitignore | 18 ++++----- debian/build_debian.sh | 7 ++++ debian/changelog | 2 +- debian/config | 4 +- debian/control | 39 +++++++++++++------ ...pse.default => matrix-synapse-py3.default} | 0 ...synapse.links => matrix-synapse-py3.links} | 0 ...e.postinst => matrix-synapse-py3.postinst} | 0 ...pse.service => matrix-synapse-py3.service} | 0 ...e.triggers => matrix-synapse-py3.triggers} | 0 debian/templates | 4 +- 11 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 debian/build_debian.sh rename debian/{matrix-synapse.default => matrix-synapse-py3.default} (100%) rename debian/{matrix-synapse.links => matrix-synapse-py3.links} (100%) rename debian/{matrix-synapse.postinst => matrix-synapse-py3.postinst} (100%) rename debian/{matrix-synapse.service => matrix-synapse-py3.service} (100%) rename debian/{matrix-synapse.triggers => matrix-synapse-py3.triggers} (100%) diff --git a/debian/.gitignore b/debian/.gitignore index 6b4389a7ab6d..8724ca6d1722 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1,9 +1,9 @@ -matrix-synapse.*.debhelper -matrix-synapse.debhelper.log -matrix-synapse.substvars -matrix-synapse/ -matrix-synapse-*/ -files -debhelper-build-stamp -source/ -.debhelper +/matrix-synapse.*.debhelper +/matrix-synapse.debhelper.log +/matrix-synapse.substvars +/matrix-synapse/ +/matrix-synapse-*/ +/files +/debhelper-build-stamp +/source/ +/.debhelper diff --git a/debian/build_debian.sh b/debian/build_debian.sh new file mode 100644 index 000000000000..1eda9e5fc954 --- /dev/null +++ b/debian/build_debian.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +dpkg-buildpackage -us -uc -b + +cp ../*.deb /build/debs \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index 15fa02b18970..9733ca02bb18 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -matrix-synapse (0.33.9) stretch; urgency=medium +matrix-synapse-py3 (0.33.9) stretch; urgency=medium * New upstream version 0.33.9 diff --git a/debian/config b/debian/config index 9fb69132987f..009e39c7392e 100755 --- a/debian/config +++ b/debian/config @@ -4,6 +4,6 @@ set -e . /usr/share/debconf/confmodule -db_input high matrix-synapse/server-name || true -db_input high matrix-synapse/report-stats || true +db_input high matrix-synapse-py3/server-name || true +db_input high matrix-synapse-py3/report-stats || true db_go diff --git a/debian/control b/debian/control index 9fd5ceeb3a68..318516de35a7 100644 --- a/debian/control +++ b/debian/control @@ -1,20 +1,35 @@ -Source: matrix-synapse +Source: matrix-synapse-py3 Section: contrib/python Priority: extra Maintainer: Synapse Developers -Build-Depends: debhelper (>= 9), python3, python3-dev, libffi-dev, libssl-dev, libjpeg-dev, libxslt1-dev, dh-virtualenv (>= 0.10), tar, lsb-release +Build-Depends: + debhelper (>= 9), + dh-virtualenv (>= 0.10), + libffi-dev, + libjpeg-dev, + libssl-dev, + libxslt1-dev, + lsb-release, + python3-dev, + python3, + tar, Standards-Version: 3.9.5 Homepage: https://github.com/matrix-org/synapse -Package: matrix-synapse +Package: matrix-synapse-py3 Architecture: any Pre-Depends: dpkg (>= 1.16.1) -Depends: python3, python3-distutils, adduser, sqlite3, libpq5, libffi6, libjpeg-turbo8, libxslt1.1, openssl -Description: A Python package and its dependencies packaged up as DEB in an isolated virtualenv. - . - This is a distribution of "matrix-synapse" as a self-contained - Python virtualenv wrapped into a Debian package ("omnibus" package, - all passengers on board). The packaged virtualenv is kept in sync with - the host's interpreter automatically. - . - See https://github.com/spotify/dh-virtualenv for more details. +Depends: + adduser, + libffi6, + libjpeg-turbo8, + libpq5, + libxslt1.1, + openssl, + python3-distutils, + python3, + sqlite3, +Description: Open federated Instant Messaging and VoIP server + Matrix is an ambitious new ecosystem for open federated Instant + Messaging and VoIP. Synapse is a reference Matrix server + implementation. \ No newline at end of file diff --git a/debian/matrix-synapse.default b/debian/matrix-synapse-py3.default similarity index 100% rename from debian/matrix-synapse.default rename to debian/matrix-synapse-py3.default diff --git a/debian/matrix-synapse.links b/debian/matrix-synapse-py3.links similarity index 100% rename from debian/matrix-synapse.links rename to debian/matrix-synapse-py3.links diff --git a/debian/matrix-synapse.postinst b/debian/matrix-synapse-py3.postinst similarity index 100% rename from debian/matrix-synapse.postinst rename to debian/matrix-synapse-py3.postinst diff --git a/debian/matrix-synapse.service b/debian/matrix-synapse-py3.service similarity index 100% rename from debian/matrix-synapse.service rename to debian/matrix-synapse-py3.service diff --git a/debian/matrix-synapse.triggers b/debian/matrix-synapse-py3.triggers similarity index 100% rename from debian/matrix-synapse.triggers rename to debian/matrix-synapse-py3.triggers diff --git a/debian/templates b/debian/templates index 647358731cd6..3b1fe0ee8272 100644 --- a/debian/templates +++ b/debian/templates @@ -1,11 +1,11 @@ -Template: matrix-synapse/server-name +Template: matrix-synapse-py3/server-name Type: string _Description: Name of the server: The name that this homeserver will appear as, to clients and other servers via federation. This name should match the SRV record published in DNS. -Template: matrix-synapse/report-stats +Template: matrix-synapse-py3/report-stats Type: boolean Default: false _Description: Report anonymous statistics? From 0276da37b66921daf599e1dd7e4463884194908d Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Thu, 6 Dec 2018 22:20:37 +1100 Subject: [PATCH 15/17] cleanup --- debian/.gitignore | 7 +++---- debian/build_debian.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/debian/.gitignore b/debian/.gitignore index 8724ca6d1722..700f50a825d8 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1,7 +1,6 @@ -/matrix-synapse.*.debhelper -/matrix-synapse.debhelper.log -/matrix-synapse.substvars -/matrix-synapse/ +/matrix-synapse-py3.*.debhelper +/matrix-synapse-py3.debhelper.log +/matrix-synapse-py3.substvars /matrix-synapse-*/ /files /debhelper-build-stamp diff --git a/debian/build_debian.sh b/debian/build_debian.sh index 1eda9e5fc954..4c27c48348df 100644 --- a/debian/build_debian.sh +++ b/debian/build_debian.sh @@ -4,4 +4,4 @@ set -e dpkg-buildpackage -us -uc -b -cp ../*.deb /build/debs \ No newline at end of file +cp ../*.deb /synapse/build/debs \ No newline at end of file From 3b1b4ab6831306eed8b8276a96defaa1c181fd16 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sun, 9 Dec 2018 04:40:10 +1100 Subject: [PATCH 16/17] cleanup --- debian/config | 4 ++-- debian/control | 7 ++++++- debian/install | 3 +-- debian/matrix-synapse-py3.service | 1 + debian/rules | 10 ++++++++-- docker/Dockerfile-dhvirtualenv | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/debian/config b/debian/config index 009e39c7392e..9fb69132987f 100755 --- a/debian/config +++ b/debian/config @@ -4,6 +4,6 @@ set -e . /usr/share/debconf/confmodule -db_input high matrix-synapse-py3/server-name || true -db_input high matrix-synapse-py3/report-stats || true +db_input high matrix-synapse/server-name || true +db_input high matrix-synapse/report-stats || true db_go diff --git a/debian/control b/debian/control index 318516de35a7..1ab45c277aa6 100644 --- a/debian/control +++ b/debian/control @@ -5,6 +5,7 @@ Maintainer: Synapse Developers Build-Depends: debhelper (>= 9), dh-virtualenv (>= 0.10), + dh-systemd (>= 1.5), libffi-dev, libjpeg-dev, libssl-dev, @@ -12,12 +13,15 @@ Build-Depends: lsb-release, python3-dev, python3, + python3-setuptools, + python3-pip, tar, Standards-Version: 3.9.5 Homepage: https://github.com/matrix-org/synapse Package: matrix-synapse-py3 -Architecture: any +Architecture: amd64 +Conflicts: matrix-synapse Pre-Depends: dpkg (>= 1.16.1) Depends: adduser, @@ -29,6 +33,7 @@ Depends: python3-distutils, python3, sqlite3, + ${misc:Pre-Depends} Description: Open federated Instant Messaging and VoIP server Matrix is an ambitious new ecosystem for open federated Instant Messaging and VoIP. Synapse is a reference Matrix server diff --git a/debian/install b/debian/install index d4427cf9d1e9..d57ad4551103 100644 --- a/debian/install +++ b/debian/install @@ -1,3 +1,2 @@ ../homeserver.yaml etc/matrix-synapse -../log.yaml etc/matrix-synapse -../*.service lib/systemd/system \ No newline at end of file +../log.yaml etc/matrix-synapse \ No newline at end of file diff --git a/debian/matrix-synapse-py3.service b/debian/matrix-synapse-py3.service index 2e9cd83b5fc3..c21d4c8f55d2 100644 --- a/debian/matrix-synapse-py3.service +++ b/debian/matrix-synapse-py3.service @@ -13,3 +13,4 @@ RestartSec=3 [Install] WantedBy=multi-user.target +Alias=matrix-synapse \ No newline at end of file diff --git a/debian/rules b/debian/rules index cf6a60b41025..46898b3b6e37 100755 --- a/debian/rules +++ b/debian/rules @@ -17,8 +17,8 @@ export DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs export CFLAGS=-march=x86-64 SNAKE=/usr/bin/python3 DEB_BUILD_OPTIONS=noddebs -EXTRA_REQUIREMENTS=--preinstall "setuptools>=17.1" --preinstall "pip>=7" --preinstall "wheel" --preinstall "no-manylinux1" --preinstall "lxml" -DH_VENV_ARGS=--with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) --extra-pip-arg="--no-cache-dir" --extra-pip-arg="--compile" --extra-pip-arg="--no-binary=lxml" +EXTRA_REQUIREMENTS=--preinstall "setuptools>=17.1" --preinstall "pip>=7" --preinstall "wheel" --preinstall "lxml" +DH_VENV_ARGS=--with systemd --install-suffix "matrix-synapse" --with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) --extra-pip-arg="--no-cache-dir" --extra-pip-arg="--compile" PACKAGE=$(shell dh_listpackages) VERSION=$(shell $(SNAKE) setup.py --version) SDIST_DIR=debian/$(PACKAGE)-$(VERSION) @@ -41,5 +41,11 @@ override_dh_gencontrol: override_dh_builddeb: dh_builddeb -- -z9 +override_dh_strip: + echo "No dhstrip" + +override_dh_shlibdeps: + echo "No shlibdeps" + %: dh $@ $(DH_VENV_ARGS) --sourcedir $(SDIST_DIR) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index 6a07ed3ae4cb..d73aa2635224 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -3,7 +3,7 @@ FROM ${distro} AS dpkg-build RUN apt-get update -qq -o Acquire::Languages=none \ && env DEBIAN_FRONTEND=noninteractive apt-get install \ -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ - build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev zlib1g-dev libxslt1-dev python3-setuptools libssl-dev lsb-release + build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev zlib1g-dev libxslt1-dev python3-setuptools python3-pip libssl-dev lsb-release dh-systemd WORKDIR /synapse/build ENTRYPOINT ["bash","/synapse/build/debian/build_debian.sh"] From cc169c2dc7b60ae85e270e727d4400f03fc280d5 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Sun, 9 Dec 2018 05:00:21 +1100 Subject: [PATCH 17/17] cleanup --- debian/control | 1 - debian/install | 3 ++- debian/{matrix-synapse-py3.service => matrix-synapse.service} | 0 debian/rules | 2 +- docker/Dockerfile-dhvirtualenv | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename debian/{matrix-synapse-py3.service => matrix-synapse.service} (100%) diff --git a/debian/control b/debian/control index 1ab45c277aa6..92b44a16a732 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,6 @@ Maintainer: Synapse Developers Build-Depends: debhelper (>= 9), dh-virtualenv (>= 0.10), - dh-systemd (>= 1.5), libffi-dev, libjpeg-dev, libssl-dev, diff --git a/debian/install b/debian/install index d57ad4551103..d9f5ae51d062 100644 --- a/debian/install +++ b/debian/install @@ -1,2 +1,3 @@ ../homeserver.yaml etc/matrix-synapse -../log.yaml etc/matrix-synapse \ No newline at end of file +../log.yaml etc/matrix-synapse +../matrix-synapse.service lib/systemd/system \ No newline at end of file diff --git a/debian/matrix-synapse-py3.service b/debian/matrix-synapse.service similarity index 100% rename from debian/matrix-synapse-py3.service rename to debian/matrix-synapse.service diff --git a/debian/rules b/debian/rules index 46898b3b6e37..9c67b9ff246c 100755 --- a/debian/rules +++ b/debian/rules @@ -18,7 +18,7 @@ export CFLAGS=-march=x86-64 SNAKE=/usr/bin/python3 DEB_BUILD_OPTIONS=noddebs EXTRA_REQUIREMENTS=--preinstall "setuptools>=17.1" --preinstall "pip>=7" --preinstall "wheel" --preinstall "lxml" -DH_VENV_ARGS=--with systemd --install-suffix "matrix-synapse" --with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) --extra-pip-arg="--no-cache-dir" --extra-pip-arg="--compile" +DH_VENV_ARGS=--install-suffix "matrix-synapse" --with python-virtualenv --setuptools --python $(SNAKE) $(EXTRA_REQUIREMENTS) --extra-pip-arg="--no-cache-dir" --extra-pip-arg="--compile" PACKAGE=$(shell dh_listpackages) VERSION=$(shell $(SNAKE) setup.py --version) SDIST_DIR=debian/$(PACKAGE)-$(VERSION) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index d73aa2635224..016689a07e90 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -3,7 +3,7 @@ FROM ${distro} AS dpkg-build RUN apt-get update -qq -o Acquire::Languages=none \ && env DEBIAN_FRONTEND=noninteractive apt-get install \ -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ - build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev zlib1g-dev libxslt1-dev python3-setuptools python3-pip libssl-dev lsb-release dh-systemd + build-essential debhelper devscripts equivs dh-virtualenv libpq-dev sqlite3 python3-dev libffi-dev libjpeg-dev zlib1g-dev libxslt1-dev python3-setuptools python3-pip libssl-dev lsb-release WORKDIR /synapse/build ENTRYPOINT ["bash","/synapse/build/debian/build_debian.sh"]