diff options
author | Tom Zanussi <tom.zanussi@linux.intel.com> | 2013-03-11 18:52:50 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-03-17 23:10:28 +0000 |
commit | 0bfe83edbb65f94fca8028be0ca20fdfec5ffc81 (patch) | |
tree | a53b8b15769ac71156b2a3e400f7d44b5d0b6375 /scripts/lib/bsp | |
parent | 6911fd0889261fb173775727db61dffaac355ed7 (diff) | |
download | ast2050-yocto-poky-0bfe83edbb65f94fca8028be0ca20fdfec5ffc81.zip ast2050-yocto-poky-0bfe83edbb65f94fca8028be0ca20fdfec5ffc81.tar.gz |
yocto-kernel: add support for kernel feature add/rm/list
Add yocto-kernel commands allowing users to add, remove, and list
kernel features with respect to a given BSP.
Features managed by these commands modify a special
machine-user-features.scc file associated with the kernel recipe
(.bbappend) of a yocto-bsp-generated BSP. This is analagous to the
implementation of similar support for bare config items and patches
already implemented for yocto-bsp-generated BSPs.
Future patches will add support for providing a list of eligible
features as defined by linux-yocto kernels and locally-defined
(recipe-space) kernel features.
(From meta-yocto rev: ae68d906c5c9854f2cd7ee0870556fbfbd7d94d0)
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/bsp')
-rw-r--r-- | scripts/lib/bsp/help.py | 98 | ||||
-rw-r--r-- | scripts/lib/bsp/kernel.py | 99 |
2 files changed, 197 insertions, 0 deletions
diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py index 346bf0f..2d7b6fe 100644 --- a/scripts/lib/bsp/help.py +++ b/scripts/lib/bsp/help.py @@ -383,6 +383,9 @@ yocto_kernel_usage = """ patch list List the patches associated with a BSP patch add Patch the Yocto kernel for a BSP patch rm Remove patches from a BSP + feature list List the features used by a BSP + feature add Have a BSP use a feature + feature rm Have a BSP stop using a feature See 'yocto-kernel help COMMAND' for more information on a specific command. @@ -594,6 +597,101 @@ DESCRIPTION remove. """ +yocto_kernel_feature_list_usage = """ + + List the BSP features that are being used by a BSP + + usage: yocto-kernel feature list <bsp-name> + + This command lists the features being used by a BSP i.e. the features + which are eligible for modification or removal by other yocto-kernel + commands. + + 'modifiable' features are the features listed in a BSP's + user-features.scc file. +""" + + +yocto_kernel_feature_list_help = """ + +NAME + yocto-kernel feature list - List the modifiable set of features + being used by a BSP + +SYNOPSIS + yocto-kernel feature list <bsp-name> + +DESCRIPTION + This command lists the 'modifiable' features being used by a BSP + i.e. the features which are eligible for modification or removal + by other yocto-kernel commands. +""" + + +yocto_kernel_feature_add_usage = """ + + Add to or modify the list of features being used for a BSP + + usage: yocto-kernel feature add <bsp-name> [/xxxx/yyyy/feature.scc ...] + + This command adds one or more feature items to a BSP's kernel + user-features.scc file, which is the file used to manage features in + a yocto-bsp-generated BSP. Features to be added must be specified as + fully-qualified feature names. +""" + + +yocto_kernel_feature_add_help = """ + +NAME + yocto-kernel feature add - Add to or modify the list of features + being used for a BSP + +SYNOPSIS + yocto-kernel feature add <bsp-name> [/xxxx/yyyy/feature.scc ...] + +DESCRIPTION + This command adds one or more feature items to a BSP's + user-features.scc file, which is the file used to manage features + in a yocto-bsp-generated BSP. Features to be added must be + specified as fully-qualified feature names. +""" + + +yocto_kernel_feature_rm_usage = """ + + Remove a feature from the list of features being used for a BSP + + usage: yocto-kernel feature rm <bsp-name> + + This command removes (turns off) one or more features from a BSP's + user-features.scc file, which is the file used to manage features in + a yocto-bsp-generated BSP. + + The set of features available to be removed by this command for a BSP + is listed and the user prompted for the specific items to remove. +""" + + +yocto_kernel_feature_rm_help = """ + +NAME + yocto-kernel feature rm - Remove a feature from the list of + features being used for a BSP + +SYNOPSIS + yocto-kernel feature rm <bsp-name> + +DESCRIPTION + This command removes (turns off) one or more features from a BSP's + user-features.scc file, which is the file used to manage features + in a yocto-bsp-generated BSP. + + The set of features available to be removed by this command for a + BSP is listed and the user prompted for the specific items to + remove. +""" + ## # yocto-layer help and usage strings ## diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py index dabb9cf..0fa228a 100644 --- a/scripts/lib/bsp/kernel.py +++ b/scripts/lib/bsp/kernel.py @@ -552,6 +552,105 @@ def find_giturl(context): return None + +def read_features(scripts_path, machine): + """ + Find and return a list of features in a machine's user-defined + features fragment [${machine}-user-features.scc]. + """ + features = [] + + f = open_user_file(scripts_path, machine, machine+"-user-features.scc", "r") + lines = f.readlines() + for line in lines: + s = line.strip() + if s and not s.startswith("#"): + feature_include = s.split() + features.append(feature_include[1].strip()) + f.close() + + return features + + +def write_features(scripts_path, machine, features): + """ + Write (replace) the list of feature items in a + machine's user-defined features fragment [${machine}=user-features.cfg]. + """ + f = open_user_file(scripts_path, machine, machine+"-user-features.scc", "w") + for item in features: + f.write("include " + item + "\n") + f.close() + + kernel_contents_changed(scripts_path, machine) + + +def yocto_kernel_feature_list(scripts_path, machine): + """ + Display the list of features used in a machine's user-defined + features fragment [${machine}-user-features.scc]. + """ + features = read_features(scripts_path, machine) + + print "The current set of machine-specific features for %s is:" % machine + print gen_choices_str(features) + + +def yocto_kernel_feature_rm(scripts_path, machine): + """ + Display the list of features used in a machine's user-defined + features fragment [${machine}-user-features.scc], prompt the user + for one or more to remove, and remove them. + """ + features = read_features(scripts_path, machine) + + print "Specify the features to remove:" + input = raw_input(gen_choices_str(features)) + rm_choices = input.split() + rm_choices.sort() + + removed = [] + + for choice in reversed(rm_choices): + try: + idx = int(choice) - 1 + except ValueError: + print "Invalid choice (%s), exiting" % choice + sys.exit(1) + if idx < 0 or idx >= len(features): + print "Invalid choice (%d), exiting" % (idx + 1) + sys.exit(1) + removed.append(features.pop(idx)) + + write_features(scripts_path, machine, features) + + print "Removed features:" + for r in removed: + print "\t%s" % r + + +def yocto_kernel_feature_add(scripts_path, machine, features): + """ + Add one or more features a machine's user-defined features + fragment [${machine}-user-features.scc]. + """ + new_items = [] + + for item in features: + if not item.endswith(".scc"): + print "Invalid feature (%s), exiting" % item + sys.exit(1) + new_items.append(item) + + cur_items = read_features(scripts_path, machine) + cur_items.extend(new_items) + + write_features(scripts_path, machine, cur_items) + + print "Added features:" + for n in new_items: + print "\t%s" % n + def base_branches(context): """ |