From: Paul Eggleton Date: Wed, 30 May 2012 16:17:17 +0000 (+0100) Subject: lib/bb/fetch2: ignore remote URIs when doing file checksums X-Git-Tag: rev_ivi_2015_02_04~17037 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97b227a7a53b8fcb8bfa963debb9482c15d3d908;p=scm%2Fbb%2Ftizen-distro.git lib/bb/fetch2: ignore remote URIs when doing file checksums Skip evaluating remote URIs when doing local file checksums, because we don't need to process them and doing so will trigger a parse failure if SRCREV is not fully specified. Whilst this is just delaying a check until runtime (when do_fetch runs for the recipe) we're only validating this here accidentally and if we did wish to check it during parsing it ought to be done explicitly. Fixes [YOCTO #2512] (Bitbake rev: 99feb77c2de707f2d825566cf48371c48f450e3e) Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 6ae69cd..83050e4 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -112,6 +112,9 @@ class NetworkAccess(BBFetchException): BBFetchException.__init__(self, msg) self.args = (url, cmd) +class NonLocalMethod(Exception): + def __init__(self): + Exception.__init__(self) def decodeurl(url): """Decodes an URL into the tokens (scheme, network location, path, @@ -565,17 +568,17 @@ def srcrev_internal_helper(ud, d, name): def get_checksum_file_list(d): """ Get a list of files checksum in SRC_URI - Returns the all resolved local path of all local file entries in + Returns the resolved local paths of all local file entries in SRC_URI as a space-separated string """ - fetch = Fetch([], d) + fetch = Fetch([], d, cache = False, localonly = True) dl_dir = d.getVar('DL_DIR', True) filelist = [] for u in fetch.urls: ud = fetch.ud[u] - if isinstance(ud.method, local.Local): + if ud and isinstance(ud.method, local.Local): ud.setup_localpath(d) f = ud.localpath if f.startswith(dl_dir): @@ -639,7 +642,7 @@ class FetchData(object): """ A class which represents the fetcher state for a given URI. """ - def __init__(self, url, d): + def __init__(self, url, d, localonly = False): # localpath is the location of a downloaded result. If not set, the file is local. self.donestamp = None self.localfile = "" @@ -686,6 +689,9 @@ class FetchData(object): if not self.method: raise NoMethodError(url) + if localonly and not isinstance(self.method, local.Local): + raise NonLocalMethod() + if hasattr(self.method, "urldata_init"): self.method.urldata_init(self, d) @@ -1009,7 +1015,10 @@ class FetchMethod(object): return "%s-%s" % (key, d.getVar("PN", True) or "") class Fetch(object): - def __init__(self, urls, d, cache = True): + def __init__(self, urls, d, cache = True, localonly = False): + if localonly and cache: + raise Exception("bb.fetch2.Fetch.__init__: cannot set cache and localonly at same time") + if len(urls) == 0: urls = d.getVar("SRC_URI", True).split() self.urls = urls @@ -1022,7 +1031,12 @@ class Fetch(object): for url in urls: if url not in self.ud: - self.ud[url] = FetchData(url, d) + try: + self.ud[url] = FetchData(url, d, localonly) + except NonLocalMethod: + if localonly: + self.ud[url] = None + pass if cache: urldata_cache[fn] = self.ud