diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-05-30 10:20:59 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-01 12:38:41 +0100 |
commit | 2b510f5e018fed5f0e679d887656a501a6a38aaa (patch) | |
tree | 8cbe6c7f640defa9137229edd0feb3b1ee644f49 /scripts/lib/recipetool/create_buildsys.py | |
parent | c056dad62cdc4d4043e8ac91ff103d234005660f (diff) | |
download | poky-2b510f5e018fed5f0e679d887656a501a6a38aaa.tar.gz |
recipetool: create: support extracting SUMMARY and HOMEPAGE
Allow plugins to set any variable value through the extravalues dict,
and use this to support extracting SUMMARY and HOMEPAGE values from spec
files included with the source; additionally translate "License:" to a
comment next to the LICENSE field (we have our own logic for setting
LICENSE, but it will often be useful to see what the spec file says if
one is present).
Also use the same mechanism for setting the same variables for node.js
modules; this was already supported but wasn't inserting the settings in
the appropriate place in the file which this will now do.
(From OE-Core rev: 91fc35ff5e89aa6d4c4ad945e45406fb4f71018e)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/recipetool/create_buildsys.py')
-rw-r--r-- | scripts/lib/recipetool/create_buildsys.py | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/scripts/lib/recipetool/create_buildsys.py b/scripts/lib/recipetool/create_buildsys.py index f84ec3dc6c..37d161ef0f 100644 --- a/scripts/lib/recipetool/create_buildsys.py +++ b/scripts/lib/recipetool/create_buildsys.py | |||
@@ -830,22 +830,35 @@ class SpecFileRecipeHandler(RecipeHandler): | |||
830 | if 'PV' in extravalues and 'PN' in extravalues: | 830 | if 'PV' in extravalues and 'PN' in extravalues: |
831 | return | 831 | return |
832 | filelist = RecipeHandler.checkfiles(srctree, ['*.spec'], recursive=True) | 832 | filelist = RecipeHandler.checkfiles(srctree, ['*.spec'], recursive=True) |
833 | pn = None | 833 | valuemap = {'Name': 'PN', |
834 | pv = None | 834 | 'Version': 'PV', |
835 | 'Summary': 'SUMMARY', | ||
836 | 'Url': 'HOMEPAGE', | ||
837 | 'License': 'LICENSE'} | ||
838 | foundvalues = {} | ||
835 | for fileitem in filelist: | 839 | for fileitem in filelist: |
836 | linecount = 0 | 840 | linecount = 0 |
837 | with open(fileitem, 'r') as f: | 841 | with open(fileitem, 'r') as f: |
838 | for line in f: | 842 | for line in f: |
839 | if line.startswith('Name:') and not pn: | 843 | for value, varname in valuemap.iteritems(): |
840 | pn = line.split(':')[1].strip() | 844 | if line.startswith(value + ':') and not varname in foundvalues: |
841 | if line.startswith('Version:') and not pv: | 845 | foundvalues[varname] = line.split(':', 1)[1].strip() |
842 | pv = line.split(':')[1].strip() | 846 | break |
843 | if pv or pn: | 847 | if len(foundvalues) == len(valuemap): |
844 | if pv and not 'PV' in extravalues and validate_pv(pv): | 848 | break |
845 | extravalues['PV'] = pv | 849 | if 'PV' in foundvalues: |
846 | if pn and not 'PN' in extravalues: | 850 | if not validate_pv(foundvalues['PV']): |
847 | extravalues['PN'] = pn | 851 | del foundvalues['PV'] |
848 | break | 852 | license = foundvalues.pop('LICENSE', None) |
853 | if license: | ||
854 | liccomment = '# NOTE: spec file indicates the license may be "%s"' % license | ||
855 | for i, line in enumerate(lines_before): | ||
856 | if line.startswith('LICENSE ='): | ||
857 | lines_before.insert(i, liccomment) | ||
858 | break | ||
859 | else: | ||
860 | lines_before.append(liccomment) | ||
861 | extravalues.update(foundvalues) | ||
849 | 862 | ||
850 | def register_recipe_handlers(handlers): | 863 | def register_recipe_handlers(handlers): |
851 | # Set priorities with some gaps so that other plugins can insert | 864 | # Set priorities with some gaps so that other plugins can insert |