From 8c9320cc922a165946ac557f0bda2e29ab794951 Mon Sep 17 00:00:00 2001 From: Tom Zanussi Date: Mon, 11 Mar 2013 22:36:44 -0500 Subject: yocto-kernel: add support for destroying recipe-space kernel features Add a yocto-kernel command allowing users to destroy a recipe-space kernel feature local to a particular BSP. The removed feature is subsequently no longer available for the normal feature addition and removal yocto-kernel commands. (From meta-yocto rev: faa18f56d9412694f2c8e0b0c09e751cb7f3a743) Signed-off-by: Tom Zanussi Signed-off-by: Richard Purdie --- scripts/lib/bsp/kernel.py | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'scripts/lib/bsp/kernel.py') diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py index ac6861e14b..fc1e6bdd08 100644 --- a/scripts/lib/bsp/kernel.py +++ b/scripts/lib/bsp/kernel.py @@ -910,6 +910,85 @@ def yocto_kernel_feature_create(scripts_path, machine, feature_items): print "\t%s" % feature_dirname + "/" + feature +def feature_in_use(scripts_path, machine, feature): + """ + Determine whether the specified feature is in use by the BSP. + Return True if so, False otherwise. + """ + features = read_features(scripts_path, machine) + for f in features: + if f == feature: + return True + return False + + +def feature_remove(scripts_path, machine, feature): + """ + Remove the specified feature from the available recipe-space + features defined for the BSP. + """ + features = read_features(scripts_path, machine) + new_features = [] + for f in features: + if f == feature: + continue + new_features.append(f) + write_features(scripts_path, machine, new_features) + + +def yocto_kernel_feature_destroy(scripts_path, machine, feature): + """ + Remove a recipe-space kernel feature from a BSP. + """ + if not check_feature_name(feature): + sys.exit(1) + + if feature_in_use(scripts_path, machine, "features/" + feature) or \ + feature_in_use(scripts_path, machine, "cfg/" + feature): + print "Feature %s is in use (use 'feature rm' to un-use it first), exiting" % feature + sys.exit(1) + + filesdir = find_filesdir(scripts_path, machine) + if not filesdir: + print "Couldn't destroy feature (%s), no 'files' dir found" % feature + sys.exit(1) + + feature_dirname = "features" + featdir = os.path.join(filesdir, feature_dirname) + if not os.path.exists(featdir): + print "Couldn't find feature directory (%s)" % feature_dirname + sys.exit(1) + + feature_fqn = os.path.join(featdir, feature) + if not os.path.exists(feature_fqn): + feature_dirname = "cfg" + featdir = os.path.join(filesdir, feature_dirname) + if not os.path.exists(featdir): + print "Couldn't find feature directory (%s)" % feature_dirname + sys.exit(1) + feature_fqn = os.path.join(featdir, feature_filename) + if not os.path.exists(feature_fqn): + print "Couldn't find feature (%s)" % feature + sys.exit(1) + + f = open(feature_fqn, "r") + lines = f.readlines() + for line in lines: + s = line.strip() + if s.startswith("patch ") or s.startswith("kconf "): + split_line = s.split() + filename = os.path.join(featdir, split_line[-1]) + if os.path.exists(filename): + os.remove(filename) + f.close() + os.remove(feature_fqn) + + feature_remove(scripts_path, machine, feature) + + print "Removed feature:" + print "\t%s" % feature_dirname + "/" + feature + + def base_branches(context): """ Return a list of the base branches found in the kernel git repo. -- cgit v1.2.3-54-g00ecf