@@ -144,18 +144,21 @@ DownloadOrCopyNonUniqueFilename() {
144144 # does not.
145145 local url=" $1 "
146146 local dest=" $2 "
147+ local force=" ${3:- 0} "
147148
148149 local hash=" $( echo " $url " | sha256sum | cut -d' ' -f1) "
149150
150- DownloadOrCopy " ${url} " " ${dest} .${hash} "
151+ DownloadOrCopy " ${url} " " ${dest} .${hash} " " ${force} "
151152 # cp the file to prevent having to redownload it, but mv it to the
152153 # final location so that it's atomic.
153154 cp " ${dest} .${hash} " " ${dest} .$$ "
154155 mv " ${dest} .$$ " " ${dest} "
155156}
156157
157158DownloadOrCopy () {
158- if [ -f " $2 " ] ; then
159+ local force=" ${3:- 0} "
160+
161+ if [ $force -eq 0 ] && [ -f " $2 " ] ; then
159162 echo " $2 already in place"
160163 return
161164 fi
@@ -296,7 +299,21 @@ GeneratePackageListDistRepo() {
296299 local package_list_arch=" ${repo_basedir} /${package_file_arch} "
297300
298301 DownloadOrCopyNonUniqueFilename " ${package_list_arch} " " ${package_list} "
299- VerifyPackageListing " ${package_file_arch} " " ${package_list} " ${repo} ${dist}
302+
303+ for i in {1..5}; do
304+ if VerifyPackageListing " ${package_file_arch} " " ${package_list} " ${repo} ${dist} ; then
305+ break
306+ fi
307+
308+ if [ $i -eq 5 ]; then
309+ echo " sha256sum: ERROR: computed checksum did NOT match, exceeded max number of attempts"
310+ exit 1
311+ fi
312+
313+ echo " sha256sum: WARNING: computed checksum did NOT match, retrying..."
314+ DownloadOrCopyNonUniqueFilename " ${package_list_arch} " " ${package_list} " 1
315+ done
316+
300317 ExtractPackageXz " ${package_list} " " ${tmp_package_list} " ${repo}
301318 cat " ${tmp_package_list} " | ./merge-package-lists.py " ${list_base} "
302319}
@@ -401,14 +418,33 @@ InstallIntoSysroot() {
401418 exit 1
402419 fi
403420
404- Banner " Installing $( basename ${file} ) "
405- DownloadOrCopy ${file} ${package}
406- if [ ! -s " ${package} " ] ; then
407- echo
408- echo " ERROR: bad package ${package} "
409- exit 1
410- fi
411- echo " ${sha256sum} ${package} " | sha256sum --quiet -c
421+ for i in {1..5}; do
422+ Banner " Installing $( basename ${file} ) "
423+ DownloadOrCopy ${file} ${package}
424+ if [ ! -s " ${package} " ] ; then
425+ echo
426+ echo " ERROR: bad package ${package} "
427+ exit 1
428+ fi
429+
430+ sha256sum_comp=($( sha256sum ${package} ) )
431+
432+ if [ " $sha256sum_comp " = " $sha256sum " ]; then
433+ break
434+ fi
435+
436+ echo ${output_file}
437+ echo expected: ${sha256sum}
438+ echo computed: ${sha256sum_comp}
439+
440+ if [ $i -eq 5 ]; then
441+ echo " sha256sum: ERROR: computed checksum did NOT match, exceeded max number of attempts"
442+ exit 1
443+ fi
444+
445+ echo " sha256sum: WARNING: computed checksum did NOT match, retrying..."
446+ rm ${package}
447+ done
412448
413449 SubBanner " Extracting to ${INSTALL_ROOT} "
414450 dpkg-deb -x ${package} ${INSTALL_ROOT}
@@ -551,7 +587,17 @@ VerifyPackageListing() {
551587 exit 1
552588 fi
553589
554- echo " ${sha256sum} ${output_file} " | sha256sum --quiet -c
590+ sha256sum_comp=($( sha256sum ${output_file} ) )
591+
592+ if [ " $sha256sum_comp " = " $sha256sum " ]; then
593+ return 0
594+ fi
595+
596+ echo ${output_file}
597+ echo expected: ${sha256sum}
598+ echo computed: ${sha256sum_comp}
599+
600+ return 1
555601}
556602
557603#
0 commit comments