apt-mirror 2.22 KB
Newer Older
1
#!/bin/bash
2
3
4
5

set -e
set -u

6
7
. "$(dirname $0)/utils.sh"

8
9
ARCHIVE="$1"

10
11
12
output_tagged_snapshot() {
   local archive="$1"
   local tag="$2"
13
   local snapshot=$(branch_name_to_suite "$tag")
intrigeri's avatar
intrigeri committed
14
   echo "http://tagged.snapshots.deb.tails.boum.org/$snapshot/$archive"
15
16
17
18
19
20
21
22
23
24
}

output_time_based_snapshot() {
   local archive="$1"
   local serial="$2"
   echo "http://time-based.snapshots.deb.tails.boum.org/$archive/$serial"
}

### Sanity checks

25
26
[ -n "$ARCHIVE" ] || exit 1

27
28
29
30
### Main

SERIAL=$(cat "config/APT_snapshots.d/$ARCHIVE/serial")
RESOLVED_SERIAL=$(cat "tmp/APT_snapshots.d/$ARCHIVE/serial")
31
BASE_BRANCH=$(base_branch)
32
CURRENT_BRANCH=$(current_branch)
33

34
if [ "$BASE_BRANCH" = stable ] || [ "$BASE_BRANCH" = testing ] || [ "$CURRENT_BRANCH" = feature/stretch ] ; then
35
36
37
    case "$ARCHIVE" in
       debian-security)
          [ "$SERIAL" = latest ] \
38
              || fatal "APT snapshots are frozen for the debian-security archive," \
39
40
                       "which should happen neither on feature/stretch nor on"     \
                        "a branch based on $BASE_BRANCH"
41
42
43
          ;;
       *)
          [ "$SERIAL" != latest ] \
44
              || fatal "APT snapshots are not frozen for the $ARCHIVE archive," \
45
46
                       "which should happen neither on feature/stretch nor on"  \
                        "a branch based on $BASE_BRANCH"
47
    esac
48
    if version_was_released "$(version_in_changelog)"; then
49
50
        on_a_tag \
            || fatal "Not building from a tag, but last version in changelog" \
51
52
53
                     "was released"
        output_tagged_snapshot "$ARCHIVE" "$(version_in_changelog)"
    else
54
55
56
57
58
       if [ "$BASE_BRANCH" = stable ] ; then
           version_was_released "$(previous_version_in_changelog)" \
               || fatal "None of the two last version in changelog were released"
       fi
       output_time_based_snapshot "$ARCHIVE" "$RESOLVED_SERIAL"
59
    fi
60
else
61
    if [ "$BASE_BRANCH" = devel ] || [ "$CURRENT_BRANCH" = feature/stretch ]; then
62
63
64
65
        if [ "$SERIAL" != latest ]; then
            fatal "APT snapshots are frozen, which should happen neither on" \
                  "feature/stretch nor on a branch based on the devel one"
        fi
66
67
    fi
    output_time_based_snapshot "$ARCHIVE" "$RESOLVED_SERIAL"
68
fi