summaryrefslogtreecommitdiffstats
path: root/scripts/lib/bsp/kernel.py
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@intel.com>2013-03-11 22:19:07 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-17 23:10:28 +0000
commit5edc7af428cccfbf53780fc98ed1685b655f43d1 (patch)
tree8a2d19445c3761229cae00d52dcb17d14ee0ea15 /scripts/lib/bsp/kernel.py
parent2518215438119804290aa8149936ebde0fcc89d3 (diff)
downloadpoky-5edc7af428cccfbf53780fc98ed1685b655f43d1.tar.gz
yocto-kernel: add support for creating recipe-space kernel features
Add a yocto-kernel command allowing users to create a recipe-space kernel feature local to a particular BSP. The new feature is subsequently available for the normal feature addition and removal yocto-kernel commands used with features defined in the meta branch of linux-yocto kernel repos. (From meta-yocto rev: 13abcd93b9e1591bc45ff5f9eb17b8feb9ac9ae5) Signed-off-by: Tom Zanussi <tom.zanussi@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.py103
1 files changed, 102 insertions, 1 deletions
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py
index ac0b074b5d..ac6861e14b 100644
--- a/scripts/lib/bsp/kernel.py
+++ b/scripts/lib/bsp/kernel.py
@@ -808,7 +808,108 @@ def yocto_kernel_feature_describe(scripts_path, machine, feature):
808 808
809 print desc 809 print desc
810 810
811 811
812def check_feature_name(feature_name):
813 """
814 Sanity-check the feature name for create/destroy. Return False if not OK.
815 """
816 if not feature_name.endswith(".scc"):
817 print "Invalid feature name (must end with .scc) [%s], exiting" % feature_name
818 return False
819
820 if "/" in feature_name:
821 print "Invalid feature name (don't specify directory) [%s], exiting" % feature_name
822 return False
823
824 return True
825
826
827def check_create_input(feature_items):
828 """
829 Sanity-check the create input. Return False if not OK.
830 """
831 if not check_feature_name(feature_items[0]):
832 return False
833
834 if feature_items[1].endswith(".patch") or feature_items[1].startswith("CONFIG_"):
835 print "Missing description and/or compatibilty [%s], exiting" % feature_items[1]
836 return False
837
838 if feature_items[2].endswith(".patch") or feature_items[2].startswith("CONFIG_"):
839 print "Missing description and/or compatibility [%s], exiting" % feature_items[1]
840 return False
841
842 return True
843
844
845def yocto_kernel_feature_create(scripts_path, machine, feature_items):
846 """
847 Create a recipe-space kernel feature in a BSP.
848 """
849 if not check_create_input(feature_items):
850 sys.exit(1)
851
852 feature = feature_items[0]
853 feature_basename = feature.split(".")[0]
854 feature_description = feature_items[1]
855 feature_compat = feature_items[2]
856
857 patches = []
858 cfg_items = []
859
860 for item in feature_items[3:]:
861 if item.endswith(".patch"):
862 patches.append(item)
863 elif item.startswith("CONFIG"):
864 if ("=y" in item or "=m" in item):
865 cfg_items.append(item)
866 else:
867 print "Invalid feature item (must be .patch or CONFIG_*) [%s], exiting" % item
868 sys.exit(1)
869
870 feature_dirname = "cfg"
871 if patches:
872 feature_dirname = "features"
873
874 filesdir = find_filesdir(scripts_path, machine)
875 if not filesdir:
876 print "Couldn't add feature (%s), no 'files' dir found" % feature
877 sys.exit(1)
878
879 featdir = os.path.join(filesdir, feature_dirname)
880 if not os.path.exists(featdir):
881 os.mkdir(featdir)
882
883 for patch in patches:
884 if not os.path.isfile(patch):
885 print "Couldn't find patch (%s), exiting" % patch
886 sys.exit(1)
887 basename = os.path.basename(patch)
888 featdir_patch = os.path.join(featdir, basename)
889 shutil.copyfile(patch, featdir_patch)
890
891 new_cfg_filename = os.path.join(featdir, feature_basename + ".cfg")
892 new_cfg_file = open(new_cfg_filename, "w")
893 for cfg_item in cfg_items:
894 new_cfg_file.write(cfg_item + "\n")
895 new_cfg_file.close()
896
897 new_feature_filename = os.path.join(featdir, feature_basename + ".scc")
898 new_feature_file = open(new_feature_filename, "w")
899 new_feature_file.write("define KFEATURE_DESCRIPTION \"" + feature_description + "\"\n")
900 new_feature_file.write("define KFEATURE_COMPATIBILITY " + feature_compat + "\n\n")
901
902 for patch in patches:
903 patch_dir, patch_file = os.path.split(patch)
904 new_feature_file.write("patch " + patch_file + "\n")
905
906 new_feature_file.write("kconf non-hardware " + feature_basename + ".cfg\n")
907 new_feature_file.close()
908
909 print "Added feature:"
910 print "\t%s" % feature_dirname + "/" + feature
911
912
812def base_branches(context): 913def base_branches(context):
813 """ 914 """
814 Return a list of the base branches found in the kernel git repo. 915 Return a list of the base branches found in the kernel git repo.