From 33aa351ac13936fb2549403f18a44fed32b2edfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Tue, 14 Jan 2014 13:56:04 -0500 Subject: [PATCH] download: Fix download_sig logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- templates/lxc-download.in | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/templates/lxc-download.in b/templates/lxc-download.in index fa54686ef..4f28d0c00 100644 --- a/templates/lxc-download.in +++ b/templates/lxc-download.in @@ -73,10 +73,17 @@ download_file() { } download_sig() { - download_file $1 $2 noexit - if [ "$DOWNLOAD_VALIDATE" = "true" ]; then - echo "ERROR: Failed to download http://${DOWNLOAD_SERVER}/$1" 1>&2 - exit 1 + if ! download_file $1 $2 noexit; then + if [ "$DOWNLOAD_VALIDATE" = "true" ]; then + if [ "$3" = "normal" ]; then + echo "ERROR: Failed to download http://${DOWNLOAD_SERVER}/$1" 1>&2 + exit 1 + else + return 1 + fi + else + return 0 + fi fi } @@ -268,11 +275,11 @@ if [ "$DOWNLOAD_USE_CACHE" = "false" ]; then echo "Downloading the image index" if ! download_file ${DOWNLOAD_INDEX_PATH}.${DOWNLOAD_COMPAT_LEVEL} \ ${DOWNLOAD_TEMP}/index noexit || - ! download_file ${DOWNLOAD_INDEX_PATH}.${DOWNLOAD_COMPAT_LEVEL}.asc \ + ! download_sig ${DOWNLOAD_INDEX_PATH}.${DOWNLOAD_COMPAT_LEVEL}.asc \ ${DOWNLOAD_TEMP}/index.asc noexit; then download_file ${DOWNLOAD_INDEX_PATH} ${DOWNLOAD_TEMP}/index normal download_sig ${DOWNLOAD_INDEX_PATH}.asc \ - ${DOWNLOAD_TEMP}/index.asc + ${DOWNLOAD_TEMP}/index.asc normal fi gpg_validate ${DOWNLOAD_TEMP}/index.asc