summaryrefslogtreecommitdiffstats
path: root/scripts/verify-bashisms
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-01-31 13:50:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-31 15:28:41 +0000
commit010f9fa86a993554e2b9134e6baf96899649a2ef (patch)
treee2131bcfbfe40bc18b2a896188e131792504ff3c /scripts/verify-bashisms
parent48c65ddaa4d224848a96dff9a459ee715495a5eb (diff)
downloadpoky-010f9fa86a993554e2b9134e6baf96899649a2ef.tar.gz
verify-bashisms: fix problems with tinfoil2
tinfoil2 is based on a client/server architecture, which broke the verify-bashisms script: - The tinfoil instance and its data proxies can't be pickled, so all interaction with the bitbake server has to run in the main script process and only processing of the plain scripts can be done with multiprocessing: _pickle.PicklingError: Can't pickle <class 'bb.tinfoil.TinfoilCookerAdapter.TinfoilRecipeCacheAdapter'>: attribute lookup TinfoilRecipeCacheAdapter on bb.tinfoil failed - The multiprocessing pool has to be created before initializing tinfoil, otherwise the pool workers end up trying to communicate with the bitbake server during shutdown: ERROR: UI received SIGTERM Process ForkPoolWorker-2: Traceback (most recent call last): File "/usr/lib/python3.4/multiprocessing/process.py", line 257, in _bootstrap util._exit_function() File "/usr/lib/python3.4/multiprocessing/util.py", line 286, in _exit_function _run_finalizers(0) ... File "/usr/lib/python3.4/multiprocessing/process.py", line 131, in is_alive assert self._parent_pid == os.getpid(), 'can only test a child process' AssertionError: can only test a child process - func() needs to defined before creating the pool to avoid: AttributeError: Can't get attribute 'func' on <module '__main__' from '/work/openembedded-core/scripts/verify-bashisms'> (From OE-Core rev: aa439f11c7f414774843720d68ebe0a6d3375ea6) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/verify-bashisms')
-rwxr-xr-xscripts/verify-bashisms44
1 files changed, 25 insertions, 19 deletions
diff --git a/scripts/verify-bashisms b/scripts/verify-bashisms
index ed0a5631d0..613f174a97 100755
--- a/scripts/verify-bashisms
+++ b/scripts/verify-bashisms
@@ -71,6 +71,20 @@ if __name__=='__main__':
71 print("Cannot find checkbashisms.pl on $PATH, get it from https://anonscm.debian.org/cgit/collab-maint/devscripts.git/plain/scripts/checkbashisms.pl") 71 print("Cannot find checkbashisms.pl on $PATH, get it from https://anonscm.debian.org/cgit/collab-maint/devscripts.git/plain/scripts/checkbashisms.pl")
72 sys.exit(1) 72 sys.exit(1)
73 73
74 # The order of defining the worker function,
75 # initializing the pool and connecting to the
76 # bitbake server is crucial, don't change it.
77 def func(item):
78 fn, scripts = item
79 result = []
80 for key, script in scripts:
81 r = process(fn, key, script)
82 if r: result.extend(r)
83 return fn, result
84
85 import multiprocessing
86 pool = multiprocessing.Pool()
87
74 tinfoil = get_tinfoil() 88 tinfoil = get_tinfoil()
75 89
76 # This is only the default configuration and should iterate over 90 # This is only the default configuration and should iterate over
@@ -83,32 +97,24 @@ if __name__=='__main__':
83 else: 97 else:
84 initial_pns = sorted(pkg_pn) 98 initial_pns = sorted(pkg_pn)
85 99
86 pns = [] 100 pns = {}
87 print("Generating file list...") 101 print("Generating scripts...")
88 for pn in initial_pns: 102 for pn in initial_pns:
89 for fn in pkg_pn[pn]: 103 for fn in pkg_pn[pn]:
90 # There's no point checking multiple BBCLASSEXTENDed variants of the same recipe 104 # There's no point checking multiple BBCLASSEXTENDed variants of the same recipe
91 realfn, _, _ = bb.cache.virtualfn2realfn(fn) 105 realfn, _, _ = bb.cache.virtualfn2realfn(fn)
92 if realfn not in pns: 106 if realfn not in pns:
93 pns.append(realfn) 107 data = tinfoil.parse_recipe_file(realfn)
94 108 scripts = []
95 109 for key in data.keys():
96 def func(fn): 110 if data.getVarFlag(key, "func") and not data.getVarFlag(key, "python"):
97 result = [] 111 script = data.getVar(key, False)
98 data = tinfoil.parse_recipe_file(fn) 112 if script:
99 for key in data.keys(): 113 scripts.append((key, script))
100 if data.getVarFlag(key, "func") and not data.getVarFlag(key, "python"): 114 pns[realfn] = scripts
101 script = data.getVar(key, False)
102 if not script: continue
103 #print ("%s:%s" % (fn, key))
104 r = process(fn, key, script)
105 if r: result.extend(r)
106 return fn, result
107 115
108 print("Scanning scripts...\n") 116 print("Scanning scripts...\n")
109 import multiprocessing 117 for pn, results in pool.imap(func, pns.items()):
110 pool = multiprocessing.Pool()
111 for pn,results in pool.imap(func, pns):
112 if results: 118 if results:
113 print(pn) 119 print(pn)
114 for message,source in results: 120 for message,source in results: