summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index bc1824b01b..d8bee063e7 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -117,6 +117,16 @@ class SHA256SumError(MD5SumError):
117 BBFetchException.__init__(self, msg) 117 BBFetchException.__init__(self, msg)
118 self.args = (path, wanted, got, url) 118 self.args = (path, wanted, got, url)
119 119
120class NetworkAccess(BBFetchException):
121 """Exception raised when network access is disabled but it is required."""
122 def __init__(self, url, cmd):
123 msg = "Network access disabled through BB_NO_NETWORK but access rquested with command %s (for url %s)" % (cmd, url)
124 self.url = url
125 self.cmd = cmd
126 BBFetchException.__init__(self, msg)
127 self.args = (url, cmd)
128
129
120def decodeurl(url): 130def decodeurl(url):
121 """Decodes an URL into the tokens (scheme, network location, path, 131 """Decodes an URL into the tokens (scheme, network location, path,
122 user, password, parameters). 132 user, password, parameters).
@@ -398,12 +408,12 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []):
398 408
399 return output 409 return output
400 410
401def check_network_access(d, info = ""): 411def check_network_access(d, info = "", url = None):
402 """ 412 """
403 log remote network access, and error if BB_NO_NETWORK is set 413 log remote network access, and error if BB_NO_NETWORK is set
404 """ 414 """
405 if bb.data.getVar("BB_NO_NETWORK", d, True) == "1": 415 if bb.data.getVar("BB_NO_NETWORK", d, True) == "1":
406 raise FetchError("BB_NO_NETWORK is set, but the fetcher code attempted network access with the command %s" % info) 416 raise NetworkAccess(url, info)
407 else: 417 else:
408 logger.debug(1, "Fetcher accessed the network with the command %s" % info) 418 logger.debug(1, "Fetcher accessed the network with the command %s" % info)
409 419
@@ -459,6 +469,9 @@ def try_mirrors(d, origud, mirrors, check = False):
459 os.symlink(ud.localpath, origud.localpath) 469 os.symlink(ud.localpath, origud.localpath)
460 return ud.localpath 470 return ud.localpath
461 471
472 except bb.fetch2.NetworkAccess:
473 raise
474
462 except bb.fetch2.BBFetchException as e: 475 except bb.fetch2.BBFetchException as e:
463 logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) 476 logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url))
464 logger.debug(1, str(e)) 477 logger.debug(1, str(e))
@@ -909,6 +922,9 @@ class Fetch(object):
909 m.build_mirror_data(u, ud, self.d) 922 m.build_mirror_data(u, ud, self.d)
910 localpath = ud.localpath 923 localpath = ud.localpath
911 924
925 except bb.fetch2.NetworkAccess:
926 raise
927
912 except BBFetchException as e: 928 except BBFetchException as e:
913 logger.debug(1, str(e)) 929 logger.debug(1, str(e))
914 # Remove any incomplete fetch 930 # Remove any incomplete fetch