fix(pkg-cache): no | while read pipelines under pipefail (Shell-Checks) #32
@@ -83,13 +83,17 @@ created() { printf '%s\n' "$1" >> "$STATE/created"; }
|
|||||||
if [ "$MODE" = restore ]; then
|
if [ "$MODE" = restore ]; then
|
||||||
[ -d "$STATE" ] || exit 0
|
[ -d "$STATE" ] || exit 0
|
||||||
host=$(cat "$STATE/host")
|
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#./}"
|
cat "$STATE/orig/$rel" > "/${rel#./}"
|
||||||
done
|
done
|
||||||
while read -r f; do [ -n "$f" ] && rm -f -- "$f"; done < "$STATE/created"
|
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
|
# 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.
|
# (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
|
if ! grep -qxF -- "$f" "$STATE/manifest" && grep -qF -- "$host" "$f"; then
|
||||||
echo "pkg-cache-repos: removing new file that references the cache: $f"
|
echo "pkg-cache-repos: removing new file that references the cache: $f"
|
||||||
rm -f -- "$f"
|
rm -f -- "$f"
|
||||||
|
|||||||
Reference in new issue
Block a user