copy_buildsync: fix tempfile for OUT_ISO & OUT_STAGE, plus comments

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This commit is contained in:
Robin H. Johnson 2023-10-08 16:06:13 -07:00
parent 57cb206aa5
commit 6c75b00db7
No known key found for this signature in database
GPG key ID: 19395F23C58826C4

View file

@ -154,14 +154,21 @@ process_arch() {
[ -z "${latest_iso_date}" ] && latest_iso_date="NONE-FOUND" [ -z "${latest_iso_date}" ] && latest_iso_date="NONE-FOUND"
[ -z "${latest_stage3_date}" ] && latest_stage3_date="NONE-FOUND" [ -z "${latest_stage3_date}" ] && latest_stage3_date="NONE-FOUND"
OUT_ISO_tmp=""
OUT_STAGE3_tmp=""
if [ -n "${iso_list}" ]; then if [ -n "${iso_list}" ]; then
echo -e "${header}" >"${OUT_ISO}" OUT_ISO_tmp=$(mktemp -p . -t ".${OUT_ISO}.XXXXXX")
chmod 644 "${OUT_ISO_tmp}"
echo -e "${header}" >"${OUT_ISO_tmp}"
# Some arches produce more than one type of iso. # Some arches produce more than one type of iso.
# So let's not advertise a current one via a symlink in general. # So let's not advertise a current one via a symlink in general.
rm -f current-iso rm -f current-iso
fi fi
if [ -n "${stage3_list}" ]; then if [ -n "${stage3_list}" ]; then
echo -e "${header}" >"${OUT_STAGE3}" OUT_STAGE3_tmp=$(mktemp -p . -t ".${OUT_STAGE3}.XXXXXX")
chmod 644 "${OUT_STAGE3_tmp}"
echo -e "${header}" >"${OUT_STAGE3_tmp}"
# Ditto for stage3 # Ditto for stage3
rm -f current-stage3 rm -f current-stage3
fi fi
@ -177,25 +184,37 @@ process_arch() {
for v in $variants ; do for v in $variants ; do
# FIXME: trace the $a variable in this! # FIXME: trace the $a variable in this!
# example output 20230907T160230Z/install-alpha-minimal-20230907T160230Z.iso
variant_path=$(find 20* -iname "${v}-20*" "${find_variants[@]}" -print 2>/dev/null | sed -e "s,.*/$a/autobuilds/,,g" | sort -k1,1 -t/ | tail -n1 ) variant_path=$(find 20* -iname "${v}-20*" "${find_variants[@]}" -print 2>/dev/null | sed -e "s,.*/$a/autobuilds/,,g" | sort -k1,1 -t/ | tail -n1 )
if [ -z "${variant_path}" ] || [ ! -e "${variant_path}" ]; then if [ -z "${variant_path}" ] || [ ! -e "${variant_path}" ]; then
echo "$ARCH: Variant ${v} is missing" 1>&2 echo "$ARCH: Variant ${v} is missing" 1>&2
continue continue
fi fi
variant_date="${variant_path%/*}"
variant_base="${variant_path#*/}"
size=$(stat --format='%s' "${variant_path}") size=$(stat --format='%s' "${variant_path}")
f="latest-${v}.txt" f="latest-${v}.txt"
f_tmp=$(mktemp -p . -t ".${f}.XXXXXX") f_tmp=$(mktemp -p . -t ".${f}.XXXXXX")
chmod 644 "${f_tmp}" chmod 644 "${f_tmp}"
echo -e "${header}" >"${f_tmp}" echo -e "${header}" >"${f_tmp}"
echo -e "${variant_path} ${size}" >>"${f_tmp}" echo -e "${variant_path} ${size}" >>"${f_tmp}"
[[ ${variant_path} =~ tar.*$ ]] && echo -e "${variant_path} ${size}" >>"${OUT_STAGE3}" # FIXME: tempfile [[ ${variant_path} =~ tar.*$ ]] && echo -e "${variant_path} ${size}" >>"${OUT_STAGE3_tmp}"
[[ ${variant_path} =~ iso$ ]] && echo -e "${variant_path} ${size}" >>"${OUT_ISO}" # FIXME: tempfile [[ ${variant_path} =~ iso$ ]] && echo -e "${variant_path} ${size}" >>"${OUT_ISO_tmp}"
rm -f "current-$v" rm -f "current-$v"
ln -sf "${variant_path%/*}" "current-$v" ln -sf "${variant_path%/*}" "current-$v"
# Update keepfile
echo "${variant_path}" | sed -e 's,/.*,,g' -e 's,^,/,g' -e 's,$,$,g' >>"${keepfile_tmp}" echo "${variant_path}" | sed -e 's,/.*,,g' -e 's,^,/,g' -e 's,$,$,g' >>"${keepfile_tmp}"
# Place latest-*txt into place in the base arch dir.
mv -f "${f_tmp}" "${f}" mv -f "${f_tmp}" "${f}"
done done
# Atomic move these files if created.
[[ -n "${OUT_ISO_tmp}" ]] && [[ -f "${OUT_ISO_tmp}" ]] && mv "${OUT_ISO_tmp}" "${OUT_ISO}"
[[ -n "${OUT_STAGE3_tmp}" ]] && [[ -f "${OUT_STAGE3_tmp}" ]] && mv "${OUT_STAGE3_tmp}" "${OUT_STAGE3}"
# Refresh keepfile # Refresh keepfile
mv -f "${keepfile_tmp}" "${keepfile}" mv -f "${keepfile_tmp}" "${keepfile}"