]> code.ossystems Code Review - openembedded-core.git/commitdiff
bb.fetch2: add "BB_NO_NETWORK" option
authorYu Ke <ke.yu@intel.com>
Mon, 24 Jan 2011 06:58:26 +0000 (14:58 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 25 Jan 2011 12:32:49 +0000 (12:32 +0000)
Sometime user want a purely local fetching, i.e. using local mirror without
any remote netowrk access. BB_NO_NETWORK option is introduced for this purpose

check_network_access() is the guard for BB_NO_NETWOKR option. it should be
put in any place that fetcher use network access

Signed-off-by: Yu Ke <ke.yu@intel.com>
bitbake/lib/bb/fetch2/__init__.py

index 886d49afa2eaaa69e48269a363f88f8285ceb6ea..9fe4eb2c025962eb38ec4d78fc9230973970863f 100644 (file)
@@ -469,6 +469,16 @@ def runfetchcmd(cmd, d, quiet = False):
 
     return output
 
+def check_network_access(d, info = ""):
+    """
+    log remote network access, and error if BB_NO_NETWORK is set
+    """
+    if bb.data.getVar("BB_NO_NETWORK", d, True) == "1":
+        bb.error("BB_NO_NETWORK is set, but the fetcher code attempted network access with the command %s" % info)
+        raise FetchError("BB_NO_NETWORK violation")
+    else:
+        bb.note("Fetcher accessed the network with the command %s" % info)
+
 def try_mirrors(d, uri, mirrors, check = False, force = False):
     """
     Try to use a mirrored version of the sources.