3 # shellcheck disable=SC2029
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}"
13 echo "$(basename "$0") BUILD_MANIFEST TAG" >&2
16 [ $# -eq 2 ] || fail_with_usage
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" \
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
45 ssh "$TIME_BASED_SNAPSHOTS_USER_AT_HOST" \
46 reprepro
--basedir "${REMOTE_DEST_DIR}/${archive}" update
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"
55 ssh "${TIME_BASED_SNAPSHOTS_USER}@${TIME_BASED_SNAPSHOTS_HOST}" \
56 rm "$REMOTE_BUILD_MANIFEST"