summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@intel.com>2013-03-12 02:25:46 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-17 23:10:28 (GMT)
commit934f2ed2539e046f91a234d30fc4da71ffbe28a0 (patch)
treed23b6fdda5c60c2ac29df1f1a923b6bb93786603 /scripts/lib
parent0bfe83edbb65f94fca8028be0ca20fdfec5ffc81 (diff)
downloadpoky-934f2ed2539e046f91a234d30fc4da71ffbe28a0.tar.gz
yocto-kernel: add support for listing available kernel features
Add a yocto-kernel command allowing users to list all the kernel features available to a BSP. This includes the features contained in linux-yocto meta branches as well as recipe-space features defined locally to the BSP. (From meta-yocto rev: 12f3af8d92456ad9212170decdbe102fc78b58f6) Signed-off-by: Tom Zanussi <tom.zanussi@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/bsp/help.py31
-rw-r--r--scripts/lib/bsp/kernel.py107
2 files changed, 138 insertions, 0 deletions
diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py
index 2d7b6fe..9ba6a93 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
697yocto_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
709yocto_kernel_available_features_list_help = """
710
711NAME
712 yocto-kernel features list - List the set of kernel features
713 available to a BSP
714
715SYNOPSIS
716 yocto-kernel features list <bsp-name>
717
718DESCRIPTION
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 0fa228a..0308600 100644
--- a/scripts/lib/bsp/kernel.py
+++ b/scripts/lib/bsp/kernel.py
@@ -32,6 +32,7 @@ import shutil
32from tags import * 32from tags import *
33import glob 33import glob
34import subprocess 34import subprocess
35from engine import create_context
35 36
36 37
37def find_bblayers(scripts_path): 38def 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
656def 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
673def 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
698def 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
716def 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
655def base_branches(context): 762def base_branches(context):
656 """ 763 """