diff --git a/.ci/env/apt.sh b/.ci/env/apt.sh index 2665ed9a65d..591c87b4297 100755 --- a/.ci/env/apt.sh +++ b/.ci/env/apt.sh @@ -63,10 +63,31 @@ function install_qemu_emulation_apt { } function install_qemu_emulation_deb { - qemu_deb=qemu-user-static_9.0.1+ds-1~bpo12+1_amd64.deb + set +e + + versions=(9.0.2 9.0.1 8.2.4) + found_version="" + for version in ${versions[@]}; do + qemu_deb="qemu-user-static_${version}+ds-1_amd64.deb" + echo "Checking for http://ftp.debian.org/debian/pool/main/q/qemu/${qemu_deb}" + if wget -q --method=HEAD http://ftp.debian.org/debian/pool/main/q/qemu/${qemu_deb} &> /dev/null; + then + echo "Found qemu version ${version}" + found_version=${qemu_deb} + break + fi + done + set -eo pipefail - wget http://ftp.debian.org/debian/pool/main/q/qemu/${qemu_deb} - sudo dpkg -i ${qemu_deb} + if [[ -z "${found_version}" ]] ; then + # If nothing is found, error out and fail + echo "None of the requested qemu versions ${versions[*]} are available." + false + fi + + wget http://ftp.debian.org/debian/pool/main/q/qemu/${found_version} + sudo dpkg -i ${found_version} + sudo systemctl restart systemd-binfmt.service set +eo pipefail }