apt-mirror 2.27 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)
bertagaz's avatar
bertagaz committed
32
CURRENT_BRANCH=$(git_current_branch)
33

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