blob: 08f6de973661e97537739988c34e5ab2cb788e5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/sh
# S3 bucket
S3="s3://apt-archive.postgresql.org/pub/repos/apt"
set -eu
FILE="$1"
if [ "${2:-}" ]; then
DEST="$2"
else
DEST="$FILE"
fi
if ! test -f "$FILE"; then
echo "$FILE is missing" >&2
BASE="${FILE##*/}"
if test -s "morgue/$BASE"; then
FILE="morgue/$BASE"
echo "Using $FILE instead"
else
exit 1
fi
fi
case $DEST in
dists/*|pool/*) ;;
*) echo "Refusing to upload file outside of dists/ or pool/" >&2
exit 1
;;
esac
[ -t 1 ] && echo "$FILE ..."
# upload to S3
aws s3 cp --quiet "$FILE" "$S3/$DEST"
# try if we can get the file back
RESTORE=$(mktemp --tmpdir upload-to-s3.XXXXXX)
trap "rm -f $RESTORE" EXIT
aws s3 cp --quiet "$S3/$DEST" "$RESTORE"
cmp "$FILE" "$RESTORE"
|