update-acng-config 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. set -e
  3. set -u
  4. set -o pipefail
  5. list_origins () {
  6. (
  7. cd config/APT_snapshots.d/
  8. ls --color=never -1 | grep -v --line-regexp '\.placeholder'
  9. )
  10. }
  11. print_tagged_snapshots_pool_url () {
  12. origin="$1"
  13. version="$2"
  14. printf \
  15. 'http://tagged.snapshots.deb.tails.boum.org/%s/%s/pool/\n' \
  16. "$version" "$origin"
  17. }
  18. conf=/etc/apt-cacher-ng/tails-snapshots.conf
  19. for origin in $(list_origins) ; do
  20. [ "$origin" != .placeholder ] || continue
  21. origin_without_dashes=$(echo "$origin" | sed -e 's,-,,g')
  22. echo "Remap-tailssnapshots${origin_without_dashes}pool: file:tails-time-based-snapshots-$origin-pool.list file:tails-tagged-snapshots-$origin-pool.list"
  23. done > "$conf"
  24. chmod 644 "$conf"
  25. # Generate .list files for time-based snapshots
  26. for origin in $(list_origins) ; do
  27. list="/etc/apt-cacher-ng/tails-time-based-snapshots-$origin-pool.list"
  28. current_year=$(date '+%Y')
  29. for year in $(seq $(($current_year - 1)) $(($current_year + 1))) ; do
  30. for month in $(seq 1 12); do
  31. # We need the config file to contain _at least_ everything
  32. # that can possibly exists, and we don't care if it has some extra
  33. # lines, so to simplify we do as if each month had 31 days.
  34. for day in $(seq 1 31) ; do
  35. for n in $(seq 1 4) ; do
  36. printf 'http://time-based.snapshots.deb.tails.boum.org/%s/%04u%02u%02u%02u/pool/\n' \
  37. "$origin" "$year" "$month" "$day" "$n"
  38. done
  39. done
  40. done
  41. done \
  42. > "$list"
  43. chmod 644 "$list"
  44. done
  45. # Generate .list files for tagged snapshots
  46. for origin in $(list_origins) ; do
  47. list="/etc/apt-cacher-ng/tails-tagged-snapshots-$origin-pool.list"
  48. # We need the config file to contain _at least_ everything
  49. # that can possibly exists, and we don't care if it has some extra
  50. # lines, so here we try to build the smallest possible superset of
  51. # all realistic Tails version numbers; it could certainly be a tiny
  52. # bit smaller, at the cost of more assumptions (=> more risk of not
  53. # including some version number we'll end up using) or of more
  54. # code complexity (=> higher maintenance cost).
  55. #
  56. # XXX: Stretch: bump the end of the range of major versions
  57. for major in $(seq 2 3) ; do
  58. for minor in $(seq 0 32); do
  59. for suffix in "" alpha beta rc ; do
  60. for suffix_n in "" $(seq 1 8); do
  61. if [ -z "$suffix" ]; then
  62. version="${major}.${minor}"
  63. elif [ -z "$suffix_n" ]; then
  64. version="${major}.${minor}-${suffix}"
  65. else
  66. version="${major}.${minor}-${suffix}${suffix_n}"
  67. fi
  68. print_tagged_snapshots_pool_url "$origin" "$version"
  69. done
  70. done
  71. for emergency in $(seq 1 4) ; do
  72. version="${major}.${minor}.${emergency}"
  73. print_tagged_snapshots_pool_url "$origin" "$version"
  74. done
  75. done
  76. done > "$list"
  77. chmod 644 "$list"
  78. done