From 03d7f4b95de21ac7651ea4c0462b07f941626b06 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 20:01:30 +0000 Subject: [PATCH] fix: address code review feedback in distribute.sh --- scripts/distribute.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/distribute.sh b/scripts/distribute.sh index d05f379..54b9705 100755 --- a/scripts/distribute.sh +++ b/scripts/distribute.sh @@ -98,7 +98,9 @@ case "${COMMAND}" in CHECKSUM_FILE="${DIST_DIR}/checksums.txt" echo "Generating checksums for ${DIST_DIR}..." - (cd "${DIST_DIR}" && sha256sum -- * > checksums.txt) + # Generate checksums for all files except the checksums file itself. + (cd "${DIST_DIR}" && find . -maxdepth 1 -type f ! -name "checksums.txt" \ + -exec sha256sum {} + | sed 's|\./||' | sort > checksums.txt) echo "Checksums written to ${CHECKSUM_FILE}" cat "${CHECKSUM_FILE}" ;; @@ -140,14 +142,17 @@ case "${COMMAND}" in ############################################################################### reorganize-artifacts) echo "Reorganizing artifacts..." + # Use nullglob so the loop does not run if no directories match. + shopt -s nullglob for artifact_dir in distribute-artifacts/cache-apt-pkgs-*/; do - if [[ ! -d "${artifact_dir}" ]]; then + dir_name="$(basename "${artifact_dir}")" + # Extract arch from the format "cache-apt-pkgs--<8-char-commit-sha>". + # The commit SHA is exactly 8 hex characters at the end. + arch_upper="$(echo "${dir_name}" | sed 's/^cache-apt-pkgs-//; s/-[0-9a-f]\{8\}$//')" + if [[ -z "${arch_upper}" ]]; then + echo "Warning: Could not extract architecture from ${dir_name}, skipping" >&2 continue fi - - dir_name="$(basename "${artifact_dir}")" - # Extract arch: strip prefix "cache-apt-pkgs-" and trailing "-" - arch_upper="$(echo "${dir_name}" | sed 's/^cache-apt-pkgs-//; s/-[^-]*$//')" arch_lower="$(echo "${arch_upper}" | tr '[:upper:]' '[:lower:]')" dest_dir="distribute/${arch_lower}" @@ -155,6 +160,7 @@ case "${COMMAND}" in cp -r "${artifact_dir}"* "${dest_dir}/" echo "Reorganized ${artifact_dir} -> ${dest_dir}" done + shopt -u nullglob echo "Artifact reorganization complete" ;;