aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2023-06-29 22:33:01 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2023-06-29 22:33:01 -0700
commitd1dda423e1285e94fade299209e58f4434db35ee (patch)
treea5477c7c6a761d5e9ea4d4807cb30235fcfb8b2f
parentkeyrings.inc.bash: ensure there is a checksum to verify the download for corr... (diff)
downloadqa-scripts-d1dda423e1285e94fade299209e58f4434db35ee.tar.gz
qa-scripts-d1dda423e1285e94fade299209e58f4434db35ee.tar.bz2
qa-scripts-d1dda423e1285e94fade299209e58f4434db35ee.zip
keyrings.inc.bash: ensure digests/packets present
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rwxr-xr-xkeyrings-export.bash4
-rw-r--r--keyrings.inc.bash17
2 files changed, 12 insertions, 9 deletions
diff --git a/keyrings-export.bash b/keyrings-export.bash
index 92c0228..56e4e51 100755
--- a/keyrings-export.bash
+++ b/keyrings-export.bash
@@ -6,6 +6,8 @@
# - requires keeping state to detect changes in keys, there is no usable mtime data in a key itself
OUTPUT_DIR=${1:-.}
+# Ensure output is absolute
+OUTPUT_DIR=$(readlink -f "${OUTPUT_DIR}")
BASEDIR="$(dirname "$0")"
# shellcheck source=./keyrings.inc.bash
source "${BASEDIR}"/keyrings.inc.bash
@@ -57,7 +59,7 @@ export_keys "${OUTPUT_DIR}"/keys/all-devs.gpg \
for key in "${KEYRINGS[@]}" ; do
if [[ ! -L "${OUTPUT_DIR}"/${key}.gpg ]] ; then
# Compatibility symlink
- ln -s "${OUTPUT_DIR}"/keys/${key}.gpg "${OUTPUT_DIR}"/${key}.gpg
+ ln -sf "${OUTPUT_DIR}"/keys/${key}.gpg "${OUTPUT_DIR}"/${key}.gpg
fi
if [[ $(date -u +%A) == Monday ]] ; then
diff --git a/keyrings.inc.bash b/keyrings.inc.bash
index 32fc03f..d2668e0 100644
--- a/keyrings.inc.bash
+++ b/keyrings.inc.bash
@@ -123,14 +123,15 @@ export_keys() {
# Check if the textual format has changed at all, and emit the new version
# if there are ANY changes at all.
- if ! cmp -s "${DST}.packets.txt" "${TMP}.packets.txt"; then
- chmod a+r "${TMP}"
- mv -f "${TMP}" "${DST}"
- mv -f "${TMP}.packets.txt" "${DST}.packets.txt"
- mv -f "${TMP}.DIGESTS" "${DST}.DIGESTS"
- fi
- # Cleanup anyway
- rm -f "${TMP}.packets.txt" "${TMP}"
+ cmp -s "${DST}.packets.txt" "${TMP}.packets.txt"
+ cmp_rc=$?
+ chmod a+r "${TMP}" "${TMP}.packets.txt" "${TMP}.DIGESTS"
+ for suffix in '' '.packets.txt' '.DIGESTS'; do
+ # If these file do not exist, or the cmp was different, move them.
+ [ ! -f "${DST}${suffix}" -o $cmp_rc -ne 0 ] && mv -f "${TMP}${suffix}" "${DST}${suffix}"
+ # Cleanup anyway
+ rm -f "${TMP}${suffix}"
+ done
}
# populate common variables