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 | |
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')
-rw-r--r-- | scripts/lib/bsp/help.py | 98 | ||||
-rw-r--r-- | scripts/lib/bsp/kernel.py | 99 | ||||
-rwxr-xr-x | scripts/yocto-kernel | 71 |
3 files changed, 267 insertions, 1 deletions
diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py index 346bf0f2bd..2d7b6fe6d2 100644 --- a/scripts/lib/bsp/help.py +++ b/scripts/lib/bsp/help.py | |||
@@ -383,6 +383,9 @@ yocto_kernel_usage = """ | |||
383 | patch list List the patches associated with a BSP | 383 | patch list List the patches associated with a BSP |
384 | patch add Patch the Yocto kernel for a BSP | 384 | patch add Patch the Yocto kernel for a BSP |
385 | patch rm Remove patches from a BSP | 385 | patch rm Remove patches from a BSP |
386 | feature list List the features used by a BSP | ||
387 | feature add Have a BSP use a feature | ||
388 | feature rm Have a BSP stop using a feature | ||
386 | 389 | ||
387 | See 'yocto-kernel help COMMAND' for more information on a specific command. | 390 | See 'yocto-kernel help COMMAND' for more information on a specific command. |
388 | 391 | ||
@@ -594,6 +597,101 @@ DESCRIPTION | |||
594 | remove. | 597 | remove. |
595 | """ | 598 | """ |
596 | 599 | ||
600 | yocto_kernel_feature_list_usage = """ | ||
601 | |||
602 | List the BSP features that are being used by a BSP | ||
603 | |||
604 | usage: yocto-kernel feature list <bsp-name> | ||
605 | |||
606 | This command lists the features being used by a BSP i.e. the features | ||
607 | which are eligible for modification or removal by other yocto-kernel | ||
608 | commands. | ||
609 | |||
610 | 'modifiable' features are the features listed in a BSP's | ||
611 | user-features.scc file. | ||
612 | """ | ||
613 | |||
614 | |||
615 | yocto_kernel_feature_list_help = """ | ||
616 | |||
617 | NAME | ||
618 | yocto-kernel feature list - List the modifiable set of features | ||
619 | being used by a BSP | ||
620 | |||
621 | SYNOPSIS | ||
622 | yocto-kernel feature list <bsp-name> | ||
623 | |||
624 | DESCRIPTION | ||
625 | This command lists the 'modifiable' features being used by a BSP | ||
626 | i.e. the features which are eligible for modification or removal | ||
627 | by other yocto-kernel commands. | ||
628 | """ | ||
629 | |||
630 | |||
631 | yocto_kernel_feature_add_usage = """ | ||
632 | |||
633 | Add to or modify the list of features being used for a BSP | ||
634 | |||
635 | usage: yocto-kernel feature add <bsp-name> [/xxxx/yyyy/feature.scc ...] | ||
636 | |||
637 | This command adds one or more feature items to a BSP's kernel | ||
638 | user-features.scc file, which is the file used to manage features in | ||
639 | a yocto-bsp-generated BSP. Features to be added must be specified as | ||
640 | fully-qualified feature names. | ||
641 | """ | ||
642 | |||
643 | |||
644 | yocto_kernel_feature_add_help = """ | ||
645 | |||
646 | NAME | ||
647 | yocto-kernel feature add - Add to or modify the list of features | ||
648 | being used for a BSP | ||
649 | |||
650 | SYNOPSIS | ||
651 | yocto-kernel feature add <bsp-name> [/xxxx/yyyy/feature.scc ...] | ||
652 | |||
653 | DESCRIPTION | ||
654 | This command adds one or more feature items to a BSP's | ||
655 | user-features.scc file, which is the file used to manage features | ||
656 | in a yocto-bsp-generated BSP. Features to be added must be | ||
657 | specified as fully-qualified feature names. | ||
658 | """ | ||
659 | |||
660 | |||
661 | yocto_kernel_feature_rm_usage = """ | ||
662 | |||
663 | Remove a feature from the list of features being used for a BSP | ||
664 | |||
665 | usage: yocto-kernel feature rm <bsp-name> | ||
666 | |||
667 | This command removes (turns off) one or more features from a BSP's | ||
668 | user-features.scc file, which is the file used to manage features in | ||
669 | a yocto-bsp-generated BSP. | ||
670 | |||
671 | The set of features available to be removed by this command for a BSP | ||
672 | is listed and the user prompted for the specific items to remove. | ||
673 | """ | ||
674 | |||
675 | |||
676 | yocto_kernel_feature_rm_help = """ | ||
677 | |||
678 | NAME | ||
679 | yocto-kernel feature rm - Remove a feature from the list of | ||
680 | features being used for a BSP | ||
681 | |||
682 | SYNOPSIS | ||
683 | yocto-kernel feature rm <bsp-name> | ||
684 | |||
685 | DESCRIPTION | ||
686 | This command removes (turns off) one or more features from a BSP's | ||
687 | user-features.scc file, which is the file used to manage features | ||
688 | in a yocto-bsp-generated BSP. | ||
689 | |||
690 | The set of features available to be removed by this command for a | ||
691 | BSP is listed and the user prompted for the specific items to | ||
692 | remove. | ||
693 | """ | ||
694 | |||
597 | ## | 695 | ## |
598 | # yocto-layer help and usage strings | 696 | # yocto-layer help and usage strings |
599 | ## | 697 | ## |
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 | """ |
diff --git a/scripts/yocto-kernel b/scripts/yocto-kernel index 2e1789b13d..72b407109d 100755 --- a/scripts/yocto-kernel +++ b/scripts/yocto-kernel | |||
@@ -162,6 +162,65 @@ def yocto_kernel_patch_rm_subcommand(args, usage_str): | |||
162 | yocto_kernel_patch_rm(scripts_path, args[0]) | 162 | yocto_kernel_patch_rm(scripts_path, args[0]) |
163 | 163 | ||
164 | 164 | ||
165 | def yocto_kernel_feature_list_subcommand(args, usage_str): | ||
166 | """ | ||
167 | Command-line handling for listing the BSP features that are being | ||
168 | used by the BSP. The real work is done by | ||
169 | bsp.kernel.yocto_kernel_feature_list(). | ||
170 | """ | ||
171 | logging.debug("yocto_kernel_feature_list_subcommand") | ||
172 | |||
173 | parser = optparse.OptionParser(usage = usage_str) | ||
174 | |||
175 | (options, args) = parser.parse_args(args) | ||
176 | |||
177 | if len(args) != 1: | ||
178 | logging.error("Wrong number of arguments, exiting\n") | ||
179 | parser.print_help() | ||
180 | sys.exit(1) | ||
181 | |||
182 | yocto_kernel_feature_list(scripts_path, args[0]) | ||
183 | |||
184 | |||
185 | def yocto_kernel_feature_add_subcommand(args, usage_str): | ||
186 | """ | ||
187 | Command-line handling for adding the use of kernel features to a | ||
188 | BSP. The real work is done by bsp.kernel.yocto_kernel_feature_add(). | ||
189 | """ | ||
190 | logging.debug("yocto_kernel_feature_add_subcommand") | ||
191 | |||
192 | parser = optparse.OptionParser(usage = usage_str) | ||
193 | |||
194 | (options, args) = parser.parse_args(args) | ||
195 | |||
196 | if len(args) < 2: | ||
197 | logging.error("Wrong number of arguments, exiting\n") | ||
198 | parser.print_help() | ||
199 | sys.exit(1) | ||
200 | |||
201 | machine = args.pop(0) | ||
202 | yocto_kernel_feature_add(scripts_path, machine, args) | ||
203 | |||
204 | |||
205 | def yocto_kernel_feature_rm_subcommand(args, usage_str): | ||
206 | """ | ||
207 | Command-line handling for removing the use of kernel features from | ||
208 | a BSP. The real work is done by bsp.kernel.yocto_kernel_feature_rm(). | ||
209 | """ | ||
210 | logging.debug("yocto_kernel_feature_rm_subcommand") | ||
211 | |||
212 | parser = optparse.OptionParser(usage = usage_str) | ||
213 | |||
214 | (options, args) = parser.parse_args(args) | ||
215 | |||
216 | if len(args) != 1: | ||
217 | logging.error("Wrong number of arguments, exiting\n") | ||
218 | parser.print_help() | ||
219 | sys.exit(1) | ||
220 | |||
221 | yocto_kernel_feature_rm(scripts_path, args[0]) | ||
222 | |||
223 | |||
165 | subcommands = { | 224 | subcommands = { |
166 | "config-list": [yocto_kernel_config_list_subcommand, | 225 | "config-list": [yocto_kernel_config_list_subcommand, |
167 | yocto_kernel_config_list_usage, | 226 | yocto_kernel_config_list_usage, |
@@ -181,6 +240,15 @@ subcommands = { | |||
181 | "patch-rm": [yocto_kernel_patch_rm_subcommand, | 240 | "patch-rm": [yocto_kernel_patch_rm_subcommand, |
182 | yocto_kernel_patch_rm_usage, | 241 | yocto_kernel_patch_rm_usage, |
183 | yocto_kernel_patch_rm_help], | 242 | yocto_kernel_patch_rm_help], |
243 | "feature-list": [yocto_kernel_feature_list_subcommand, | ||
244 | yocto_kernel_feature_list_usage, | ||
245 | yocto_kernel_feature_list_help], | ||
246 | "feature-add": [yocto_kernel_feature_add_subcommand, | ||
247 | yocto_kernel_feature_add_usage, | ||
248 | yocto_kernel_feature_add_help], | ||
249 | "feature-rm": [yocto_kernel_feature_rm_subcommand, | ||
250 | yocto_kernel_feature_rm_usage, | ||
251 | yocto_kernel_feature_rm_help], | ||
184 | } | 252 | } |
185 | 253 | ||
186 | 254 | ||
@@ -212,7 +280,8 @@ def main(): | |||
212 | else: | 280 | else: |
213 | sc = 0 | 281 | sc = 0 |
214 | 282 | ||
215 | if args[sc] == "config" or args[sc] == "patch": | 283 | if args[sc] == "config" or args[sc] == "patch" or \ |
284 | args[sc] == "feature": | ||
216 | if len(args) < 2 + sc: | 285 | if len(args) < 2 + sc: |
217 | parser.print_help() | 286 | parser.print_help() |
218 | sys.exit(1) | 287 | sys.exit(1) |