mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-12 11:04:18 -05:00
fa6deb298b
Debian package builds were failing for two reasons: 1. Python versions prior to 3.7 throw exceptions when attempting to print Unicode characters under a "C" locale. (#9076) 2. We depended on `dh-systemd` which no longer exists in Debian Bullseye, but is necessary in Ubuntu Xenial. (#9073) Setting `LANG="C.UTF-8"` in the build environment fixes the first issue. See also: https://bugs.python.org/issue19846 The second issue is a bit trickier. The dh-systemd package was merged into debhelper version 9.20160709 and a transitional package left in its wake. The transitional dh-systemd package was removed in Debian Bullseye. However, Ubuntu Xenial ships an older debhelper, and still needs dh-systemd. Thus, builds were failing on Bullseye since we depended on a package which had ceased existing, but we couldn't remove it from the debian/control file and our build scripts because we still needed it for Ubuntu Xenial. We can fix the debian/control issue by listing dh-systemd as an alternative to the newer versions of debhelper. Since dh-systemd declares that it depends on debhelper, Ubuntu Xenial will select its older dh-systemd which will in turn pull in its older debhelper, resulting in no change from the status quo. All other supported releases will satisfy the debhelper dependency constraint and skip the dh-systemd alternative. Build scripts were fixed by unconditionally attempting to install dh-systemd on all releases and suppressing failures. Once we drop support for Ubuntu Xenial, we can revert most of this commit and rely on the version constraint on debhelper in debian/control. Fixes #9076 Fixes #9073 Signed-off-by: Dan Callahan <danc@element.io>
92 lines
3.1 KiB
Plaintext
92 lines
3.1 KiB
Plaintext
# A dockerfile which builds a docker image for building a debian package for
|
|
# synapse. The distro to build for is passed as a docker build var.
|
|
#
|
|
# The default entrypoint expects the synapse source to be mounted as a
|
|
# (read-only) volume at /synapse/source, and an output directory at /debs.
|
|
#
|
|
# A pair of environment variables (TARGET_USERID and TARGET_GROUPID) can be
|
|
# passed to the docker container; if these are set, the build script will chown
|
|
# the build products accordingly, to avoid ending up with things owned by root
|
|
# in the host filesystem.
|
|
|
|
# Get the distro we want to pull from as a dynamic build variable
|
|
ARG distro=""
|
|
|
|
###
|
|
### Stage 0: build a dh-virtualenv
|
|
###
|
|
FROM ${distro} as builder
|
|
|
|
RUN apt-get update -qq -o Acquire::Languages=none
|
|
RUN env DEBIAN_FRONTEND=noninteractive apt-get install \
|
|
-yqq --no-install-recommends \
|
|
build-essential \
|
|
ca-certificates \
|
|
devscripts \
|
|
equivs \
|
|
wget
|
|
|
|
# fetch and unpack the package
|
|
RUN mkdir /dh-virtualenv
|
|
RUN wget -q -O /dh-virtualenv.tar.gz https://github.com/spotify/dh-virtualenv/archive/ac6e1b1.tar.gz
|
|
RUN tar -xv --strip-components=1 -C /dh-virtualenv -f /dh-virtualenv.tar.gz
|
|
|
|
# install its build deps. We do another apt-cache-update here, because we might
|
|
# be using a stale cache from docker build.
|
|
RUN apt-get update -qq -o Acquire::Languages=none \
|
|
&& cd /dh-virtualenv \
|
|
&& env DEBIAN_FRONTEND=noninteractive mk-build-deps -ri -t "apt-get -y --no-install-recommends"
|
|
|
|
# build it
|
|
RUN cd /dh-virtualenv && dpkg-buildpackage -us -uc -b
|
|
|
|
###
|
|
### Stage 1
|
|
###
|
|
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}
|
|
|
|
# Python < 3.7 assumes LANG="C" means ASCII-only and throws on printing unicode
|
|
# http://bugs.python.org/issue19846
|
|
ENV LANG C.UTF-8
|
|
|
|
# Install the build dependencies
|
|
#
|
|
# NB: keep this list in sync with the list of build-deps in debian/control
|
|
# TODO: it would be nice to do that automatically.
|
|
# TODO: Remove the dh-systemd stanza after dropping support for Ubuntu xenial
|
|
# it's a transitional package on all other, more recent releases
|
|
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 \
|
|
libsystemd-dev \
|
|
lsb-release \
|
|
pkg-config \
|
|
python3-dev \
|
|
python3-pip \
|
|
python3-setuptools \
|
|
python3-venv \
|
|
sqlite3 \
|
|
libpq-dev \
|
|
xmlsec1 \
|
|
&& ( env DEBIAN_FRONTEND=noninteractive apt-get install \
|
|
-yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \
|
|
dh-systemd || true )
|
|
|
|
COPY --from=builder /dh-virtualenv_1.2~dev-1_all.deb /
|
|
|
|
# install dhvirtualenv. Update the apt cache again first, in case we got a
|
|
# cached cache from docker the first time.
|
|
RUN apt-get update -qq -o Acquire::Languages=none \
|
|
&& apt-get install -yq /dh-virtualenv_1.2~dev-1_all.deb
|
|
|
|
WORKDIR /synapse/source
|
|
ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"]
|