From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E9BE7158009 for ; Fri, 30 Jun 2023 05:33:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DEAC5E0802; Fri, 30 Jun 2023 05:33:10 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C7650E0802 for ; Fri, 30 Jun 2023 05:33:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EA26F335C7B for ; Fri, 30 Jun 2023 05:33:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 77F10135 for ; Fri, 30 Jun 2023 05:33:08 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1688103181.d1dda423e1285e94fade299209e58f4434db35ee.robbat2@gentoo> Subject: [gentoo-commits] proj/qa-scripts:master commit in: / X-VCS-Repository: proj/qa-scripts X-VCS-Files: keyrings-export.bash keyrings.inc.bash X-VCS-Directories: / X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: d1dda423e1285e94fade299209e58f4434db35ee X-VCS-Branch: master Date: Fri, 30 Jun 2023 05:33:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: eda7b1e9-813e-42fb-ac5a-63c9487aff04 X-Archives-Hash: 9b8a087365bdd18e7d3f5c0f63fc545b commit: d1dda423e1285e94fade299209e58f4434db35ee Author: Robin H. Johnson gentoo org> AuthorDate: Fri Jun 30 05:33:01 2023 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Fri Jun 30 05:33:01 2023 +0000 URL: https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=d1dda423 keyrings.inc.bash: ensure digests/packets present Signed-off-by: Robin H. Johnson gentoo.org> keyrings-export.bash | 4 +++- keyrings.inc.bash | 17 +++++++++-------- 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