1
0
mirror of https://git.yoctoproject.org/poky synced 2026-07-27 07:27:12 +00:00

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>
This commit is contained in:
Paul Eggleton
2016-05-30 10:20:59 +12:00
committed by Richard Purdie
parent c056dad62c
commit 2b510f5e01
3 changed files with 54 additions and 36 deletions
+25 -12
View File
@@ -830,22 +830,35 @@ class SpecFileRecipeHandler(RecipeHandler):
if 'PV' in extravalues and 'PN' in extravalues:
return
filelist = RecipeHandler.checkfiles(srctree, ['*.spec'], recursive=True)
pn = None
pv = None
valuemap = {'Name': 'PN',
'Version': 'PV',
'Summary': 'SUMMARY',
'Url': 'HOMEPAGE',
'License': 'LICENSE'}
foundvalues = {}
for fileitem in filelist:
linecount = 0
with open(fileitem, 'r') as f:
for line in f:
if line.startswith('Name:') and not pn:
pn = line.split(':')[1].strip()
if line.startswith('Version:') and not pv:
pv = line.split(':')[1].strip()
if pv or pn:
if pv and not 'PV' in extravalues and validate_pv(pv):
extravalues['PV'] = pv
if pn and not 'PN' in extravalues:
extravalues['PN'] = pn
break
for value, varname in valuemap.iteritems():
if line.startswith(value + ':') and not varname in foundvalues:
foundvalues[varname] = line.split(':', 1)[1].strip()
break
if len(foundvalues) == len(valuemap):
break
if 'PV' in foundvalues:
if not validate_pv(foundvalues['PV']):
del foundvalues['PV']
license = foundvalues.pop('LICENSE', None)
if license:
liccomment = '# NOTE: spec file indicates the license may be "%s"' % license
for i, line in enumerate(lines_before):
if line.startswith('LICENSE ='):
lines_before.insert(i, liccomment)
break
else:
lines_before.append(liccomment)
extravalues.update(foundvalues)
def register_recipe_handlers(handlers):
# Set priorities with some gaps so that other plugins can insert