From 421a0fa541bb8b4508854b5e00532a02b28d73ea Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 8 May 2019 23:38:12 +0200 Subject: [PATCH] fail early when lates build information can not be fetched When the mirror returns a error, it was trying to interpret the error message (e.g. Internal server error..) as a download link. By using -f on curl we get an empty reply and an exit code, which, as we run in set -e mode, aborts. Change-Id: Ibaa39aedb7db286f859c4b090114c6a233b150c7 --- diskimage_builder/elements/gentoo/root.d/10-gentoo-image | 2 +- diskimage_builder/elements/hpdsa/pre-install.d/06-hpdsa | 2 +- .../source-repositories/extra-data.d/98-source-repositories | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/diskimage_builder/elements/gentoo/root.d/10-gentoo-image b/diskimage_builder/elements/gentoo/root.d/10-gentoo-image index b9c02c71..a278695d 100755 --- a/diskimage_builder/elements/gentoo/root.d/10-gentoo-image +++ b/diskimage_builder/elements/gentoo/root.d/10-gentoo-image @@ -65,7 +65,7 @@ else fi DIB_CLOUD_SOURCE=${DIB_CLOUD_SOURCE:-"http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage4-amd64-${SIGNED_SOURCE_SUFFIX}.txt"} -BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-"http://distfiles.gentoo.org/releases/amd64/autobuilds/$(curl ${DIB_CLOUD_SOURCE} -s | tail -n 1 | cut -d\ -f 1)"} +BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-"http://distfiles.gentoo.org/releases/amd64/autobuilds/$(curl ${DIB_CLOUD_SOURCE} -s -f | tail -n 1 | cut -d\ -f 1)"} BASE_IMAGE_FILE_SUFFIX=${BASE_IMAGE_FILE_SUFFIX:-"$(basename ${BASE_IMAGE_FILE} | cut -d. -f 2,3)"} SIGNATURE_FILE="${SIGNATURE_FILE:-${BASE_IMAGE_FILE}.DIGESTS.asc}" CACHED_FILE="${DIB_IMAGE_CACHE}/${FILENAME_BASE}.${BASE_IMAGE_FILE_SUFFIX}" diff --git a/diskimage_builder/elements/hpdsa/pre-install.d/06-hpdsa b/diskimage_builder/elements/hpdsa/pre-install.d/06-hpdsa index 3dd923b8..42baa3eb 100755 --- a/diskimage_builder/elements/hpdsa/pre-install.d/06-hpdsa +++ b/diskimage_builder/elements/hpdsa/pre-install.d/06-hpdsa @@ -11,4 +11,4 @@ echo 'deb https://downloads.linux.hp.com/SDR/repo/ubuntu-hpdsa' $DIB_RELEASE ' m >> /etc/apt/sources.list.d/ubuntu-hpdsa.list # Add the key -curl https://downloads.linux.hp.com/SDR/hpPublicKey2048_key1.pub | apt-key add - +curl -f -s https://downloads.linux.hp.com/SDR/hpPublicKey2048_key1.pub | apt-key add - diff --git a/diskimage_builder/elements/source-repositories/extra-data.d/98-source-repositories b/diskimage_builder/elements/source-repositories/extra-data.d/98-source-repositories index 87086810..16df6a93 100755 --- a/diskimage_builder/elements/source-repositories/extra-data.d/98-source-repositories +++ b/diskimage_builder/elements/source-repositories/extra-data.d/98-source-repositories @@ -201,7 +201,7 @@ function get_repos_for_element(){ tar -C $tmpdir -xzf $CACHE_PATH else echo "Fetching $REPONAME tarball from $REPOLOCATION" - curl $REPOLOCATION | tar -C $tmpdir -xzf - + curl -f $REPOLOCATION | tar -C $tmpdir -xzf - fi sudo mkdir -p $REPO_DEST @@ -223,7 +223,7 @@ function get_repos_for_element(){ sudo cp $CACHE_PATH $REPO_DEST else echo "Fetching $REPONAME file from $REPOLOCATION" - sudo curl $REPOLOCATION -o $REPO_DEST + sudo curl -f $REPOLOCATION -o $REPO_DEST fi ;; *)