summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-03 17:17:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-06 13:13:00 +0000
commit88badcf7eb124096c3755087e5c138dca6074f0f (patch)
treec66eac8ab867455de719b3bb105bf0e7c2b801cd /meta
parent85b4891a1ccfe65872435cb9b393d0eb35743b06 (diff)
downloadpoky-88badcf7eb124096c3755087e5c138dca6074f0f.tar.gz
kernel.bbclass: Improve populate_packages_prepend
Small performance tweaks for populate_packages_prepend: * Compile the regexps once at the start * Don't keep importing a module which is already imported * No need to check PKG is set, we'd have failed long before now if it wasn't * Don't export PATH, bitbake takes care of this at the task level (From OE-Core rev: e9d43d7b4d2cfb22b21f3814c2401a699c78b025) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/kernel.bbclass48
1 files changed, 21 insertions, 27 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index cc61be6f18..4805944ccb 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -302,71 +302,68 @@ fi
302} 302}
303 303
304python populate_packages_prepend () { 304python populate_packages_prepend () {
305 import re
306
307 modinfoexp = re.compile("([^=]+)=(.*)")
308 kerverrexp = re.compile('^(.*-hh.*)[\.\+].*$')
309 depmodpat0 = re.compile("^(.*\.k?o):..*$")
310 depmodpat1 = re.compile("^(.*\.k?o):\s*(.*\.k?o)\s*$")
311 depmodpat2 = re.compile("^(.*\.k?o):\s*(.*\.k?o)\s*\\\$")
312 depmodpat3 = re.compile("^\t(.*\.k?o)\s*\\\$")
313 depmodpat4 = re.compile("^\t(.*\.k?o)\s*$")
314
305 def extract_modinfo(file): 315 def extract_modinfo(file):
306 import tempfile, re, subprocess 316 import tempfile, subprocess
307 tempfile.tempdir = d.getVar("WORKDIR", True) 317 tempfile.tempdir = d.getVar("WORKDIR", True)
308 tf = tempfile.mkstemp() 318 tf = tempfile.mkstemp()
309 tmpfile = tf[1] 319 tmpfile = tf[1]
310 cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (d.getVar("PATH", True), d.getVar("HOST_PREFIX", True) or "", file, tmpfile) 320 cmd = "%sobjcopy -j .modinfo -O binary %s %s" % (d.getVar("HOST_PREFIX", True) or "", file, tmpfile)
311 subprocess.call(cmd, shell=True) 321 subprocess.call(cmd, shell=True)
312 f = open(tmpfile) 322 f = open(tmpfile)
313 l = f.read().split("\000") 323 l = f.read().split("\000")
314 f.close() 324 f.close()
315 os.close(tf[0]) 325 os.close(tf[0])
316 os.unlink(tmpfile) 326 os.unlink(tmpfile)
317 exp = re.compile("([^=]+)=(.*)")
318 vals = {} 327 vals = {}
319 for i in l: 328 for i in l:
320 m = exp.match(i) 329 m = modinfoexp.match(i)
321 if not m: 330 if not m:
322 continue 331 continue
323 vals[m.group(1)] = m.group(2) 332 vals[m.group(1)] = m.group(2)
324 return vals 333 return vals
325 334
326 def parse_depmod(): 335 def parse_depmod():
327 import re
328 336
329 dvar = d.getVar('PKGD', True) 337 dvar = d.getVar('PKGD', True)
330 if not dvar:
331 bb.error("PKGD not defined")
332 return
333 338
334 kernelver = d.getVar('KERNEL_VERSION', True) 339 kernelver = d.getVar('KERNEL_VERSION', True)
335 kernelver_stripped = kernelver 340 kernelver_stripped = kernelver
336 m = re.match('^(.*-hh.*)[\.\+].*$', kernelver) 341 m = kerverrexp.match(kernelver)
337 if m: 342 if m:
338 kernelver_stripped = m.group(1) 343 kernelver_stripped = m.group(1)
339 path = d.getVar("PATH", True) 344 cmd = "depmod -n -a -b %s -F %s/boot/System.map-%s %s" % (dvar, dvar, kernelver, kernelver_stripped)
340
341 cmd = "PATH=\"%s\" depmod -n -a -b %s -F %s/boot/System.map-%s %s" % (path, dvar, dvar, kernelver, kernelver_stripped)
342 f = os.popen(cmd, 'r') 345 f = os.popen(cmd, 'r')
343 346
344 deps = {} 347 deps = {}
345 pattern0 = "^(.*\.k?o):..*$"
346 pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$"
347 pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$"
348 pattern3 = "^\t(.*\.k?o)\s*\\\$"
349 pattern4 = "^\t(.*\.k?o)\s*$"
350
351 line = f.readline() 348 line = f.readline()
352 while line: 349 while line:
353 if not re.match(pattern0, line): 350 if not depmodpat0.match(line):
354 line = f.readline() 351 line = f.readline()
355 continue 352 continue
356 m1 = re.match(pattern1, line) 353 m1 = depmodpat1.match(line)
357 if m1: 354 if m1:
358 deps[m1.group(1)] = m1.group(2).split() 355 deps[m1.group(1)] = m1.group(2).split()
359 else: 356 else:
360 m2 = re.match(pattern2, line) 357 m2 = depmodpat2.match(line)
361 if m2: 358 if m2:
362 deps[m2.group(1)] = m2.group(2).split() 359 deps[m2.group(1)] = m2.group(2).split()
363 line = f.readline() 360 line = f.readline()
364 m3 = re.match(pattern3, line) 361 m3 = depmodpat3.match(line)
365 while m3: 362 while m3:
366 deps[m2.group(1)].extend(m3.group(1).split()) 363 deps[m2.group(1)].extend(m3.group(1).split())
367 line = f.readline() 364 line = f.readline()
368 m3 = re.match(pattern3, line) 365 m3 = depmodpat3.match(line)
369 m4 = re.match(pattern4, line) 366 m4 = depmodpat4.match(line)
370 deps[m2.group(1)].extend(m4.group(1).split()) 367 deps[m2.group(1)].extend(m4.group(1).split())
371 line = f.readline() 368 line = f.readline()
372 f.close() 369 f.close()
@@ -379,7 +376,6 @@ python populate_packages_prepend () {
379 file = file.replace("/lib/modules/%s/" % d.getVar('KERNEL_VERSION', True) or '', '', 1) 376 file = file.replace("/lib/modules/%s/" % d.getVar('KERNEL_VERSION', True) or '', '', 1)
380 377
381 if module_deps.has_key(file): 378 if module_deps.has_key(file):
382 import re
383 dependencies = [] 379 dependencies = []
384 for i in module_deps[file]: 380 for i in module_deps[file]:
385 m = re.match(pattern, os.path.basename(i)) 381 m = re.match(pattern, os.path.basename(i))
@@ -392,7 +388,6 @@ python populate_packages_prepend () {
392 return [] 388 return []
393 389
394 def frob_metadata(file, pkg, pattern, format, basename): 390 def frob_metadata(file, pkg, pattern, format, basename):
395 import re
396 vals = extract_modinfo(file) 391 vals = extract_modinfo(file)
397 392
398 dvar = d.getVar('PKGD', True) 393 dvar = d.getVar('PKGD', True)
@@ -454,7 +449,6 @@ python populate_packages_prepend () {
454 if len(os.listdir(dir)) == 0: 449 if len(os.listdir(dir)) == 0:
455 os.rmdir(dir) 450 os.rmdir(dir)
456 451
457 import re
458 metapkg = "kernel-modules" 452 metapkg = "kernel-modules"
459 blacklist = [ 'kernel-dev', 'kernel-image', 'kernel-base', 'kernel-vmlinux' ] 453 blacklist = [ 'kernel-dev', 'kernel-image', 'kernel-base', 'kernel-vmlinux' ]
460 for l in module_deps.values(): 454 for l in module_deps.values():