diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/recipetool/create.py | 49 | ||||
-rw-r--r-- | scripts/lib/recipetool/create_buildsys.py | 37 | ||||
-rw-r--r-- | scripts/lib/recipetool/create_npm.py | 4 |
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 | ||
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 |
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') |