diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/bsp/help.py | 31 | ||||
-rw-r--r-- | scripts/lib/bsp/kernel.py | 107 | ||||
-rwxr-xr-x | scripts/yocto-kernel | 27 |
3 files changed, 164 insertions, 1 deletions
diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py index 2d7b6fe6d2..9ba6a931ee 100644 --- a/scripts/lib/bsp/help.py +++ b/scripts/lib/bsp/help.py | |||
@@ -386,6 +386,7 @@ yocto_kernel_usage = """ | |||
386 | feature list List the features used by a BSP | 386 | feature list List the features used by a BSP |
387 | feature add Have a BSP use a feature | 387 | feature add Have a BSP use a feature |
388 | feature rm Have a BSP stop using a feature | 388 | feature rm Have a BSP stop using a feature |
389 | features list List the features available to BSPs | ||
389 | 390 | ||
390 | See 'yocto-kernel help COMMAND' for more information on a specific command. | 391 | See 'yocto-kernel help COMMAND' for more information on a specific command. |
391 | 392 | ||
@@ -692,6 +693,36 @@ DESCRIPTION | |||
692 | remove. | 693 | remove. |
693 | """ | 694 | """ |
694 | 695 | ||
696 | |||
697 | yocto_kernel_available_features_list_usage = """ | ||
698 | |||
699 | List the set of kernel features available to a BSP | ||
700 | |||
701 | usage: yocto-kernel features list <bsp-name> | ||
702 | |||
703 | This command lists the complete set of kernel features available to a | ||
704 | BSP. This includes the features contained in linux-yocto meta | ||
705 | branches as well as recipe-space features defined locally to the BSP. | ||
706 | """ | ||
707 | |||
708 | |||
709 | yocto_kernel_available_features_list_help = """ | ||
710 | |||
711 | NAME | ||
712 | yocto-kernel features list - List the set of kernel features | ||
713 | available to a BSP | ||
714 | |||
715 | SYNOPSIS | ||
716 | yocto-kernel features list <bsp-name> | ||
717 | |||
718 | DESCRIPTION | ||
719 | This command lists the complete set of kernel features available | ||
720 | to a BSP. This includes the features contained in linux-yocto | ||
721 | meta branches as well as recipe-space features defined locally to | ||
722 | the BSP. | ||
723 | """ | ||
724 | |||
725 | |||
695 | ## | 726 | ## |
696 | # yocto-layer help and usage strings | 727 | # yocto-layer help and usage strings |
697 | ## | 728 | ## |
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py index 0fa228a58a..0308600a42 100644 --- a/scripts/lib/bsp/kernel.py +++ b/scripts/lib/bsp/kernel.py | |||
@@ -32,6 +32,7 @@ import shutil | |||
32 | from tags import * | 32 | from tags import * |
33 | import glob | 33 | import glob |
34 | import subprocess | 34 | import subprocess |
35 | from engine import create_context | ||
35 | 36 | ||
36 | 37 | ||
37 | def find_bblayers(scripts_path): | 38 | def find_bblayers(scripts_path): |
@@ -651,6 +652,112 @@ def yocto_kernel_feature_add(scripts_path, machine, features): | |||
651 | for n in new_items: | 652 | for n in new_items: |
652 | print "\t%s" % n | 653 | print "\t%s" % n |
653 | 654 | ||
655 | |||
656 | def find_feature_url(git_url): | ||
657 | """ | ||
658 | Find the url of the kern-features.rc kernel for the kernel repo | ||
659 | specified from the BSP's kernel recipe SRC_URI. | ||
660 | """ | ||
661 | feature_url = "" | ||
662 | if git_url.startswith("git://"): | ||
663 | git_url = git_url[len("git://"):].strip() | ||
664 | s = git_url.split("/") | ||
665 | if s[1].endswith(".git"): | ||
666 | s[1] = s[1][:len(s[1]) - len(".git")] | ||
667 | feature_url = "http://" + s[0] + "/cgit/cgit.cgi/" + s[1] + \ | ||
668 | "/plain/meta/cfg/kern-features.rc?h=meta" | ||
669 | |||
670 | return feature_url | ||
671 | |||
672 | |||
673 | def find_feature_desc(lines): | ||
674 | """ | ||
675 | Find the feature description and compatibility in the passed-in | ||
676 | set of lines. Returns a string string of the form 'desc | ||
677 | [compat]'. | ||
678 | """ | ||
679 | desc = "no description available" | ||
680 | compat = "unknown" | ||
681 | |||
682 | for line in lines: | ||
683 | idx = line.find("KFEATURE_DESCRIPTION") | ||
684 | if idx != -1: | ||
685 | desc = line[idx + len("KFEATURE_DESCRIPTION"):].strip() | ||
686 | if desc.startswith("\""): | ||
687 | desc = desc[1:] | ||
688 | if desc.endswith("\""): | ||
689 | desc = desc[:-1] | ||
690 | else: | ||
691 | idx = line.find("KFEATURE_COMPATIBILITY") | ||
692 | if idx != -1: | ||
693 | compat = line[idx + len("KFEATURE_COMPATIBILITY"):].strip() | ||
694 | |||
695 | return desc + " [" + compat + "]" | ||
696 | |||
697 | |||
698 | def print_feature_descs(layer, feature_dir): | ||
699 | """ | ||
700 | Print the feature descriptions for the features in feature_dir. | ||
701 | """ | ||
702 | kernel_files_features = os.path.join(layer, "recipes-kernel/linux/files/" + | ||
703 | feature_dir) | ||
704 | for root, dirs, files in os.walk(kernel_files_features): | ||
705 | for file in files: | ||
706 | if file.endswith("~") or file.endswith("#"): | ||
707 | continue | ||
708 | if file.endswith(".scc"): | ||
709 | fullpath = os.path.join(layer, "recipes-kernel/linux/files/" + | ||
710 | feature_dir + "/" + file) | ||
711 | f = open(fullpath) | ||
712 | feature_desc = find_feature_desc(f.readlines()) | ||
713 | print feature_dir + "/" + file + ": " + feature_desc | ||
714 | |||
715 | |||
716 | def yocto_kernel_available_features_list(scripts_path, machine): | ||
717 | """ | ||
718 | Display the list of all the kernel features available for use in | ||
719 | BSPs, as gathered from the set of feature sources. | ||
720 | """ | ||
721 | layer = find_bsp_layer(scripts_path, machine) | ||
722 | kernel = find_current_kernel(layer, machine) | ||
723 | if not kernel: | ||
724 | print "Couldn't determine the kernel for this BSP, exiting." | ||
725 | sys.exit(1) | ||
726 | |||
727 | context = create_context(machine, "arch", scripts_path) | ||
728 | context["name"] = "name" | ||
729 | context["filename"] = kernel | ||
730 | giturl = find_giturl(context) | ||
731 | feature_url = find_feature_url(giturl) | ||
732 | |||
733 | feature_cmd = "wget -q -O - " + feature_url | ||
734 | tmp = subprocess.Popen(feature_cmd, shell=True, stdout=subprocess.PIPE).stdout.read() | ||
735 | |||
736 | print "The current set of kernel features available to %s is:\n" % machine | ||
737 | |||
738 | if tmp: | ||
739 | tmpline = tmp.split("\n") | ||
740 | in_kernel_options = False | ||
741 | for line in tmpline: | ||
742 | if not "=" in line: | ||
743 | if in_kernel_options: | ||
744 | break | ||
745 | if "kernel-options" in line: | ||
746 | in_kernel_options = True | ||
747 | continue | ||
748 | if in_kernel_options: | ||
749 | feature_def = line.split("=") | ||
750 | feature_type = feature_def[0].strip() | ||
751 | feature = feature_def[1].strip() | ||
752 | desc = get_feature_desc(giturl, feature) | ||
753 | print "%s: %s" % (feature, desc) | ||
754 | |||
755 | print "[local]" | ||
756 | |||
757 | print_feature_descs(layer, "cfg") | ||
758 | print_feature_descs(layer, "features") | ||
759 | |||
760 | |||
654 | 761 | ||
655 | def base_branches(context): | 762 | def base_branches(context): |
656 | """ | 763 | """ |
diff --git a/scripts/yocto-kernel b/scripts/yocto-kernel index 72b407109d..a66a7272db 100755 --- a/scripts/yocto-kernel +++ b/scripts/yocto-kernel | |||
@@ -221,6 +221,28 @@ def yocto_kernel_feature_rm_subcommand(args, usage_str): | |||
221 | yocto_kernel_feature_rm(scripts_path, args[0]) | 221 | yocto_kernel_feature_rm(scripts_path, args[0]) |
222 | 222 | ||
223 | 223 | ||
224 | def yocto_kernel_available_features_list_subcommand(args, usage_str): | ||
225 | """ | ||
226 | Command-line handling for listing all the kernel features | ||
227 | available for use in a BSP. This includes the features present in | ||
228 | the meta branch(es) of the pointed-to repo(s) as well as the local | ||
229 | features added in recipe-space to the current BSP as well. The | ||
230 | real work is done by bsp.kernel.yocto_kernel_available_features_list(). | ||
231 | """ | ||
232 | logging.debug("yocto_kernel_feature_available_features_list_subcommand") | ||
233 | |||
234 | parser = optparse.OptionParser(usage = usage_str) | ||
235 | |||
236 | (options, args) = parser.parse_args(args) | ||
237 | |||
238 | if len(args) != 1: | ||
239 | logging.error("Wrong number of arguments, exiting\n") | ||
240 | parser.print_help() | ||
241 | sys.exit(1) | ||
242 | |||
243 | yocto_kernel_available_features_list(scripts_path, args[0]) | ||
244 | |||
245 | |||
224 | subcommands = { | 246 | subcommands = { |
225 | "config-list": [yocto_kernel_config_list_subcommand, | 247 | "config-list": [yocto_kernel_config_list_subcommand, |
226 | yocto_kernel_config_list_usage, | 248 | yocto_kernel_config_list_usage, |
@@ -249,6 +271,9 @@ subcommands = { | |||
249 | "feature-rm": [yocto_kernel_feature_rm_subcommand, | 271 | "feature-rm": [yocto_kernel_feature_rm_subcommand, |
250 | yocto_kernel_feature_rm_usage, | 272 | yocto_kernel_feature_rm_usage, |
251 | yocto_kernel_feature_rm_help], | 273 | yocto_kernel_feature_rm_help], |
274 | "features-list": [yocto_kernel_available_features_list_subcommand, | ||
275 | yocto_kernel_available_features_list_usage, | ||
276 | yocto_kernel_available_features_list_help], | ||
252 | } | 277 | } |
253 | 278 | ||
254 | 279 | ||
@@ -281,7 +306,7 @@ def main(): | |||
281 | sc = 0 | 306 | sc = 0 |
282 | 307 | ||
283 | if args[sc] == "config" or args[sc] == "patch" or \ | 308 | if args[sc] == "config" or args[sc] == "patch" or \ |
284 | args[sc] == "feature": | 309 | args[sc] == "feature" or args[sc] == "features": |
285 | if len(args) < 2 + sc: | 310 | if len(args) < 2 + sc: |
286 | parser.print_help() | 311 | parser.print_help() |
287 | sys.exit(1) | 312 | sys.exit(1) |