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