Skip to content

Commit

Permalink
ci: Reduce redundant commands in run.sh
Browse files Browse the repository at this point in the history
(backport <rust-lang#4124>)
(cherry picked from commit c90236b)
  • Loading branch information
tgross35 committed Nov 20, 2024
1 parent 36ce4a0 commit ec54c2e
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,21 @@ if [ -n "${QEMU:-}" ]; then

if [ -z "${QEMU#*.gz}" ]; then
# image is .gz : download and uncompress it
qemufile="$(echo "${QEMU%.gz}" | sed 's/\//__/g')"
if [ ! -f "${tmpdir}/${qemufile}" ]; then
curl --retry 5 "${mirrors_url}/${QEMU}" |
gunzip -d > "${tmpdir}/${qemufile}"
fi
base_file="${QEMU%.gz}"
pipe_cmd="gunzip -d"
elif [ -z "${QEMU#*.xz}" ]; then
# image is .xz : download and uncompress it
qemufile="$(echo "${QEMU%.xz}" | sed 's/\//__/g')"
if [ ! -f "${tmpdir}/${qemufile}" ]; then
curl --retry 5 "${mirrors_url}/${QEMU}" |
unxz > "${tmpdir}/${qemufile}"
fi
base_file="${QEMU%.xz}"
pipe_cmd="unxz"
else
# plain qcow2 image: just download it
qemufile="$(echo "${QEMU}" | sed 's/\//__/g')"
if [ ! -f "${tmpdir}/${qemufile}" ]; then
curl --retry 5 "${mirrors_url}/${QEMU}" \
> "${tmpdir}/${qemufile}"
fi
base_file="$QEMU"
pipe_cmd="cat" # nop to forward the result
fi

qemufile="$(echo "$base_file" | sed 's/\//__/g')"
if [ ! -f "${tmpdir}/${qemufile}" ]; then
curl --retry 5 "${mirrors_url}/${QEMU}" | $pipe_cmd > "${tmpdir}/${qemufile}"
fi

# Create a mount a fresh new filesystem image that we'll later pass to QEMU.
Expand Down

0 comments on commit ec54c2e

Please sign in to comment.