aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2018-03-19 19:58:57 -0400
committerAlec Warner <antarus@gentoo.org>2018-03-19 19:58:57 -0400
commitc168cee1054fa6a5a993d5033950f6803bc29569 (patch)
tree94e73920fc9c24276507aaf4d3e98b6908b8d70d
parentSwitch to using fully qualified prefix. (diff)
downloadmastermirror-scripts-c168cee1054fa6a5a993d5033950f6803bc29569.tar.gz
mastermirror-scripts-c168cee1054fa6a5a993d5033950f6803bc29569.tar.bz2
mastermirror-scripts-c168cee1054fa6a5a993d5033950f6803bc29569.zip
Avoid manual intervention when we miss a snapshot.
If yesterday's snapshot is missing, scan for the last successful snapshot.
-rwxr-xr-xsnapshots-create.sh25
1 files changed, 19 insertions, 6 deletions
diff --git a/snapshots-create.sh b/snapshots-create.sh
index f6af8ac..f29dec6 100755
--- a/snapshots-create.sh
+++ b/snapshots-create.sh
@@ -44,8 +44,21 @@ if [[ ! $(gpg --list-keys ${SIGNKEYID} | grep ${SIGNKEYID}) ]]; then
exit 1
fi
-if [[ ! -e "${UPLOAD}/${DELTA_FILENAME}" ]]; then
- echo "Previous snapshot does not exist: '${UPLOAD}/${DELTA_FILENAME}'"
+# Use yesterdays snapshot, if its unavailable, use the 'latest' snapshot.
+# If both are missing, bail out.
+POTENTIAL_SNAPSHOTS=(
+ ${UPLOAD}/${DELTA_FILENAME}
+ ${UPLOAD}/portage-latest.tar.bz2
+ FAIL
+)
+
+for previous_snapshot in ${POTENTIAL_SNAPSHOTS[*]}; do
+ [[ -e ${previous_snapshot} ]] && break
+done
+
+if [[ ${previous_snapshot} == FAIL ]]; then
+ # Cut FAIL out of the printed list, to ease debugging.
+ echo "Previous snapshots do not exist: ${POTENTIAL_SNAPSHOTS[*]:0:2}"
exit 1
fi
@@ -138,19 +151,19 @@ write_time_log "END TARBALL $(date -u)"
# 2) Sanity check the tarball size and bail out if it appears abnormal.
write_time_log "START SIZE SANITY $(date -u)"
current_size=$(stat -c '%s' "${FILENAME}")
-previous_size=$(stat -c '%s' "${UPLOAD}/${DELTA_FILENAME}")
+previous_size=$(stat -c '%s' "${previous_snapshot}")
if [ ${current_size} -lt ${previous_size} ]; then
size_difference=$(expr ${previous_size} - ${current_size})
difference_ratio=$(expr ${previous_size} / ${size_difference})
if [ ${difference_ratio} -lt 2 ]; then
echo "Snapshot size has decreased by more than 50% in one day!!!"
echo "${FILENAME} ${current_size} bytes"
- echo "${DELTA_FILENAME} ${previous_size} bytes"
+ echo "${previous_snapshot} ${previous_size} bytes"
exit 1
elif [ ${difference_ratio} -lt 5 ]; then
echo "Snapshot size has decreased by more than 20% in one day!!!"
echo "${FILENAME} ${current_size} bytes"
- echo "${DELTA_FILENAME} ${previous_size} bytes"
+ echo "${previous_snapshot} ${previous_size} bytes"
# Make this non-fatal while we recover more space.
#exit 1
fi
@@ -192,7 +205,7 @@ write_time_log "END SIGN $(date -u)"
write_time_log "START DELTA $(date -u)"
PATCH=snapshot-${DELTA_BASE}-${YESTERDAY}.patch.bz2
if [ ! -f "${PATCH}" ]; then
- ${NICE} ${BZIP2_PROG} -dkc ${UPLOAD}/${DELTA_FILENAME} > orig
+ ${NICE} ${BZIP2_PROG} -dkc "${previous_snapshot}" > orig
/usr/bin/differ -f bdelta orig ${FILENAME%.bz2} ${PATCH%.bz2}
${NICE} ${BZIP2_PROG} -9 ${PATCH%.bz2}
md5sum ${PATCH} > ${PATCH}.md5sum