1
0

docker_update_debian_changelog.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash -e
  2. # Copyright 2021 The Matrix.org Foundation C.I.C.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # This script is meant to be used inside a Docker container to run the `dch` incantations
  16. # needed to release Synapse. This is useful on systems like macOS where such scripts are
  17. # not easily accessible.
  18. #
  19. # Running it (when if the current working directory is the root of the Synapse checkout):
  20. # docker run --rm -v $PWD:/synapse ubuntu:latest /synapse/scripts-dev/docker_update_debian_changelog.sh VERSION
  21. #
  22. # The image can be replaced by any other Debian-based image (as long as the `devscripts`
  23. # package exists in the default repository).
  24. # `VERSION` is the version of Synapse being released without the leading "v" (e.g. 1.42.0).
  25. # Check if a version was provided.
  26. if [ "$#" -ne 1 ]; then
  27. echo "Usage: update_debian_changelog.sh VERSION"
  28. echo "VERSION is the version of Synapse being released in the form 1.42.0 (without the leading \"v\")"
  29. exit 1
  30. fi
  31. # Check that apt-get is available on the system.
  32. if ! which apt-get > /dev/null 2>&1; then
  33. echo "\"apt-get\" isn't available on this system. This script needs to be run in a Docker container using a Debian-based image."
  34. exit 1
  35. fi
  36. # Check if devscripts is available in the default repos for this distro.
  37. # Update the apt package list cache.
  38. # We need to do this before we can search the apt cache or install devscripts.
  39. apt-get update || exit 1
  40. if ! apt-cache search devscripts | grep -E "^devscripts \-" > /dev/null; then
  41. echo "The package \"devscripts\" needs to exist in the default repositories for this distribution."
  42. exit 1
  43. fi
  44. # We set -x here rather than in the shebang so that if we need to exit early because no
  45. # version was provided, the message doesn't get drowned in useless output.
  46. set -x
  47. # Make the root of the Synapse checkout the current working directory.
  48. cd /synapse
  49. # Install devscripts (which provides dch). We need to make the Debian frontend
  50. # noninteractive because installing devscripts otherwise asks for the machine's location.
  51. DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts
  52. # Update the Debian changelog.
  53. ver=${1}
  54. dch -M -v "$(sed -Ee 's/(rc|a|b|c)/~\1/' <<<"$ver")" "New synapse release $ver."
  55. dch -M -r -D stable ""