mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
fetcher2: retry mirror if upstream checksum mismatch
This patch is for [YOCTO #1085] fix. If the upstream fails a checksum, retry from the MIRROR before giving up. This will add more robust fetching if an upstream serves a bad file or webpage. fetching of distcc prior to the move from samba -> googlecode is a good example of this. (Bitbake rev: b631e922257de52bf2247c01152d9856c870e7d0) Signed-off-by: Yu Ke <ke.yu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -300,6 +300,22 @@ def verify_checksum(u, ud, d):
|
|||||||
if ud.sha256_expected != sha256data:
|
if ud.sha256_expected != sha256data:
|
||||||
raise SHA256SumError(ud.localpath, ud.sha256_expected, sha256data, u)
|
raise SHA256SumError(ud.localpath, ud.sha256_expected, sha256data, u)
|
||||||
|
|
||||||
|
def update_stamp(u, ud, d):
|
||||||
|
"""
|
||||||
|
donestamp is file stamp indicating the whole fetching is done
|
||||||
|
this function update the stamp after verifying the checksum
|
||||||
|
"""
|
||||||
|
if os.path.exists(ud.donestamp):
|
||||||
|
# Touch the done stamp file to show active use of the download
|
||||||
|
try:
|
||||||
|
os.utime(ud.donestamp, None)
|
||||||
|
except:
|
||||||
|
# Errors aren't fatal here
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
verify_checksum(u, ud, d)
|
||||||
|
open(ud.donestamp, 'w').close()
|
||||||
|
|
||||||
def subprocess_setup():
|
def subprocess_setup():
|
||||||
import signal
|
import signal
|
||||||
# Python installs a SIGPIPE handler by default. This is usually not what
|
# Python installs a SIGPIPE handler by default. This is usually not what
|
||||||
@@ -932,6 +948,9 @@ class Fetch(object):
|
|||||||
if hasattr(m, "build_mirror_data"):
|
if hasattr(m, "build_mirror_data"):
|
||||||
m.build_mirror_data(u, ud, self.d)
|
m.build_mirror_data(u, ud, self.d)
|
||||||
localpath = ud.localpath
|
localpath = ud.localpath
|
||||||
|
# early checksum verify, so that if checksum mismatched,
|
||||||
|
# fetcher still have chance to fetch from mirror
|
||||||
|
update_stamp(u, ud, self.d)
|
||||||
|
|
||||||
except bb.fetch2.NetworkAccess:
|
except bb.fetch2.NetworkAccess:
|
||||||
raise
|
raise
|
||||||
@@ -948,17 +967,7 @@ class Fetch(object):
|
|||||||
if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1):
|
if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1):
|
||||||
raise FetchError("Unable to fetch URL %s from any source." % u, u)
|
raise FetchError("Unable to fetch URL %s from any source." % u, u)
|
||||||
|
|
||||||
if os.path.exists(ud.donestamp):
|
update_stamp(u, ud, self.d)
|
||||||
# Touch the done stamp file to show active use of the download
|
|
||||||
try:
|
|
||||||
os.utime(ud.donestamp, None)
|
|
||||||
except:
|
|
||||||
# Errors aren't fatal here
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Only check the checksums if we've not seen this item before, then create the stamp
|
|
||||||
verify_checksum(u, ud, self.d)
|
|
||||||
open(ud.donestamp, 'w').close()
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
bb.utils.unlockfile(lf)
|
bb.utils.unlockfile(lf)
|
||||||
|
|||||||
Reference in New Issue
Block a user