Skip to content

Commit a3ceb59

Browse files
committed
Add an error handing logic when qemu-$arch-statis.tar.gz URL is not found.
1 parent 00cd7f9 commit a3ceb59

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

update.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ for to_arch in $to_archs; do
4949
if [ "$from_arch" != "$to_arch" ]; then
5050
work_dir="${out_dir}/${from_arch}_qemu-${to_arch}"
5151
mkdir -p "${work_dir}"
52-
curl -sSL -o "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" \
53-
"https://github.com/${REPO}/releases/download/v${VERSION}/${from_arch}_qemu-${to_arch}-static.tar.gz"
52+
tar_gz_url="https://github.com/${REPO}/releases/download/v${VERSION}/${from_arch}_qemu-${to_arch}-static.tar.gz"
53+
http_status="$(curl -s -o /dev/null -w "%{http_code}" "${tar_gz_url}")"
54+
if [ "${http_status}" = 404 ]; then
55+
echo "URL not found: ${tar_gz_url}" 1>&2
56+
exit 1
57+
fi
58+
curl -sSL -o "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" "${tar_gz_url}"
5459
tar xzvf "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz" -C "${work_dir}"
5560
rm -f "${work_dir}/${from_arch}_qemu-${to_arch}-static.tar.gz"
5661

0 commit comments

Comments
 (0)