[build] Fix reproducible build version issue when failed to download web file (#14587)

Why I did it
refine reproducible build.

How I did it
Fix reset map variable in bash.
Ignore empty web file md5sum value.
If web file didn't backup in azure storage, use file on web.
How to verify i
This commit is contained in:
Liu Shilong 2023-04-11 10:47:30 +08:00 committed by GitHub
parent 0df155b014
commit 3d32008e49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,7 +151,6 @@ set_reproducible_mirrors()
download_packages()
{
local parameters=("$@")
local filenames=
declare -A filenames
for (( i=0; i<${#parameters[@]}; i++ ))
do
@ -171,7 +170,7 @@ download_packages()
local filename=$(echo $url | awk -F"/" '{print $NF}' | cut -d? -f1 | cut -d# -f1)
[ -f $WEB_VERSION_FILE ] && version=$(grep "^${url}=" $WEB_VERSION_FILE | awk -F"==" '{print $NF}')
if [ -z "$version" ]; then
log_err "Warning: Failed to verify the package: $url, the version is not specified" 1>&2
log_err "Warning: Failed to verify the package: $url, the version is not specified"
continue
fi
@ -185,15 +184,16 @@ download_packages()
else
real_version=$(get_url_version $url) || { echo "get_url_version $url failed"; exit 1; }
if [ "$real_version" != "$version" ]; then
log_err "Failed to verify url: $url, real hash value: $real_version, expected value: $version_filename" 1>&2
exit 1
log_err "Warning: Failed to verify url: $url, real hash value: $real_version, expected value: $version_filename"
continue
fi
fi
else
real_version=$(get_url_version $url) || { echo "get_url_version $url failed"; exit 1; }
fi
echo "$url==$real_version" >> ${BUILD_WEB_VERSION_FILE}
# ignore md5sum for string ""
# echo -n "" | md5sum == d41d8cd98f00b204e9800998ecf8427e
[[ $real_version == "d41d8cd98f00b204e9800998ecf8427e" ]] || echo "$url==$real_version" >> ${BUILD_WEB_VERSION_FILE}
fi
done