From 8f66b613aaa38124b758ef85b3d1694f04d401fe Mon Sep 17 00:00:00 2001 From: Jianping Liu Date: Tue, 25 Feb 2025 20:04:01 +0800 Subject: [PATCH] dist,copy-drivers: exit 1 if download driver fail For easy to debug "make dist-rpm" error or koji task error, exit 1 if download driver fail. BTW, try to download driver 3 times. Signed-off-by: Jianping Liu Reviewed-by: Yongliang Gao --- dist/sources/download-and-copy-drivers.sh | 20 +++++++++++++------- drivers/thirdparty/copy-drivers.sh | 2 ++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dist/sources/download-and-copy-drivers.sh b/dist/sources/download-and-copy-drivers.sh index 5fd7f5fa8898..311a72f96ddd 100755 --- a/dist/sources/download-and-copy-drivers.sh +++ b/dist/sources/download-and-copy-drivers.sh @@ -17,7 +17,7 @@ check_url_reachable() mlnx_tgz_url=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh backup_url) curl -I $mlnx_tgz_url 1>/dev/null 2>&1 if (( $? != 0 )); then - echo "Could not download ${mlnx_tgz_name} !" + echo "Could not download ${mlnx_tgz_name} ! URL can't reachable!" exit 1 fi } @@ -25,13 +25,13 @@ check_url_reachable() thirdparty_mlnx(){ get_mlnx_tgz_ok=1 - # Real MLNX_OFED_LINUX-*.tgz will more than 1024 bytes. - # Dummy MLNX_OFED_LINUX-*.tgz will less than 1024 bytes. - if [ $(stat -c%s ${mlnx_tgz_name}) -lt 1024 ]; then + sha256_tmp=$(sha256sum ${mlnx_tgz_name} | awk '{printf $1}') + if [[ $sha256_tmp != $mlnx_tgz_sha256 ]]; then rm -f ${mlnx_tgz_name} timeout 900 wget -q $mlnx_tgz_url || get_mlnx_tgz_ok=0 fi + ## Check the mlnx_tgz which just downloaded. sha256_tmp=$(sha256sum ${mlnx_tgz_name} | awk '{printf $1}') if [[ $sha256_tmp != $mlnx_tgz_sha256 ]]; then get_mlnx_tgz_ok=0; fi @@ -44,8 +44,14 @@ thirdparty_mlnx(){ ## ## main , script start run at here. ## -check_url_reachable +max_attempts=3 -thirdparty_mlnx +for attempt in {1..$max_attempts}; do + check_url_reachable + thirdparty_mlnx -echo "Having downloaded thirdparty drivers." + if (( $? == 0 )); then + echo "Having downloaded thirdparty drivers." + break + fi +done diff --git a/drivers/thirdparty/copy-drivers.sh b/drivers/thirdparty/copy-drivers.sh index 601f223ec7fa..dd0b7050dbd8 100755 --- a/drivers/thirdparty/copy-drivers.sh +++ b/drivers/thirdparty/copy-drivers.sh @@ -6,12 +6,14 @@ thirdparty_mlnx(){ if [ ! -e release-drivers/mlnx/${mlnx_tgz_name} ] ; then ./download-and-copy-drivers.sh + if (( $? != 0 )) ; then exit 1 ; fi mv ${mlnx_tgz_name} release-drivers/mlnx/ else sha256_tmp=$(sha256sum release-drivers/mlnx/${mlnx_tgz_name} | awk '{printf $1}') if [[ $sha256_tmp != $mlnx_tgz_sha256 ]]; then echo "Warning: release-drivers/mlnx/${mlnx_tgz_name} is exist, but sha256sum is not correct!" ./download-and-copy-drivers.sh + if (( $? != 0 )) ; then exit 1 ; fi mv ${mlnx_tgz_name} release-drivers/mlnx/ fi fi