summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-05-30 10:20:59 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-01 12:38:41 +0100
commit2b510f5e018fed5f0e679d887656a501a6a38aaa (patch)
tree8cbe6c7f640defa9137229edd0feb3b1ee644f49 /scripts/lib
parentc056dad62cdc4d4043e8ac91ff103d234005660f (diff)
downloadpoky-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')
-rw-r--r--scripts/lib/recipetool/create.py49
-rw-r--r--scripts/lib/recipetool/create_buildsys.py37
-rw-r--r--scripts/lib/recipetool/create_npm.py4
3 files changed, 54 insertions, 36 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index aade40b5a8..66c881a17a 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -331,6 +331,7 @@ def create_recipe(args):
331 import bb.process 331 import bb.process
332 import tempfile 332 import tempfile
333 import shutil 333 import shutil
334 import oe.recipeutils
334 335
335 pkgarch = "" 336 pkgarch = ""
336 if args.machine: 337 if args.machine:
@@ -429,7 +430,8 @@ def create_recipe(args):
429 lines_before.append('# Recipe created by %s' % os.path.basename(sys.argv[0])) 430 lines_before.append('# Recipe created by %s' % os.path.basename(sys.argv[0]))
430 lines_before.append('# This is the basis of a recipe and may need further editing in order to be fully functional.') 431 lines_before.append('# This is the basis of a recipe and may need further editing in order to be fully functional.')
431 lines_before.append('# (Feel free to remove these comments when editing.)') 432 lines_before.append('# (Feel free to remove these comments when editing.)')
432 lines_before.append('#') 433 # We need a blank line here so that patch_recipe_lines can rewind before the LICENSE comments
434 lines_before.append('')
433 435
434 licvalues = guess_license(srctree_use) 436 licvalues = guess_license(srctree_use)
435 lic_files_chksum = [] 437 lic_files_chksum = []
@@ -561,28 +563,28 @@ def create_recipe(args):
561 handler.process(srctree_use, classes, lines_before, lines_after, handled, extravalues) 563 handler.process(srctree_use, classes, lines_before, lines_after, handled, extravalues)
562 564
563 extrafiles = extravalues.pop('extrafiles', {}) 565 extrafiles = extravalues.pop('extrafiles', {})
566 extra_pn = extravalues.pop('PN', None)
567 extra_pv = extravalues.pop('PV', None)
564 568
565 if not realpv: 569 if extra_pv and not realpv:
566 realpv = extravalues.get('PV', None) 570 realpv = extra_pv
567 if realpv: 571 if not validate_pv(realpv):
568 if not validate_pv(realpv): 572 realpv = None
569 realpv = None 573 else:
570 else: 574 realpv = realpv.lower().split()[0]
571 realpv = realpv.lower().split()[0] 575 if '_' in realpv:
572 if '_' in realpv: 576 realpv = realpv.replace('_', '-')
573 realpv = realpv.replace('_', '-') 577 if extra_pn and not pn:
574 if not pn: 578 pn = extra_pn
575 pn = extravalues.get('PN', None) 579 if pn.startswith('GNU '):
576 if pn: 580 pn = pn[4:]
577 if pn.startswith('GNU '): 581 if ' ' in pn:
578 pn = pn[4:] 582 # Probably a descriptive identifier rather than a proper name
579 if ' ' in pn: 583 pn = None
580 # Probably a descriptive identifier rather than a proper name 584 else:
581 pn = None 585 pn = pn.lower()
582 else: 586 if '_' in pn:
583 pn = pn.lower() 587 pn = pn.replace('_', '-')
584 if '_' in pn:
585 pn = pn.replace('_', '-')
586 588
587 if not outfile: 589 if not outfile:
588 if not pn: 590 if not pn:
@@ -662,6 +664,9 @@ def create_recipe(args):
662 outlines.append('') 664 outlines.append('')
663 outlines.extend(lines_after) 665 outlines.extend(lines_after)
664 666
667 if extravalues:
668 _, outlines = oe.recipeutils.patch_recipe_lines(outlines, extravalues, trailing_newline=False)
669
665 if args.extract_to: 670 if args.extract_to:
666 scriptutils.git_convert_standalone_clone(srctree) 671 scriptutils.git_convert_standalone_clone(srctree)
667 if os.path.isdir(args.extract_to): 672 if os.path.isdir(args.extract_to):
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
850def register_recipe_handlers(handlers): 863def 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
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index cc4fb42684..ffbcb4905c 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -104,9 +104,9 @@ class NpmRecipeHandler(RecipeHandler):
104 classes.append('npm') 104 classes.append('npm')
105 handled.append('buildsystem') 105 handled.append('buildsystem')
106 if 'description' in data: 106 if 'description' in data:
107 lines_before.append('SUMMARY = "%s"' % data['description']) 107 extravalues['SUMMARY'] = data['description']
108 if 'homepage' in data: 108 if 'homepage' in data:
109 lines_before.append('HOMEPAGE = "%s"' % data['homepage']) 109 extravalues['HOMEPAGE'] = data['homepage']
110 110
111 # Shrinkwrap 111 # Shrinkwrap
112 localfilesdir = tempfile.mkdtemp(prefix='recipetool-npm') 112 localfilesdir = tempfile.mkdtemp(prefix='recipetool-npm')