From ec54c2e5defab9614c83f0dc34545e2f26e3ebe6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 20 Nov 2024 06:59:34 -0500 Subject: [PATCH] ci: Reduce redundant commands in run.sh (backport ) (cherry picked from commit c90236b5289b6ec48d926a23204cc01b14a749e1) --- ci/run.sh | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index f4fef82fcdc2d..22b356a6425b1 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -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.