tails-custom-apt-sources 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. set -e
  3. set -u
  4. . "$(dirname $0)/utils.sh"
  5. APT_MIRROR_URL="http://deb.tails.boum.org/"
  6. DEFAULT_COMPONENTS="main contrib non-free"
  7. BASE_BRANCHES="stable testing devel feature/jessie"
  8. output_apt_binary_source() {
  9. local suite="$1"
  10. local components="${2:-$DEFAULT_COMPONENTS}"
  11. echo "deb $APT_MIRROR_URL $suite $components"
  12. }
  13. output_overlay_apt_binary_sources() {
  14. for suite in $(ls config/APT_overlays.d) ; do
  15. output_apt_binary_source "$suite"
  16. done
  17. }
  18. on_base_branch() {
  19. local current_branch=$(current_branch)
  20. for base_branch in $BASE_BRANCHES ; do
  21. if [ "$current_branch" = "$base_branch" ] ; then
  22. return 0
  23. fi
  24. done
  25. return 1
  26. }
  27. ### Sanity checks
  28. [ -d config/APT_overlays.d ] || fatal 'config/APT_overlays.d/ does not exist'
  29. [ -e config/base_branch ] || fatal 'config/base_branch does not exist'
  30. [ "$(cat config/base_branch | wc -l)" -eq 1 ] \
  31. || fatal 'config/base_branch must contain exactly one line'
  32. if on_base_branch && ! [ "$(base_branch)" = "$(current_branch)" ] ; then
  33. echo "base_branch: $(base_branch)" >&2
  34. echo "current_branch: $(current_branch)" >&2
  35. fatal "In a base branch, config/base_branch must match the current branch."
  36. fi
  37. ### Main
  38. if version_was_released "$(version_in_changelog)"; then
  39. if [ -n "$(ls config/APT_overlays.d)" ]; then
  40. fatal 'config/APT_overlays.d/ must be empty while releasing'
  41. fi
  42. output_apt_binary_source "$(branch_name_to_suite "$(version_in_changelog)")"
  43. else
  44. output_apt_binary_source "$(branch_name_to_suite "$(base_branch)")"
  45. output_overlay_apt_binary_sources
  46. fi