diff --git a/debian/patches/0001-tox.patch b/debian/patches/0001-tox.patch
new file mode 100644
index 0000000000..2cf3ec0fe8
--- /dev/null
+++ b/debian/patches/0001-tox.patch
@@ -0,0 +1,19 @@
+From: Erik Johnston <erikj@matrix.org>
+Date: Fri, 10 Jun 2016 10:57:07 +0100
+Subject: tox
+
+---
+ tox.ini | 1 +
+ 1 file changed, 1 insertion(+)
+
+Index: package-synapse-debian/tox.ini
+===================================================================
+--- package-synapse-debian.orig/tox.ini
++++ package-synapse-debian/tox.ini
+@@ -1,5 +1,6 @@
+ [tox]
+ envlist = packaging, py27, py36, pep8, check_isort
++sitepackages = True
+
+ [base]
+ deps =
diff --git a/debian/patches/0002-change_instructions.patch b/debian/patches/0002-change_instructions.patch
new file mode 100644
index 0000000000..933de3ab94
--- /dev/null
+++ b/debian/patches/0002-change_instructions.patch
@@ -0,0 +1,34 @@
+From: Erik Johnston <erikj@matrix.org>
+Date: Fri, 10 Jun 2016 10:57:07 +0100
+Subject: change_instructions
+
+---
+ synapse/config/_base.py | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/synapse/config/_base.py
++++ b/synapse/config/_base.py
+@@ -31,6 +31,11 @@
+ MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS = """\
+ Please opt in or out of reporting anonymized homeserver usage statistics, by
+ setting the `report_stats` key in your config file to either True or False.
++
++To set it run:
++
++ dpkg-reconfigure matrix-synapse
++
+ """
+
+ MISSING_REPORT_STATS_SPIEL = """\
+@@ -45,6 +50,11 @@
+
+ MISSING_SERVER_NAME = """\
+ Missing mandatory `server_name` config option.
++
++To set it run:
++
++ dpkg-reconfigure matrix-synapse
++
+ """
+
+
diff --git a/debian/patches/0004-webclient-instructions.patch b/debian/patches/0004-webclient-instructions.patch
new file mode 100644
index 0000000000..e2e61a8446
--- /dev/null
+++ b/debian/patches/0004-webclient-instructions.patch
@@ -0,0 +1,27 @@
+From: Erik Johnston <erikj@matrix.org>
+Date: Fri, 10 Jun 2016 10:57:07 +0100
+Subject: webclient-instructions
+
+---
+ synapse/app/homeserver.py | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+Index: package-synapse-debian/synapse/app/homeserver.py
+===================================================================
+--- package-synapse-debian.orig/synapse/app/homeserver.py
++++ package-synapse-debian/synapse/app/homeserver.py
+@@ -86,12 +86,11 @@ def build_resource_for_web_client(hs):
+ "Please either install the matrix-angular-sdk or configure\n"
+ "the location of the source to serve via the configuration\n"
+ "option `web_client_location`\n\n"
+- "To install the `matrix-angular-sdk` via pip, run:\n\n"
+- " pip install '%(dep)s'\n"
++ "To install the `matrix-angular-sdk` via apt-get, run:\n\n"
++ " apt-get install matrix-synapse-angular-client\n"
+ "\n"
+ "You can also disable hosting of the webclient via the\n"
+ "configuration option `web_client`\n"
+- % {"dep": CONDITIONAL_REQUIREMENTS["web_client"].keys()[0]}
+ )
+ syweb_path = os.path.dirname(syweb.__file__)
+ webclient_path = os.path.join(syweb_path, "webclient")
diff --git a/debian/patches/0006-Don-t-require-strict-nacl-0.3.0-requirement.patch b/debian/patches/0006-Don-t-require-strict-nacl-0.3.0-requirement.patch
new file mode 100644
index 0000000000..8370c96166
--- /dev/null
+++ b/debian/patches/0006-Don-t-require-strict-nacl-0.3.0-requirement.patch
@@ -0,0 +1,21 @@
+From: Erik Johnston <erikj@matrix.org>
+Date: Mon, 20 Jun 2016 13:20:37 +0100
+Subject: Don't require strict nacl==0.3.0 requirement
+
+---
+ synapse/python_dependencies.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: package-synapse-debian/synapse/python_dependencies.py
+===================================================================
+--- package-synapse-debian.orig/synapse/python_dependencies.py
++++ package-synapse-debian/synapse/python_dependencies.py
+@@ -37,7 +37,7 @@ REQUIREMENTS = {
+ "unpaddedbase64>=1.1.0": ["unpaddedbase64>=1.1.0"],
+ "canonicaljson>=1.1.3": ["canonicaljson>=1.1.3"],
+ "signedjson>=1.0.0": ["signedjson>=1.0.0"],
+- "pynacl>=1.2.1": ["nacl>=1.2.1", "nacl.bindings"],
++ "pynacl>=0.3.0": ["nacl>=0.3.0", "nacl.bindings"],
+ "service_identity>=16.0.0": ["service_identity>=16.0.0"],
+ "Twisted>=17.1.0": ["twisted>=17.1.0"],
+ "treq>=15.1": ["treq>=15.1"],
diff --git a/debian/patches/bcrypt.patch b/debian/patches/bcrypt.patch
new file mode 100644
index 0000000000..a962949920
--- /dev/null
+++ b/debian/patches/bcrypt.patch
@@ -0,0 +1,30 @@
+Index: package-synapse-debian/synapse/handlers/auth.py
+===================================================================
+--- package-synapse-debian.orig/synapse/handlers/auth.py
++++ package-synapse-debian/synapse/handlers/auth.py
+@@ -921,10 +921,10 @@ class AuthHandler(BaseHandler):
+ # Normalise the Unicode in the password
+ pw = unicodedata.normalize("NFKC", password)
+
+- return bcrypt.checkpw(
++ return bcrypt.hashpw(
+ pw.encode('utf8') + self.hs.config.password_pepper.encode("utf8"),
+ stored_hash
+- )
++ ) == stored_hash
+
+ if stored_hash:
+ if not isinstance(stored_hash, bytes):
+Index: package-synapse-debian/synapse/python_dependencies.py
+===================================================================
+--- package-synapse-debian.orig/synapse/python_dependencies.py
++++ package-synapse-debian/synapse/python_dependencies.py
+@@ -49,7 +49,7 @@ REQUIREMENTS = {
+ "pyasn1>=0.1.9": ["pyasn1"],
+ "pyasn1-modules>=0.0.7": ["pyasn1_modules"],
+ "daemonize>=2.3.1": ["daemonize"],
+- "bcrypt>=3.1.0": ["bcrypt>=3.1.0"],
++ "bcrypt": ["bcrypt"],
+ "pillow>=3.1.2": ["PIL"],
+ "sortedcontainers>=1.4.4": ["sortedcontainers"],
+ "psutil>=2.0.0": ["psutil>=2.0.0"],
diff --git a/debian/patches/no_install_with_pip b/debian/patches/no_install_with_pip
new file mode 100644
index 0000000000..654656f596
--- /dev/null
+++ b/debian/patches/no_install_with_pip
@@ -0,0 +1,43 @@
+Index: package-synapse-debian/synapse/app/__init__.py
+===================================================================
+--- package-synapse-debian.orig/synapse/app/__init__.py
++++ package-synapse-debian/synapse/app/__init__.py
+@@ -25,8 +25,8 @@ try:
+ except python_dependencies.MissingRequirementError as e:
+ message = "\n".join([
+ "Missing Requirement: %s" % (str(e),),
+- "To install run:",
+- " pip install --upgrade --force \"%s\"" % (e.dependency,),
++ "To install, try:",
++ " sudo apt-get install python-%s" % (e.dependency,),
+ "",
+ ])
+ sys.stderr.writelines(message)
+Index: package-synapse-debian/synapse/config/jwt_config.py
+===================================================================
+--- package-synapse-debian.orig/synapse/config/jwt_config.py
++++ package-synapse-debian/synapse/config/jwt_config.py
+@@ -19,7 +19,7 @@ MISSING_JWT = (
+ """Missing jwt library. This is required for jwt login.
+
+ Install by running:
+- pip install pyjwt
++ sudo apt-get install python-jwt
+ """
+ )
+
+Index: package-synapse-debian/synapse/config/repository.py
+===================================================================
+--- package-synapse-debian.orig/synapse/config/repository.py
++++ package-synapse-debian/synapse/config/repository.py
+@@ -27,9 +27,7 @@ MISSING_LXML = (
+ """Missing lxml library. This is required for URL preview API.
+
+ Install by running:
+- pip install lxml
+-
+- Requires libxslt1-dev system package.
++ sudo apt-get install python-lxml
+ """
+ )
+
diff --git a/debian/patches/remove-webclient.patch b/debian/patches/remove-webclient.patch
new file mode 100644
index 0000000000..bfd2fce576
--- /dev/null
+++ b/debian/patches/remove-webclient.patch
@@ -0,0 +1,31 @@
+Index: package-synapse-debian/synapse/app/homeserver.py
+===================================================================
+--- package-synapse-debian.orig/synapse/app/homeserver.py
++++ package-synapse-debian/synapse/app/homeserver.py
+@@ -124,7 +124,7 @@ class SynapseHomeServer(HomeServer):
+ for res in listener_config["resources"]:
+ for name in res["names"]:
+ resources.update(self._configure_named_resource(
+- name, res.get("compress", False),
++ config, name, res.get("compress", False),
+ ))
+
+ additional_resources = listener_config.get("additional_resources", {})
+@@ -171,7 +171,7 @@ class SynapseHomeServer(HomeServer):
+ )
+ logger.info("Synapse now listening on port %d", port)
+
+- def _configure_named_resource(self, name, compress=False):
++ def _configure_named_resource(self, config, name, compress=False):
+ """Build a resource map for a named resource
+
+ Args:
+@@ -235,7 +235,7 @@ class SynapseHomeServer(HomeServer):
+ if name in ["keys", "federation"]:
+ resources[SERVER_KEY_V2_PREFIX] = KeyApiV2Resource(self)
+
+- if name == "webclient":
++ if name == "webclient" and config.web_client:
+ resources[WEB_CLIENT_PREFIX] = build_resource_for_web_client(self)
+
+ if name == "metrics" and self.get_config().enable_metrics:
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000000..ae46209e92
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,7 @@
+0001-tox.patch
+0002-change_instructions.patch
+0004-webclient-instructions.patch
+0006-Don-t-require-strict-nacl-0.3.0-requirement.patch
+remove-webclient.patch
+bcrypt.patch
+no_install_with_pip
|