build_debian.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. # The script to build the Debian package, as ran inside the Docker image.
  3. set -ex
  4. # Get the codename from distro env
  5. DIST=`cut -d ':' -f2 <<< $distro`
  6. # we get a read-only copy of the source: make a writeable copy
  7. cp -aT /synapse/source /synapse/build
  8. cd /synapse/build
  9. # if this is a prerelease, set the Section accordingly.
  10. #
  11. # When the package is later added to the package repo, reprepro will use the
  12. # Section to determine which "component" it should go into (see
  13. # https://manpages.debian.org/stretch/reprepro/reprepro.1.en.html#GUESSING)
  14. DEB_VERSION=`dpkg-parsechangelog -SVersion`
  15. case $DEB_VERSION in
  16. *~rc*|*~a*|*~b*|*~c*)
  17. sed -ie '/^Section:/c\Section: prerelease' debian/control
  18. ;;
  19. esac
  20. # add an entry to the changelog for this distribution
  21. dch -M -l "+$DIST" "build for $DIST"
  22. dch -M -r "" --force-distribution --distribution "$DIST"
  23. dpkg-buildpackage -us -uc
  24. ls -l ..
  25. # copy the build results out, setting perms if necessary
  26. shopt -s nullglob
  27. for i in ../*.deb ../*.dsc ../*.tar.xz ../*.changes ../*.buildinfo; do
  28. [ -z "$TARGET_USERID" ] || chown "$TARGET_USERID" "$i"
  29. [ -z "$TARGET_GROUPID" ] || chgrp "$TARGET_GROUPID" "$i"
  30. mv "$i" /debs
  31. done