diff options
| author | Yu Ke <ke.yu@intel.com> | 2011-07-13 17:08:39 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-07-13 12:13:10 +0100 |
| commit | bf8735f83b3ad2e7366205cfb00625c335a4f910 (patch) | |
| tree | 7381b205c88bce874092a5df8944990ecfe9b40e | |
| parent | d5651cbea300633c78daa753a8ed13a83c4225e5 (diff) | |
| download | poky-bf8735f83b3ad2e7366205cfb00625c335a4f910.tar.gz | |
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>
| -rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 31 |
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 | ||
| 303 | def 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 | |||
| 303 | def subprocess_setup(): | 319 | def 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) |
