diff options
| author | Tom Zanussi <tom.zanussi@intel.com> | 2013-03-11 22:36:44 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-03-17 23:10:28 +0000 |
| commit | 8c9320cc922a165946ac557f0bda2e29ab794951 (patch) | |
| tree | fa84332422b156ae252821b163ca5e6a2d74cb1e /scripts/lib/bsp | |
| parent | 5edc7af428cccfbf53780fc98ed1685b655f43d1 (diff) | |
| download | poky-8c9320cc922a165946ac557f0bda2e29ab794951.tar.gz | |
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>
Diffstat (limited to 'scripts/lib/bsp')
| -rw-r--r-- | scripts/lib/bsp/help.py | 31 | ||||
| -rw-r--r-- | scripts/lib/bsp/kernel.py | 79 |
2 files changed, 110 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 = """ | |||
| 389 | features list List the features available to BSPs | 389 | features list List the features available to BSPs |
| 390 | feature describe Describe a particular feature | 390 | feature describe Describe a particular feature |
| 391 | feature create Create a new BSP-local feature | 391 | feature create Create a new BSP-local feature |
| 392 | feature destroy Remove a BSP-local feature | ||
| 392 | 393 | ||
| 393 | See 'yocto-kernel help COMMAND' for more information on a specific command. | 394 | See 'yocto-kernel help COMMAND' for more information on a specific command. |
| 394 | 395 | ||
| @@ -788,6 +789,36 @@ DESCRIPTION | |||
| 788 | (which for the time being can be one of: 'all' or 'board'). | 789 | (which for the time being can be one of: 'all' or 'board'). |
| 789 | """ | 790 | """ |
| 790 | 791 | ||
| 792 | |||
| 793 | yocto_kernel_feature_destroy_usage = """ | ||
| 794 | |||
| 795 | Destroy a recipe-space kernel feature in a BSP | ||
| 796 | |||
| 797 | usage: yocto-kernel feature destroy <bsp-name> feature.scc | ||
| 798 | |||
| 799 | This command destroys a kernel feature defined in the specified BSP's | ||
| 800 | recipe-space kernel definition. | ||
| 801 | """ | ||
| 802 | |||
| 803 | |||
| 804 | yocto_kernel_feature_destroy_help = """ | ||
| 805 | |||
| 806 | NAME | ||
| 807 | yocto-kernel feature destroy <bsp-name> feature.scc - destroy a | ||
| 808 | recipe-space kernel feature in a BSP | ||
| 809 | |||
| 810 | SYNOPSIS | ||
| 811 | yocto-kernel feature destroy <bsp-name> feature.scc | ||
| 812 | |||
| 813 | DESCRIPTION | ||
| 814 | This command destroys a kernel feature defined in the specified | ||
| 815 | BSP's recipe-space kernel definition. The named feature must end | ||
| 816 | with .scc and must not contain a feature directory to contain the | ||
| 817 | feature (this will be determined automatically). If the kernel | ||
| 818 | feature is in use by a BSP, it can't be removed until the BSP | ||
| 819 | stops using it (see yocto-kernel feature rm to stop using it). | ||
| 820 | """ | ||
| 821 | |||
| 791 | ## | 822 | ## |
| 792 | # yocto-layer help and usage strings | 823 | # yocto-layer help and usage strings |
| 793 | ## | 824 | ## |
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): | |||
| 910 | print "\t%s" % feature_dirname + "/" + feature | 910 | print "\t%s" % feature_dirname + "/" + feature |
| 911 | 911 | ||
| 912 | 912 | ||
| 913 | def feature_in_use(scripts_path, machine, feature): | ||
| 914 | """ | ||
| 915 | Determine whether the specified feature is in use by the BSP. | ||
| 916 | Return True if so, False otherwise. | ||
| 917 | """ | ||
| 918 | features = read_features(scripts_path, machine) | ||
| 919 | for f in features: | ||
| 920 | if f == feature: | ||
| 921 | return True | ||
| 922 | return False | ||
| 923 | |||
| 924 | |||
| 925 | def feature_remove(scripts_path, machine, feature): | ||
| 926 | """ | ||
| 927 | Remove the specified feature from the available recipe-space | ||
| 928 | features defined for the BSP. | ||
| 929 | """ | ||
| 930 | features = read_features(scripts_path, machine) | ||
| 931 | new_features = [] | ||
| 932 | for f in features: | ||
| 933 | if f == feature: | ||
| 934 | continue | ||
| 935 | new_features.append(f) | ||
| 936 | write_features(scripts_path, machine, new_features) | ||
| 937 | |||
| 938 | |||
| 939 | def yocto_kernel_feature_destroy(scripts_path, machine, feature): | ||
| 940 | """ | ||
| 941 | Remove a recipe-space kernel feature from a BSP. | ||
| 942 | """ | ||
| 943 | if not check_feature_name(feature): | ||
| 944 | sys.exit(1) | ||
| 945 | |||
| 946 | if feature_in_use(scripts_path, machine, "features/" + feature) or \ | ||
| 947 | feature_in_use(scripts_path, machine, "cfg/" + feature): | ||
| 948 | print "Feature %s is in use (use 'feature rm' to un-use it first), exiting" % feature | ||
| 949 | sys.exit(1) | ||
| 950 | |||
| 951 | filesdir = find_filesdir(scripts_path, machine) | ||
| 952 | if not filesdir: | ||
| 953 | print "Couldn't destroy feature (%s), no 'files' dir found" % feature | ||
| 954 | sys.exit(1) | ||
| 955 | |||
| 956 | feature_dirname = "features" | ||
| 957 | featdir = os.path.join(filesdir, feature_dirname) | ||
| 958 | if not os.path.exists(featdir): | ||
| 959 | print "Couldn't find feature directory (%s)" % feature_dirname | ||
| 960 | sys.exit(1) | ||
| 961 | |||
| 962 | feature_fqn = os.path.join(featdir, feature) | ||
| 963 | if not os.path.exists(feature_fqn): | ||
| 964 | feature_dirname = "cfg" | ||
| 965 | featdir = os.path.join(filesdir, feature_dirname) | ||
| 966 | if not os.path.exists(featdir): | ||
| 967 | print "Couldn't find feature directory (%s)" % feature_dirname | ||
| 968 | sys.exit(1) | ||
| 969 | feature_fqn = os.path.join(featdir, feature_filename) | ||
| 970 | if not os.path.exists(feature_fqn): | ||
| 971 | print "Couldn't find feature (%s)" % feature | ||
| 972 | sys.exit(1) | ||
| 973 | |||
| 974 | f = open(feature_fqn, "r") | ||
| 975 | lines = f.readlines() | ||
| 976 | for line in lines: | ||
| 977 | s = line.strip() | ||
| 978 | if s.startswith("patch ") or s.startswith("kconf "): | ||
| 979 | split_line = s.split() | ||
| 980 | filename = os.path.join(featdir, split_line[-1]) | ||
| 981 | if os.path.exists(filename): | ||
| 982 | os.remove(filename) | ||
| 983 | f.close() | ||
| 984 | os.remove(feature_fqn) | ||
| 985 | |||
| 986 | feature_remove(scripts_path, machine, feature) | ||
| 987 | |||
| 988 | print "Removed feature:" | ||
| 989 | print "\t%s" % feature_dirname + "/" + feature | ||
| 990 | |||
| 991 | |||
| 913 | def base_branches(context): | 992 | def base_branches(context): |
| 914 | """ | 993 | """ |
| 915 | Return a list of the base branches found in the kernel git repo. | 994 | Return a list of the base branches found in the kernel git repo. |
