build_debian_packages.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Build the Debian packages using Docker images.
  3. #
  4. # This script builds the Docker images and then executes them sequentially, each
  5. # one building a Debian package for the targeted operating system. It is
  6. # designed to be a "single command" to produce all the images.
  7. #
  8. # By default, builds for all known distributions, but a list of distributions
  9. # can be passed on the commandline for debugging.
  10. set -ex
  11. cd `dirname $0`
  12. if [ $# -lt 1 ]; then
  13. DISTS=(
  14. debian:stretch
  15. debian:buster
  16. debian:sid
  17. ubuntu:xenial
  18. ubuntu:bionic
  19. ubuntu:cosmic
  20. )
  21. else
  22. DISTS=("$@")
  23. fi
  24. # Make the dir where the debs will live.
  25. #
  26. # Note that we deliberately put this outside the source tree, otherwise we tend
  27. # to get source packages which are full of debs. (We could hack around that
  28. # with more magic in the build_debian.sh script, but that doesn't solve the
  29. # problem for natively-run dpkg-buildpakage).
  30. mkdir -p ../../debs
  31. # Build each OS image;
  32. for i in "${DISTS[@]}"; do
  33. TAG=$(echo ${i} | cut -d ":" -f 2)
  34. docker build --tag dh-venv-builder:${TAG} --build-arg distro=${i} -f Dockerfile-dhvirtualenv .
  35. docker run -it --rm --volume=$(pwd)/../\:/synapse/source:ro --volume=$(pwd)/../../debs:/debs \
  36. -e TARGET_USERID=$(id -u) \
  37. -e TARGET_GROUPID=$(id -g) \
  38. dh-venv-builder:${TAG}
  39. done