Update IDF for download verification
[tails.git] / bin / tag-apt-snapshots
blob1b85bf455f95a99c189472c0fd5f9c062c738c55
1 #!/bin/sh
3 # shellcheck disable=SC2029
5 set -e
6 set -u
8 TIME_BASED_SNAPSHOTS_HOST='apt.lizard'
9 TIME_BASED_SNAPSHOTS_USER='reprepro-time-based-snapshots'
10 TIME_BASED_SNAPSHOTS_USER_AT_HOST="${TIME_BASED_SNAPSHOTS_USER}@${TIME_BASED_SNAPSHOTS_HOST}"
12 fail_with_usage() {
13 echo "$(basename "$0") BUILD_MANIFEST TAG" >&2
16 [ $# -eq 2 ] || fail_with_usage
18 BUILD_MANIFEST="$1"
19 TAG="$2"
21 [ -r "$BUILD_MANIFEST" ] || fail_with_usage
22 [ -n "$TAG" ] || fail_with_usage
24 echo "I: Preparing a workspace on ${TIME_BASED_SNAPSHOTS_HOST}"
25 ssh "$TIME_BASED_SNAPSHOTS_USER_AT_HOST" install -d '$HOME'/tmp
26 REMOTE_BUILD_MANIFEST=$(ssh "$TIME_BASED_SNAPSHOTS_USER_AT_HOST" \
27 mktemp --tmpdir='$HOME'/tmp)
28 REMOTE_DEST_DIR=$(ssh "$TIME_BASED_SNAPSHOTS_USER_AT_HOST" \
29 mktemp -d --tmpdir='$HOME'/tmp)
31 echo "I: Sending build manifest to ${TIME_BASED_SNAPSHOTS_HOST}"
32 scp "$BUILD_MANIFEST" \
33 "${TIME_BASED_SNAPSHOTS_USER_AT_HOST}:${REMOTE_BUILD_MANIFEST}"
35 echo "I: Preparing reprepro configuration"
36 ssh "$TIME_BASED_SNAPSHOTS_USER_AT_HOST" \
37 tails-prepare-tagged-apt-snapshot-import \
38 "$REMOTE_BUILD_MANIFEST" \
39 "$REMOTE_DEST_DIR"
41 echo "I: Pulling packages from the time-based snapshots into the tagged ones"
42 for archive in $(ssh "$TIME_BASED_SNAPSHOTS_USER_AT_HOST" \
43 ls "$REMOTE_DEST_DIR") ; do
44 echo "I: - $archive"
45 ssh "$TIME_BASED_SNAPSHOTS_USER_AT_HOST" \
46 reprepro --basedir "${REMOTE_DEST_DIR}/${archive}" update
47 done
49 echo "I: Publishing the tagged APT snapshot"
50 ssh "${TIME_BASED_SNAPSHOTS_USER}@${TIME_BASED_SNAPSHOTS_HOST}" \
51 sudo -n /usr/local/sbin/tails-publish-tagged-apt-snapshot \
52 "$REMOTE_DEST_DIR" "$TAG"
54 echo "I: Cleaning up"
55 ssh "${TIME_BASED_SNAPSHOTS_USER}@${TIME_BASED_SNAPSHOTS_HOST}" \
56 rm "$REMOTE_BUILD_MANIFEST"