diff --git a/changelog.d/5775.bugfix b/changelog.d/5775.bugfix
new file mode 100644
index 0000000000000000000000000000000000000000..b124897d802c35b949c30d1fdbaef0b23a43a4c9
--- /dev/null
+++ b/changelog.d/5775.bugfix
@@ -0,0 +1 @@
+Fix debian packaging scripts to correctly build sid packages.
diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv
index 0117ab8bcc07bf34cdcb3bc6d7675b7a637d8afc..ac9ebcfd88c2ec0350f0a5a1cf17b95d464749bc 100644
--- a/docker/Dockerfile-dhvirtualenv
+++ b/docker/Dockerfile-dhvirtualenv
@@ -42,6 +42,11 @@ RUN cd dh-virtualenv-1.1 && dpkg-buildpackage -us -uc -b
 ###
 FROM ${distro}
 
+# Get the distro we want to pull from as a dynamic build variable
+# (We need to define it in each build stage)
+ARG distro=""
+ENV distro ${distro}
+
 # Install the build dependencies
 #
 # NB: keep this list in sync with the list of build-deps in debian/control
diff --git a/docker/build_debian.sh b/docker/build_debian.sh
index 6ed2b398986d5aa752f6edbda4223a4ded1b26f7..f312f0715fd194cb4c4cc236a006b8263ad7937e 100644
--- a/docker/build_debian.sh
+++ b/docker/build_debian.sh
@@ -4,7 +4,8 @@
 
 set -ex
 
-DIST=`lsb_release -c -s`
+# Get the codename from distro env
+DIST=`cut -d ':' -f2 <<< $distro`
 
 # we get a read-only copy of the source: make a writeable copy
 cp -aT /synapse/source /synapse/build