From a3ceb5943319b4c09695be51ac146dd3bddddfad Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Mon, 2 Sep 2019 15:13:32 +0200 Subject: [PATCH] Add an error handing logic when qemu-$arch-statis.tar.gz URL is not found. --- update.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index d1304b0..7325791 100755 --- a/update.sh +++ b/update.sh @@ -49,8 +49,13 @@ for to_arch in $to_archs; do if [ "$from_arch" != "$to_arch" ]; then work_dir="${out_dir}/${from_arch}_qemu-${to_arch}" mkdir -p "${work_dir}" - curl -sSL -o "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" \ - "https://github.com/${REPO}/releases/download/v${VERSION}/${from_arch}_qemu-${to_arch}-static.tar.gz" + tar_gz_url="https://github.com/${REPO}/releases/download/v${VERSION}/${from_arch}_qemu-${to_arch}-static.tar.gz" + http_status="$(curl -s -o /dev/null -w "%{http_code}" "${tar_gz_url}")" + if [ "${http_status}" = 404 ]; then + echo "URL not found: ${tar_gz_url}" 1>&2 + exit 1 + fi + curl -sSL -o "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" "${tar_gz_url}" tar xzvf "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" -C "${work_dir}" rm -f "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz"