diff --git a/scripts/pkg-cache-repos.sh b/scripts/pkg-cache-repos.sh index fb83c55..37580a0 100755 --- a/scripts/pkg-cache-repos.sh +++ b/scripts/pkg-cache-repos.sh @@ -83,13 +83,17 @@ created() { printf '%s\n' "$1" >> "$STATE/created"; } if [ "$MODE" = restore ]; then [ -d "$STATE" ] || exit 0 host=$(cat "$STATE/host") - (cd "$STATE/orig" && find . -type f) | while read -r rel; do + # mapfile from a process substitution, not `cmd | while read`: no pipeline, + # so nothing for pipefail to misreport (scripts/tests/lsphp-info-probe.test.sh). + mapfile -t saved < <(cd "$STATE/orig" && find . -type f) + for rel in "${saved[@]}"; do cat "$STATE/orig/$rel" > "/${rel#./}" done while read -r f; do [ -n "$f" ] && rm -f -- "$f"; done < "$STATE/created" # A repo/apt file that appeared during this RUN and still names the cache # (e.g. written by a package from the rewritten repos) is removed too. - repo_files | while read -r f; do + mapfile -t current < <(repo_files) + for f in "${current[@]}"; do if ! grep -qxF -- "$f" "$STATE/manifest" && grep -qF -- "$host" "$f"; then echo "pkg-cache-repos: removing new file that references the cache: $f" rm -f -- "$f"