summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@intel.com>2013-03-11 22:36:44 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-17 23:10:28 +0000
commitef3e53cbfcd3340c5a132107b22a7c878e7ee3ab (patch)
treebc76fc54cac4e97938c34ab4815ec9b21c0ab51b
parentdf6588d42895d3b2b923d46f06c8ab9564a85ce3 (diff)
downloadtizen-distro-ef3e53cbfcd3340c5a132107b22a7c878e7ee3ab.tar.gz
tizen-distro-ef3e53cbfcd3340c5a132107b22a7c878e7ee3ab.tar.bz2
tizen-distro-ef3e53cbfcd3340c5a132107b22a7c878e7ee3ab.zip
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 <tom.zanussi@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/bsp/help.py31
-rw-r--r--scripts/lib/bsp/kernel.py79
-rwxr-xr-xscripts/yocto-kernel23
3 files changed, 133 insertions, 0 deletions
diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py
index d7c0360a7a..427b5a00e9 100644
--- a/scripts/lib/bsp/help.py
+++ b/scripts/lib/bsp/help.py
@@ -389,6 +389,7 @@ yocto_kernel_usage = """
features list List the features available to BSPs
feature describe Describe a particular feature
feature create Create a new BSP-local feature
+ feature destroy Remove a BSP-local feature
See 'yocto-kernel help COMMAND' for more information on a specific command.
@@ -788,6 +789,36 @@ DESCRIPTION
(which for the time being can be one of: 'all' or 'board').
"""
+
+yocto_kernel_feature_destroy_usage = """
+
+ Destroy a recipe-space kernel feature in a BSP
+
+ usage: yocto-kernel feature destroy <bsp-name> feature.scc
+
+ This command destroys a kernel feature defined in the specified BSP's
+ recipe-space kernel definition.
+"""
+
+
+yocto_kernel_feature_destroy_help = """
+
+NAME
+ yocto-kernel feature destroy <bsp-name> feature.scc - destroy a
+ recipe-space kernel feature in a BSP
+
+SYNOPSIS
+ yocto-kernel feature destroy <bsp-name> feature.scc
+
+DESCRIPTION
+ This command destroys a kernel feature defined in the specified
+ BSP's recipe-space kernel definition. The named feature must end
+ with .scc and must not contain a feature directory to contain the
+ feature (this will be determined automatically). If the kernel
+ feature is in use by a BSP, it can't be removed until the BSP
+ stops using it (see yocto-kernel feature rm to stop using it).
+"""
+
##
# yocto-layer help and usage strings
##
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.
diff --git a/scripts/yocto-kernel b/scripts/yocto-kernel
index 69fe344d8d..c9b2821e00 100755
--- a/scripts/yocto-kernel
+++ b/scripts/yocto-kernel
@@ -287,6 +287,26 @@ def yocto_kernel_feature_create_subcommand(args, usage_str):
yocto_kernel_feature_create(scripts_path, machine, args)
+def yocto_kernel_feature_destroy_subcommand(args, usage_str):
+ """
+ Command-line handling for removing a recipe-space kernel feature
+ from a BSP. The real work is done by
+ bsp.kernel.yocto_kernel_feature_destroy().
+ """
+ logging.debug("yocto_kernel_feature_destroy_subcommand")
+
+ parser = optparse.OptionParser(usage = usage_str)
+
+ (options, args) = parser.parse_args(args)
+
+ if len(args) != 2:
+ logging.error("Wrong number of arguments, exiting\n")
+ parser.print_help()
+ sys.exit(1)
+
+ yocto_kernel_feature_destroy(scripts_path, args[0], args[1])
+
+
subcommands = {
"config-list": [yocto_kernel_config_list_subcommand,
yocto_kernel_config_list_usage,
@@ -324,6 +344,9 @@ subcommands = {
"feature-create": [yocto_kernel_feature_create_subcommand,
yocto_kernel_feature_create_usage,
yocto_kernel_feature_create_help],
+ "feature-destroy": [yocto_kernel_feature_destroy_subcommand,
+ yocto_kernel_feature_destroy_usage,
+ yocto_kernel_feature_destroy_help],
}