Fixes for bullseye
diff --git a/Makefile b/Makefile
index 768d43b..4404621 100644
--- a/Makefile
+++ b/Makefile
@@ -83,6 +83,31 @@
 
 buster: debian
 
+# Debian 11 - bullseye
+debian-bullseye: PLATFORM=bullseye
+debian-bullseye: DIST=debian-bullseye
+debian-bullseye: SPIDERMONKEY=libmozjs-78-0
+debian-bullseye: SPIDERMONKEY_DEV=libmozjs-78-dev
+debian-bullseye: SM_VER=78
+debian-bullseye: bullseye
+
+arm64v8-debian-bullseye: aarch64-debian-bullseye
+aarch64-debian-bullseye: PLATFORM=bullseye
+aarch64-debian-bullseye: DIST=debian-bullseye
+aarch64-debian-bullseye: SPIDERMONKEY=libmozjs-78-0
+aarch64-debian-bullseye: SPIDERMONKEY_DEV=libmozjs-78-dev
+aarch64-debian-bullseye: SM_VER=78
+aarch64-debian-bullseye: bullseye
+
+ppc64le-debian-bullseye: PLATFORM=bullseye
+ppc64le-debian-bullseye: DIST=debian-bullseye
+ppc64le-debian-bullseye: SPIDERMONKEY=libmozjs-78-0
+ppc64le-debian-bullseye: SPIDERMONKEY_DEV=libmozjs-78-dev
+ppc64le-debian-bullseye: SM_VER=78
+ppc64le-debian-bullseye: bullseye
+
+bullseye: debian
+
 
 # Ubuntu 16.04 (Xenial)
 ubuntu-xenial: PLATFORM=xenial
diff --git a/bin/detect-os.sh b/bin/detect-os.sh
index 83ffb51..8359d24 100755
--- a/bin/detect-os.sh
+++ b/bin/detect-os.sh
@@ -82,10 +82,13 @@
       if [[ ${PRETTY_NAME} =~ "Ubuntu" ]]; then
         # Ubuntu keeps changing the format of /etc/os-release's VERSION, and
         # the codename is buried. Boo. Let's use a fancy regex.
+        VERSION_ID=${VERSION_ID:-$(dpkg --status tzdata|grep Provides|cut -f2 -d'-')}
         VERSION_CODENAME=${VERSION_CODENAME:-$(echo ${VERSION} | sed -E 's/([0-9.]+)\W+([A-Za-z\,]+)\W+\(?(\w+)(.*)/\L\3/')}
         DISTRIB_CODENAME=${DISTRIB_CODENAME:-${VERSION_CODENAME}}
       elif [[ ${PRETTY_NAME} =~ "Debian" ]]; then
-        VERSION_CODENAME=${VERSION_CODENAME:-$(echo ${VERSION} | sed -E 's/(.*)\(([^\]+)\)/\2/')}
+        VERSION_ID=${VERSION_ID:-$(dpkg --status tzdata|grep Provides|cut -f2 -d'-')}
+        VERSION=${VERSION:-${VERSION_ID}}
+        VERSION_CODENAME=${VERSION_CODENAME:-$(echo ${VERSION} | sed -E 's/(.*)\(([^\]+)\)/\2/' | sed -E 's/(.*)\/.*/\1/')}
         DISTRIB_CODENAME=${DISTRIB_CODENAME:-${VERSION_CODENAME}}
       else
         echo "Unknown Debian-like OS ${PRETTY_NAME}, aborting..."
@@ -96,6 +99,7 @@
       echo "Detected distribution: ${ID}, version ${VERSION_ID} (${VERSION_CODENAME})"
     else
       echo "Unable to determine Linux distribution! Aborting."
+      echo "Detected: ID=${ID}, VERSION_ID=${VERSION_ID}, VERSION_CODENAME=(${VERSION_CODENAME})"
       exit 1
     fi
     ;;
diff --git a/build.sh b/build.sh
index 1842361..b2b3513 100755
--- a/build.sh
+++ b/build.sh
@@ -28,7 +28,7 @@
 SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
 # TODO derive these by interrogating the couchdb-ci repo rather than hard coding the list...
-DEBIANS="debian-stretch debian-buster"
+DEBIANS="debian-stretch debian-buster debian-bullseye"
 UBUNTUS="ubuntu-xenial ubuntu-bionic ubuntu-focal"
 CENTOSES="centos-7 centos-8"
 XPLAT_BASE="debian-buster"
diff --git a/debian/control.in b/debian/control.in
index a5e6e71..03437f9 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -5,7 +5,6 @@
 Standards-Version: 3.9.6
 Build-Depends: debhelper (>= 9),
                dh-exec,
-               dh-systemd (>= 1.5),
                erlang-dev (>= 1:19.2.1) | esl-erlang (>= 1:19.2.1),
                erlang-crypto | esl-erlang,
                erlang-dialyzer | esl-erlang,