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