dist: try to download mlnx driver from backup_url

If download mlnx driver fail from https://content.mellanox.com, try
to download mlnx driver from backup_url.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
This commit is contained in:
Jianping Liu 2024-09-20 18:58:22 +08:00
parent 31301ee3f1
commit 8ebfc08eb9
1 changed files with 16 additions and 19 deletions

View File

@ -1,23 +1,28 @@
#!/bin/bash
# This script may run at dist/sources/ directory or drivers/thirdparty/ directory.
# "make dist-srpm" will run dist-drivers in dist/Makefile, which will cd to dist/sources/ dir
# to run download-and-copy-drivers.sh.
# "make dist-rpm" will run BuildConfig in dist/templates/kernel.template.spec, which will cd
# to drivers/thirdparty/ dir to run download-and-copy-drivers.sh.
mlnx_tgz_url=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_url)
mlnx_tgz_name=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_tgz_name)
mlnx_tgz_sha256=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_tgz_sha256)
check_url_reachable()
{
curl -I https://content.mellanox.com 1>/dev/null 2>&1
curl -I $mlnx_tgz_url 1>/dev/null 2>&1 && return 0
echo "Try to download ${mlnx_tgz_name} from backup_url."
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 reache https://content.mellanox.com"
echo "Could not download ${mlnx_tgz_name} !"
exit 1
fi
}
thirdparty_mlnx(){
# This script may run at dist/sources/ directory or drivers/thirdparty/ directory.
# "make dist-srpm" will run dist-drivers in dist/Makefile, which will cd to dist/sources/ dir
# to run download-and-copy-drivers.sh.
# "make dist-rpm" will run BuildConfig in dist/templates/kernel.template.spec, which will cd
# to drivers/thirdparty/ dir to run download-and-copy-drivers.sh.
mlnx_tgz_url=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_url)
mlnx_tgz_name=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_tgz_name)
mlnx_tgz_sha256=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_tgz_sha256)
get_mlnx_tgz_ok=1
# Real MLNX_OFED_LINUX-*.tgz will more than 1024 bytes.
@ -27,19 +32,11 @@ thirdparty_mlnx(){
timeout 900 wget -q $mlnx_tgz_url || get_mlnx_tgz_ok=0
fi
if (( get_mlnx_tgz_ok == 0 )); then
echo "Getting mlnx driver from ${mlnx_tgz_url} is fail."
echo "Try to get mlnx driver from again from backup url."
rm -f ${mlnx_tgz_name}
mlnx_tgz_url=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh backup_url)
timeout 900 wget -q $mlnx_tgz_url && get_mlnx_tgz_ok=1
fi
sha256_tmp=$(sha256sum ${mlnx_tgz_name} | awk '{printf $1}')
if [[ $sha256_tmp != $mlnx_tgz_sha256 ]]; then get_mlnx_tgz_ok=0; fi
if (( $get_mlnx_tgz_ok == 0 )); then
echo "Download MLNX_OFED_LINUX-*.tgz fail!"
echo "Download ${mlnx_tgz_name} fail!"
exit 1
fi
}