apt-mirror 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. set -e
  3. set -u
  4. . "$(dirname $0)/utils.sh"
  5. ARCHIVE="$1"
  6. output_tagged_snapshot() {
  7. local archive="$1"
  8. local tag="$2"
  9. local snapshot=$(branch_name_to_suite "$tag")
  10. echo "http://tagged.snapshots.deb.tails.boum.org/$snapshot/$archive"
  11. }
  12. output_time_based_snapshot() {
  13. local archive="$1"
  14. local serial="$2"
  15. echo "http://time-based.snapshots.deb.tails.boum.org/$archive/$serial"
  16. }
  17. ### Sanity checks
  18. [ -n "$ARCHIVE" ] || exit 1
  19. ### Main
  20. SERIAL=$(cat "config/APT_snapshots.d/$ARCHIVE/serial")
  21. RESOLVED_SERIAL=$(cat "tmp/APT_snapshots.d/$ARCHIVE/serial")
  22. BASE_BRANCH=$(base_branch)
  23. if [ "$BASE_BRANCH" = stable ] || [ "$BASE_BRANCH" = testing ] ; then
  24. case "$ARCHIVE" in
  25. debian-security)
  26. [ "$SERIAL" = latest ] \
  27. || fatal "APT snapshots are frozen for the debian-security archive," \
  28. "which should not happen on a branch based on $BASE_BRANCH"
  29. ;;
  30. *)
  31. [ "$SERIAL" != latest ] \
  32. || fatal "APT snapshots are not frozen for the $ARCHIVE archive," \
  33. "which should not happen on a branch based on $BASE_BRANCH"
  34. esac
  35. if version_was_released "$(version_in_changelog)"; then
  36. on_a_tag \
  37. || fatal "Not building from a tag, but last version in changelog" \
  38. "was released"
  39. output_tagged_snapshot "$ARCHIVE" "$(version_in_changelog)"
  40. else
  41. if [ "$BASE_BRANCH" = stable ] ; then
  42. version_was_released "$(previous_version_in_changelog)" \
  43. || fatal "None of the two last version in changelog were released"
  44. fi
  45. output_time_based_snapshot "$ARCHIVE" "$RESOLVED_SERIAL"
  46. fi
  47. else
  48. if [ "$(base_branch)" = devel ] && [ "$SERIAL" != latest ]; then
  49. fatal "APT snapshots are frozen, which should not happen on a branch" \
  50. "based on the devel one"
  51. fi
  52. output_time_based_snapshot "$ARCHIVE" "$RESOLVED_SERIAL"
  53. fi