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>
This commit is contained in:
parent
5edc7af428
commit
8c9320cc92
|
@ -389,6 +389,7 @@ yocto_kernel_usage = """
|
||||||
features list List the features available to BSPs
|
features list List the features available to BSPs
|
||||||
feature describe Describe a particular feature
|
feature describe Describe a particular feature
|
||||||
feature create Create a new BSP-local 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.
|
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').
|
(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
|
# yocto-layer help and usage strings
|
||||||
##
|
##
|
||||||
|
|
|
@ -910,6 +910,85 @@ def yocto_kernel_feature_create(scripts_path, machine, feature_items):
|
||||||
print "\t%s" % feature_dirname + "/" + feature
|
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):
|
def base_branches(context):
|
||||||
"""
|
"""
|
||||||
Return a list of the base branches found in the kernel git repo.
|
Return a list of the base branches found in the kernel git repo.
|
||||||
|
|
|
@ -287,6 +287,26 @@ def yocto_kernel_feature_create_subcommand(args, usage_str):
|
||||||
yocto_kernel_feature_create(scripts_path, machine, args)
|
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 = {
|
subcommands = {
|
||||||
"config-list": [yocto_kernel_config_list_subcommand,
|
"config-list": [yocto_kernel_config_list_subcommand,
|
||||||
yocto_kernel_config_list_usage,
|
yocto_kernel_config_list_usage,
|
||||||
|
@ -324,6 +344,9 @@ subcommands = {
|
||||||
"feature-create": [yocto_kernel_feature_create_subcommand,
|
"feature-create": [yocto_kernel_feature_create_subcommand,
|
||||||
yocto_kernel_feature_create_usage,
|
yocto_kernel_feature_create_usage,
|
||||||
yocto_kernel_feature_create_help],
|
yocto_kernel_feature_create_help],
|
||||||
|
"feature-destroy": [yocto_kernel_feature_destroy_subcommand,
|
||||||
|
yocto_kernel_feature_destroy_usage,
|
||||||
|
yocto_kernel_feature_destroy_help],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue