summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-11 17:33:43 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-19 10:24:50 +0100
commitbfd279de3275abbfaf3e630383ec244131e0375f (patch)
tree0d1c90461a890d21444f5d2afb13c52b302427f1 /meta/classes/kernel.bbclass
parent99203edda6f0b09d817454d656c100b7a8806b18 (diff)
downloadpoky-bfd279de3275abbfaf3e630383ec244131e0375f.tar.gz
Convert tab indentation in python functions into four-space
(From OE-Core rev: 604d46c686d06d62d5a07b9c7f4fa170f99307d8) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel.bbclass')
-rw-r--r--meta/classes/kernel.bbclass342
1 files changed, 171 insertions, 171 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index fd744e7ea3..08b5e61fbe 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -310,177 +310,177 @@ module_conf_sco = "alias bt-proto-2 sco"
310module_conf_rfcomm = "alias bt-proto-3 rfcomm" 310module_conf_rfcomm = "alias bt-proto-3 rfcomm"
311 311
312python populate_packages_prepend () { 312python populate_packages_prepend () {
313 def extract_modinfo(file): 313 def extract_modinfo(file):
314 import tempfile, re, subprocess 314 import tempfile, re, subprocess
315 tempfile.tempdir = d.getVar("WORKDIR", True) 315 tempfile.tempdir = d.getVar("WORKDIR", True)
316 tf = tempfile.mkstemp() 316 tf = tempfile.mkstemp()
317 tmpfile = tf[1] 317 tmpfile = tf[1]
318 cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (d.getVar("PATH", True), d.getVar("HOST_PREFIX", True) or "", file, tmpfile) 318 cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (d.getVar("PATH", True), d.getVar("HOST_PREFIX", True) or "", file, tmpfile)
319 subprocess.call(cmd, shell=True) 319 subprocess.call(cmd, shell=True)
320 f = open(tmpfile) 320 f = open(tmpfile)
321 l = f.read().split("\000") 321 l = f.read().split("\000")
322 f.close() 322 f.close()
323 os.close(tf[0]) 323 os.close(tf[0])
324 os.unlink(tmpfile) 324 os.unlink(tmpfile)
325 exp = re.compile("([^=]+)=(.*)") 325 exp = re.compile("([^=]+)=(.*)")
326 vals = {} 326 vals = {}
327 for i in l: 327 for i in l:
328 m = exp.match(i) 328 m = exp.match(i)
329 if not m: 329 if not m:
330 continue 330 continue
331 vals[m.group(1)] = m.group(2) 331 vals[m.group(1)] = m.group(2)
332 return vals 332 return vals
333 333
334 def parse_depmod(): 334 def parse_depmod():
335 import re 335 import re
336 336
337 dvar = d.getVar('PKGD', True) 337 dvar = d.getVar('PKGD', True)
338 if not dvar: 338 if not dvar:
339 bb.error("PKGD not defined") 339 bb.error("PKGD not defined")
340 return 340 return
341 341
342 kernelver = d.getVar('KERNEL_VERSION', True) 342 kernelver = d.getVar('KERNEL_VERSION', True)
343 kernelver_stripped = kernelver 343 kernelver_stripped = kernelver
344 m = re.match('^(.*-hh.*)[\.\+].*$', kernelver) 344 m = re.match('^(.*-hh.*)[\.\+].*$', kernelver)
345 if m: 345 if m:
346 kernelver_stripped = m.group(1) 346 kernelver_stripped = m.group(1)
347 path = d.getVar("PATH", True) 347 path = d.getVar("PATH", True)
348 348
349 cmd = "PATH=\"%s\" depmod -n -a -b %s -F %s/boot/System.map-%s %s" % (path, dvar, dvar, kernelver, kernelver_stripped) 349 cmd = "PATH=\"%s\" depmod -n -a -b %s -F %s/boot/System.map-%s %s" % (path, dvar, dvar, kernelver, kernelver_stripped)
350 f = os.popen(cmd, 'r') 350 f = os.popen(cmd, 'r')
351 351
352 deps = {} 352 deps = {}
353 pattern0 = "^(.*\.k?o):..*$" 353 pattern0 = "^(.*\.k?o):..*$"
354 pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$" 354 pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$"
355 pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$" 355 pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$"
356 pattern3 = "^\t(.*\.k?o)\s*\\\$" 356 pattern3 = "^\t(.*\.k?o)\s*\\\$"
357 pattern4 = "^\t(.*\.k?o)\s*$" 357 pattern4 = "^\t(.*\.k?o)\s*$"
358 358
359 line = f.readline() 359 line = f.readline()
360 while line: 360 while line:
361 if not re.match(pattern0, line): 361 if not re.match(pattern0, line):
362 line = f.readline() 362 line = f.readline()
363 continue 363 continue
364 m1 = re.match(pattern1, line) 364 m1 = re.match(pattern1, line)
365 if m1: 365 if m1:
366 deps[m1.group(1)] = m1.group(2).split() 366 deps[m1.group(1)] = m1.group(2).split()
367 else: 367 else:
368 m2 = re.match(pattern2, line) 368 m2 = re.match(pattern2, line)
369 if m2: 369 if m2:
370 deps[m2.group(1)] = m2.group(2).split() 370 deps[m2.group(1)] = m2.group(2).split()
371 line = f.readline() 371 line = f.readline()
372 m3 = re.match(pattern3, line) 372 m3 = re.match(pattern3, line)
373 while m3: 373 while m3:
374 deps[m2.group(1)].extend(m3.group(1).split()) 374 deps[m2.group(1)].extend(m3.group(1).split())
375 line = f.readline() 375 line = f.readline()
376 m3 = re.match(pattern3, line) 376 m3 = re.match(pattern3, line)
377 m4 = re.match(pattern4, line) 377 m4 = re.match(pattern4, line)
378 deps[m2.group(1)].extend(m4.group(1).split()) 378 deps[m2.group(1)].extend(m4.group(1).split())
379 line = f.readline() 379 line = f.readline()
380 f.close() 380 f.close()
381 return deps 381 return deps
382 382
383 def get_dependencies(file, pattern, format): 383 def get_dependencies(file, pattern, format):
384 # file no longer includes PKGD 384 # file no longer includes PKGD
385 file = file.replace(d.getVar('PKGD', True) or '', '', 1) 385 file = file.replace(d.getVar('PKGD', True) or '', '', 1)
386 # instead is prefixed with /lib/modules/${KERNEL_VERSION} 386 # instead is prefixed with /lib/modules/${KERNEL_VERSION}
387 file = file.replace("/lib/modules/%s/" % d.getVar('KERNEL_VERSION', True) or '', '', 1) 387 file = file.replace("/lib/modules/%s/" % d.getVar('KERNEL_VERSION', True) or '', '', 1)
388 388
389 if module_deps.has_key(file): 389 if module_deps.has_key(file):
390 import re 390 import re
391 dependencies = [] 391 dependencies = []
392 for i in module_deps[file]: 392 for i in module_deps[file]:
393 m = re.match(pattern, os.path.basename(i)) 393 m = re.match(pattern, os.path.basename(i))
394 if not m: 394 if not m:
395 continue 395 continue
396 on = legitimize_package_name(m.group(1)) 396 on = legitimize_package_name(m.group(1))
397 dependency_pkg = format % on 397 dependency_pkg = format % on
398 dependencies.append(dependency_pkg) 398 dependencies.append(dependency_pkg)
399 return dependencies 399 return dependencies
400 return [] 400 return []
401 401
402 def frob_metadata(file, pkg, pattern, format, basename): 402 def frob_metadata(file, pkg, pattern, format, basename):
403 import re 403 import re
404 vals = extract_modinfo(file) 404 vals = extract_modinfo(file)
405 405
406 dvar = d.getVar('PKGD', True) 406 dvar = d.getVar('PKGD', True)
407 407
408 # If autoloading is requested, output /etc/modules-load.d/<name>.conf and append 408 # If autoloading is requested, output /etc/modules-load.d/<name>.conf and append
409 # appropriate modprobe commands to the postinst 409 # appropriate modprobe commands to the postinst
410 autoload = d.getVar('module_autoload_%s' % basename, True) 410 autoload = d.getVar('module_autoload_%s' % basename, True)
411 if autoload: 411 if autoload:
412 name = '%s/etc/modules-load.d/%s.conf' % (dvar, basename) 412 name = '%s/etc/modules-load.d/%s.conf' % (dvar, basename)
413 f = open(name, 'w') 413 f = open(name, 'w')
414 for m in autoload.split(): 414 for m in autoload.split():
415 f.write('%s\n' % m) 415 f.write('%s\n' % m)
416 f.close() 416 f.close()
417 postinst = d.getVar('pkg_postinst_%s' % pkg, True) 417 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
418 if not postinst: 418 if not postinst:
419 bb.fatal("pkg_postinst_%s not defined" % pkg) 419 bb.fatal("pkg_postinst_%s not defined" % pkg)
420 postinst += d.getVar('autoload_postinst_fragment', True) % autoload 420 postinst += d.getVar('autoload_postinst_fragment', True) % autoload
421 d.setVar('pkg_postinst_%s' % pkg, postinst) 421 d.setVar('pkg_postinst_%s' % pkg, postinst)
422 422
423 # Write out any modconf fragment 423 # Write out any modconf fragment
424 modconf = d.getVar('module_conf_%s' % basename, True) 424 modconf = d.getVar('module_conf_%s' % basename, True)
425 if modconf: 425 if modconf:
426 name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename) 426 name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
427 f = open(name, 'w') 427 f = open(name, 'w')
428 f.write("%s\n" % modconf) 428 f.write("%s\n" % modconf)
429 f.close() 429 f.close()
430 430
431 files = d.getVar('FILES_%s' % pkg, True) 431 files = d.getVar('FILES_%s' % pkg, True)
432 files = "%s /etc/modules-load.d/%s.conf /etc/modprobe.d/%s.conf" % (files, basename, basename) 432 files = "%s /etc/modules-load.d/%s.conf /etc/modprobe.d/%s.conf" % (files, basename, basename)
433 d.setVar('FILES_%s' % pkg, files) 433 d.setVar('FILES_%s' % pkg, files)
434 434
435 if vals.has_key("description"): 435 if vals.has_key("description"):
436 old_desc = d.getVar('DESCRIPTION_' + pkg, True) or "" 436 old_desc = d.getVar('DESCRIPTION_' + pkg, True) or ""
437 d.setVar('DESCRIPTION_' + pkg, old_desc + "; " + vals["description"]) 437 d.setVar('DESCRIPTION_' + pkg, old_desc + "; " + vals["description"])
438 438
439 rdepends_str = d.getVar('RDEPENDS_' + pkg, True) 439 rdepends_str = d.getVar('RDEPENDS_' + pkg, True)
440 if rdepends_str: 440 if rdepends_str:
441 rdepends = rdepends_str.split() 441 rdepends = rdepends_str.split()
442 else: 442 else:
443 rdepends = [] 443 rdepends = []
444 rdepends.extend(get_dependencies(file, pattern, format)) 444 rdepends.extend(get_dependencies(file, pattern, format))
445 d.setVar('RDEPENDS_' + pkg, ' '.join(rdepends)) 445 d.setVar('RDEPENDS_' + pkg, ' '.join(rdepends))
446 446
447 module_deps = parse_depmod() 447 module_deps = parse_depmod()
448 module_regex = '^(.*)\.k?o$' 448 module_regex = '^(.*)\.k?o$'
449 module_pattern = 'kernel-module-%s' 449 module_pattern = 'kernel-module-%s'
450 450
451 postinst = d.getVar('pkg_postinst_modules', True) 451 postinst = d.getVar('pkg_postinst_modules', True)
452 postrm = d.getVar('pkg_postrm_modules', True) 452 postrm = d.getVar('pkg_postrm_modules', True)
453 do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') 453 do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
454 do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') 454 do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
455 do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') 455 do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
456 do_split_packages(d, root='/lib/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='update-modules kernel-%s' % d.getVar("KERNEL_VERSION", True)) 456 do_split_packages(d, root='/lib/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='update-modules kernel-%s' % d.getVar("KERNEL_VERSION", True))
457 457
458 # If modules-load.d and modprobe.d are empty at this point, remove them to 458 # If modules-load.d and modprobe.d are empty at this point, remove them to
459 # avoid warnings. removedirs only raises an OSError if an empty 459 # avoid warnings. removedirs only raises an OSError if an empty
460 # directory cannot be removed. 460 # directory cannot be removed.
461 dvar = d.getVar('PKGD', True) 461 dvar = d.getVar('PKGD', True)
462 for dir in ["%s/etc/modprobe.d" % (dvar), "%s/etc/modules-load.d" % (dvar), "%s/etc" % (dvar)]: 462 for dir in ["%s/etc/modprobe.d" % (dvar), "%s/etc/modules-load.d" % (dvar), "%s/etc" % (dvar)]:
463 if len(os.listdir(dir)) == 0: 463 if len(os.listdir(dir)) == 0:
464 os.rmdir(dir) 464 os.rmdir(dir)
465 465
466 import re 466 import re
467 metapkg = "kernel-modules" 467 metapkg = "kernel-modules"
468 d.setVar('ALLOW_EMPTY_' + metapkg, "1") 468 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
469 d.setVar('FILES_' + metapkg, "") 469 d.setVar('FILES_' + metapkg, "")
470 blacklist = [ 'kernel-dev', 'kernel-image', 'kernel-base', 'kernel-vmlinux' ] 470 blacklist = [ 'kernel-dev', 'kernel-image', 'kernel-base', 'kernel-vmlinux' ]
471 for l in module_deps.values(): 471 for l in module_deps.values():
472 for i in l: 472 for i in l:
473 pkg = module_pattern % legitimize_package_name(re.match(module_regex, os.path.basename(i)).group(1)) 473 pkg = module_pattern % legitimize_package_name(re.match(module_regex, os.path.basename(i)).group(1))
474 blacklist.append(pkg) 474 blacklist.append(pkg)
475 metapkg_rdepends = [] 475 metapkg_rdepends = []
476 packages = d.getVar('PACKAGES', True).split() 476 packages = d.getVar('PACKAGES', True).split()
477 for pkg in packages[1:]: 477 for pkg in packages[1:]:
478 if not pkg in blacklist and not pkg in metapkg_rdepends: 478 if not pkg in blacklist and not pkg in metapkg_rdepends:
479 metapkg_rdepends.append(pkg) 479 metapkg_rdepends.append(pkg)
480 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends)) 480 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
481 d.setVar('DESCRIPTION_' + metapkg, 'Kernel modules meta package') 481 d.setVar('DESCRIPTION_' + metapkg, 'Kernel modules meta package')
482 packages.append(metapkg) 482 packages.append(metapkg)
483 d.setVar('PACKAGES', ' '.join(packages)) 483 d.setVar('PACKAGES', ' '.join(packages))
484} 484}
485 485
486# Support checking the kernel size since some kernels need to reside in partitions 486# Support checking the kernel size since some kernels need to reside in partitions