diff options
| author | Tom Zanussi <tom.zanussi@linux.intel.com> | 2013-03-11 18:52:50 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-03-17 23:10:28 +0000 |
| commit | 0bfe83edbb65f94fca8028be0ca20fdfec5ffc81 (patch) | |
| tree | a53b8b15769ac71156b2a3e400f7d44b5d0b6375 /scripts/lib/bsp/kernel.py | |
| parent | 6911fd0889261fb173775727db61dffaac355ed7 (diff) | |
| download | poky-0bfe83edbb65f94fca8028be0ca20fdfec5ffc81.tar.gz | |
yocto-kernel: add support for kernel feature add/rm/list
Add yocto-kernel commands allowing users to add, remove, and list
kernel features with respect to a given BSP.
Features managed by these commands modify a special
machine-user-features.scc file associated with the kernel recipe
(.bbappend) of a yocto-bsp-generated BSP. This is analagous to the
implementation of similar support for bare config items and patches
already implemented for yocto-bsp-generated BSPs.
Future patches will add support for providing a list of eligible
features as defined by linux-yocto kernels and locally-defined
(recipe-space) kernel features.
(From meta-yocto rev: ae68d906c5c9854f2cd7ee0870556fbfbd7d94d0)
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/bsp/kernel.py')
| -rw-r--r-- | scripts/lib/bsp/kernel.py | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py index dabb9cf3f0..0fa228a58a 100644 --- a/scripts/lib/bsp/kernel.py +++ b/scripts/lib/bsp/kernel.py | |||
| @@ -552,6 +552,105 @@ def find_giturl(context): | |||
| 552 | 552 | ||
| 553 | return None | 553 | return None |
| 554 | 554 | ||
| 555 | |||
| 556 | def read_features(scripts_path, machine): | ||
| 557 | """ | ||
| 558 | Find and return a list of features in a machine's user-defined | ||
| 559 | features fragment [${machine}-user-features.scc]. | ||
| 560 | """ | ||
| 561 | features = [] | ||
| 562 | |||
| 563 | f = open_user_file(scripts_path, machine, machine+"-user-features.scc", "r") | ||
| 564 | lines = f.readlines() | ||
| 565 | for line in lines: | ||
| 566 | s = line.strip() | ||
| 567 | if s and not s.startswith("#"): | ||
| 568 | feature_include = s.split() | ||
| 569 | features.append(feature_include[1].strip()) | ||
| 570 | f.close() | ||
| 571 | |||
| 572 | return features | ||
| 573 | |||
| 574 | |||
| 575 | def write_features(scripts_path, machine, features): | ||
| 576 | """ | ||
| 577 | Write (replace) the list of feature items in a | ||
| 578 | machine's user-defined features fragment [${machine}=user-features.cfg]. | ||
| 579 | """ | ||
| 580 | f = open_user_file(scripts_path, machine, machine+"-user-features.scc", "w") | ||
| 581 | for item in features: | ||
| 582 | f.write("include " + item + "\n") | ||
| 583 | f.close() | ||
| 584 | |||
| 585 | kernel_contents_changed(scripts_path, machine) | ||
| 586 | |||
| 587 | |||
| 588 | def yocto_kernel_feature_list(scripts_path, machine): | ||
| 589 | """ | ||
| 590 | Display the list of features used in a machine's user-defined | ||
| 591 | features fragment [${machine}-user-features.scc]. | ||
| 592 | """ | ||
| 593 | features = read_features(scripts_path, machine) | ||
| 594 | |||
| 595 | print "The current set of machine-specific features for %s is:" % machine | ||
| 596 | print gen_choices_str(features) | ||
| 597 | |||
| 598 | |||
| 599 | def yocto_kernel_feature_rm(scripts_path, machine): | ||
| 600 | """ | ||
| 601 | Display the list of features used in a machine's user-defined | ||
| 602 | features fragment [${machine}-user-features.scc], prompt the user | ||
| 603 | for one or more to remove, and remove them. | ||
| 604 | """ | ||
| 605 | features = read_features(scripts_path, machine) | ||
| 606 | |||
| 607 | print "Specify the features to remove:" | ||
| 608 | input = raw_input(gen_choices_str(features)) | ||
| 609 | rm_choices = input.split() | ||
| 610 | rm_choices.sort() | ||
| 611 | |||
| 612 | removed = [] | ||
| 613 | |||
| 614 | for choice in reversed(rm_choices): | ||
| 615 | try: | ||
| 616 | idx = int(choice) - 1 | ||
| 617 | except ValueError: | ||
| 618 | print "Invalid choice (%s), exiting" % choice | ||
| 619 | sys.exit(1) | ||
| 620 | if idx < 0 or idx >= len(features): | ||
| 621 | print "Invalid choice (%d), exiting" % (idx + 1) | ||
| 622 | sys.exit(1) | ||
| 623 | removed.append(features.pop(idx)) | ||
| 624 | |||
| 625 | write_features(scripts_path, machine, features) | ||
| 626 | |||
| 627 | print "Removed features:" | ||
| 628 | for r in removed: | ||
| 629 | print "\t%s" % r | ||
| 630 | |||
| 631 | |||
| 632 | def yocto_kernel_feature_add(scripts_path, machine, features): | ||
| 633 | """ | ||
| 634 | Add one or more features a machine's user-defined features | ||
| 635 | fragment [${machine}-user-features.scc]. | ||
| 636 | """ | ||
| 637 | new_items = [] | ||
| 638 | |||
| 639 | for item in features: | ||
| 640 | if not item.endswith(".scc"): | ||
| 641 | print "Invalid feature (%s), exiting" % item | ||
| 642 | sys.exit(1) | ||
| 643 | new_items.append(item) | ||
| 644 | |||
| 645 | cur_items = read_features(scripts_path, machine) | ||
| 646 | cur_items.extend(new_items) | ||
| 647 | |||
| 648 | write_features(scripts_path, machine, cur_items) | ||
| 649 | |||
| 650 | print "Added features:" | ||
| 651 | for n in new_items: | ||
| 652 | print "\t%s" % n | ||
| 653 | |||
| 555 | 654 | ||
| 556 | def base_branches(context): | 655 | def base_branches(context): |
| 557 | """ | 656 | """ |
