Skip to content

Commit

Permalink
[build] Fix reproducible build version issue when failed to download …
Browse files Browse the repository at this point in the history
…web file (sonic-net#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
  • Loading branch information
liushilongbuaa authored Apr 11, 2023
1 parent 0df155b commit 3d32008
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/sonic-build-hooks/scripts/buildinfo_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ set_reproducible_mirrors()
download_packages()
{
local parameters=("$@")
local filenames=
declare -A filenames
for (( i=0; i<${#parameters[@]}; i++ ))
do
Expand All @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 3d32008

Please sign in to comment.