summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index e9a64c57c0..d39f094551 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -300,6 +300,22 @@ def verify_checksum(u, ud, d):
300 if ud.sha256_expected != sha256data: 300 if ud.sha256_expected != sha256data:
301 raise SHA256SumError(ud.localpath, ud.sha256_expected, sha256data, u) 301 raise SHA256SumError(ud.localpath, ud.sha256_expected, sha256data, u)
302 302
303def update_stamp(u, ud, d):
304 """
305 donestamp is file stamp indicating the whole fetching is done
306 this function update the stamp after verifying the checksum
307 """
308 if os.path.exists(ud.donestamp):
309 # Touch the done stamp file to show active use of the download
310 try:
311 os.utime(ud.donestamp, None)
312 except:
313 # Errors aren't fatal here
314 pass
315 else:
316 verify_checksum(u, ud, d)
317 open(ud.donestamp, 'w').close()
318
303def subprocess_setup(): 319def subprocess_setup():
304 import signal 320 import signal
305 # Python installs a SIGPIPE handler by default. This is usually not what 321 # Python installs a SIGPIPE handler by default. This is usually not what
@@ -932,6 +948,9 @@ class Fetch(object):
932 if hasattr(m, "build_mirror_data"): 948 if hasattr(m, "build_mirror_data"):
933 m.build_mirror_data(u, ud, self.d) 949 m.build_mirror_data(u, ud, self.d)
934 localpath = ud.localpath 950 localpath = ud.localpath
951 # early checksum verify, so that if checksum mismatched,
952 # fetcher still have chance to fetch from mirror
953 update_stamp(u, ud, self.d)
935 954
936 except bb.fetch2.NetworkAccess: 955 except bb.fetch2.NetworkAccess:
937 raise 956 raise
@@ -948,17 +967,7 @@ class Fetch(object):
948 if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1): 967 if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1):
949 raise FetchError("Unable to fetch URL %s from any source." % u, u) 968 raise FetchError("Unable to fetch URL %s from any source." % u, u)
950 969
951 if os.path.exists(ud.donestamp): 970 update_stamp(u, ud, self.d)
952 # Touch the done stamp file to show active use of the download
953 try:
954 os.utime(ud.donestamp, None)
955 except:
956 # Errors aren't fatal here
957 pass
958 else:
959 # Only check the checksums if we've not seen this item before, then create the stamp
960 verify_checksum(u, ud, self.d)
961 open(ud.donestamp, 'w').close()
962 971
963 finally: 972 finally:
964 bb.utils.unlockfile(lf) 973 bb.utils.unlockfile(lf)