Skip to content

Commit

Permalink
testing: accommodate zstd compression in Arch bootstrap archives
Browse files Browse the repository at this point in the history
  • Loading branch information
ahesford committed May 15, 2024
1 parent 9a6e7dc commit 558cff4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions testing/helpers/extract_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ cleanup() {
exit
}

untar() {
local fname="${1?a file name is required}"
shift

case "${fname}" in
*.zstd|*.zst)
zstdcat "${fname}" | tar -x -f - "$@"
;;
*)
tar -x -f "${fname}" "$@"
;;
esac
}

REMOTE_URL="${1?A remote URL is required}"
TARGET_DIR="${2?A target directory is required}"

Expand Down Expand Up @@ -53,7 +67,7 @@ if [ -d "${CACHEDIR}" ]; then

# If the file is already cached, just extract it if possible
if [ -r "${CACHEDIR}/fetch/${FILENAME}" ]; then
if ! tar xf "${CACHEDIR}/fetch/${FILENAME}" -C "${TARGET_DIR}"; then
if ! untar "${CACHEDIR}/fetch/${FILENAME}" -C "${TARGET_DIR}"; then
echo "ERROR: extraction of cached file '${CACHEDIR}/fetch/${FILENAME}' failed"
else
exit 0
Expand All @@ -75,7 +89,7 @@ if ! curl -L -s -o "${FETCH_DIR}/${FILENAME}" "${REMOTE_URL}"; then
exit 1
fi

if ! tar xf "${FETCH_DIR}/${FILENAME}" -C "${TARGET_DIR}"; then
if ! untar "${FETCH_DIR}/${FILENAME}" -C "${TARGET_DIR}"; then
echo "ERROR: extraction of fetched file '${REMOTE_URL}' failed"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion testing/helpers/install-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fi
trap cleanup EXIT INT TERM

MIRROR="https://mirrors.edge.kernel.org/archlinux/iso/latest"
PATTERN="archlinux-bootstrap-[-_.A-Za-z0-9]\+-x86_64\.tar\.gz"
PATTERN="archlinux-bootstrap-[-_.A-Za-z0-9]\+-x86_64\.tar\.zst"
if ! ./helpers/extract_remote.sh "${MIRROR}" "${PACROOT}" "${PATTERN}"; then
echo "ERROR: could not fetch and extract Arch bootstrap image"
exit 1
Expand Down

0 comments on commit 558cff4

Please sign in to comment.