summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes-global/yocto-check-layer.bbclass30
1 files changed, 30 insertions, 0 deletions
diff --git a/meta/classes-global/yocto-check-layer.bbclass b/meta/classes-global/yocto-check-layer.bbclass
index 92a392af9c..ba93085325 100644
--- a/meta/classes-global/yocto-check-layer.bbclass
+++ b/meta/classes-global/yocto-check-layer.bbclass
@@ -27,6 +27,36 @@ def check_insane_skip(d):
27 d.setVar("QA_ERRORS_FOUND", "True") 27 d.setVar("QA_ERRORS_FOUND", "True")
28 28
29 29
30# Check that no tasks (with rare exceptions) between do_fetch and do_build
31# use the network.
32def check_network_flag(d):
33 # BPN:task names that are allowed to reach the network, using fnmatch to compare.
34 allowed = []
35 # build-appliance-image uses pip at image time
36 allowed += ["build-appliance-image:do_image"]
37
38 def is_allowed(bpn, task):
39 from fnmatch import fnmatch
40 name = f"{bpn}:{task}"
41 return any(fnmatch(name, pattern) for pattern in allowed)
42
43 bpn = d.getVar("BPN")
44 seen = set()
45 stack = {"do_build"}
46 while stack:
47 task = stack.pop()
48 if task == "do_fetch":
49 continue
50
51 seen.add(task)
52 deps = d.getVarFlag(task, "deps") or []
53 stack |= {d for d in deps if d not in seen}
54
55 network = bb.utils.to_boolean(d.getVarFlag(task, "network"))
56 if network and not is_allowed(bpn, task):
57 bb.error(f"QA Issue: task {task} has network enabled")
58
30python () { 59python () {
31 check_insane_skip(d) 60 check_insane_skip(d)
61 check_network_flag(d)
32} 62}