@@ -21,25 +21,21 @@ if [ -n "${QEMU:-}" ]; then
21
21
22
22
if [ -z " ${QEMU#* .gz} " ]; then
23
23
# image is .gz : download and uncompress it
24
- qemufile=" $( echo " ${QEMU% .gz} " | sed ' s/\//__/g' ) "
25
- if [ ! -f " ${tmpdir} /${qemufile} " ]; then
26
- curl --retry 5 " ${mirrors_url} /${QEMU} " |
27
- gunzip -d > " ${tmpdir} /${qemufile} "
28
- fi
24
+ base_file=" ${QEMU% .gz} "
25
+ pipe_cmd=" gunzip -d"
29
26
elif [ -z " ${QEMU#* .xz} " ]; then
30
27
# image is .xz : download and uncompress it
31
- qemufile=" $( echo " ${QEMU% .xz} " | sed ' s/\//__/g' ) "
32
- if [ ! -f " ${tmpdir} /${qemufile} " ]; then
33
- curl --retry 5 " ${mirrors_url} /${QEMU} " |
34
- unxz > " ${tmpdir} /${qemufile} "
35
- fi
28
+ base_file=" ${QEMU% .xz} "
29
+ pipe_cmd=" unxz"
36
30
else
37
31
# plain qcow2 image: just download it
38
- qemufile=" $( echo " ${QEMU} " | sed ' s/\//__/g' ) "
39
- if [ ! -f " ${tmpdir} /${qemufile} " ]; then
40
- curl --retry 5 " ${mirrors_url} /${QEMU} " \
41
- > " ${tmpdir} /${qemufile} "
42
- fi
32
+ base_file=" $QEMU "
33
+ pipe_cmd=" cat" # nop to forward the result
34
+ fi
35
+
36
+ qemufile=" $( echo " $base_file " | sed ' s/\//__/g' ) "
37
+ if [ ! -f " ${tmpdir} /${qemufile} " ]; then
38
+ curl --retry 5 " ${mirrors_url} /${QEMU} " | $pipe_cmd > " ${tmpdir} /${qemufile} "
43
39
fi
44
40
45
41
# Create a mount a fresh new filesystem image that we'll later pass to QEMU.
0 commit comments