diff options
Diffstat (limited to 'meta/lib/oe/recipeutils.py')
| -rw-r--r-- | meta/lib/oe/recipeutils.py | 210 |
1 files changed, 157 insertions, 53 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 407d168894..54bc3d7666 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py | |||
| @@ -24,9 +24,9 @@ from collections import OrderedDict, defaultdict | |||
| 24 | from bb.utils import vercmp_string | 24 | from bb.utils import vercmp_string |
| 25 | 25 | ||
| 26 | # Help us to find places to insert values | 26 | # Help us to find places to insert values |
| 27 | recipe_progression = ['SUMMARY', 'DESCRIPTION', 'AUTHOR', 'HOMEPAGE', 'BUGTRACKER', 'SECTION', 'LICENSE', 'LICENSE_FLAGS', 'LIC_FILES_CHKSUM', 'PROVIDES', 'DEPENDS', 'PR', 'PV', 'SRCREV', 'SRCPV', 'SRC_URI', 'S', 'do_fetch()', 'do_unpack()', 'do_patch()', 'EXTRA_OECONF', 'EXTRA_OECMAKE', 'EXTRA_OESCONS', 'do_configure()', 'EXTRA_OEMAKE', 'do_compile()', 'do_install()', 'do_populate_sysroot()', 'INITSCRIPT', 'USERADD', 'GROUPADD', 'PACKAGES', 'FILES', 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RPROVIDES', 'RREPLACES', 'RCONFLICTS', 'ALLOW_EMPTY', 'populate_packages()', 'do_package()', 'do_deploy()', 'BBCLASSEXTEND'] | 27 | recipe_progression = ['SUMMARY', 'DESCRIPTION', 'HOMEPAGE', 'BUGTRACKER', 'SECTION', 'LICENSE', 'LICENSE_FLAGS', 'LIC_FILES_CHKSUM', 'PROVIDES', 'DEPENDS', 'PR', 'PV', 'SRCREV', 'SRC_URI', 'S', 'do_fetch()', 'do_unpack()', 'do_patch()', 'EXTRA_OECONF', 'EXTRA_OECMAKE', 'EXTRA_OESCONS', 'do_configure()', 'EXTRA_OEMAKE', 'do_compile()', 'do_install()', 'do_populate_sysroot()', 'INITSCRIPT', 'USERADD', 'GROUPADD', 'PACKAGES', 'FILES', 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RPROVIDES', 'RREPLACES', 'RCONFLICTS', 'ALLOW_EMPTY', 'populate_packages()', 'do_package()', 'do_deploy()', 'BBCLASSEXTEND'] |
| 28 | # Variables that sometimes are a bit long but shouldn't be wrapped | 28 | # Variables that sometimes are a bit long but shouldn't be wrapped |
| 29 | nowrap_vars = ['SUMMARY', 'HOMEPAGE', 'BUGTRACKER', r'SRC_URI\[(.+\.)?md5sum\]', r'SRC_URI\[(.+\.)?sha256sum\]'] | 29 | nowrap_vars = ['SUMMARY', 'HOMEPAGE', 'BUGTRACKER', r'SRC_URI\[(.+\.)?md5sum\]', r'SRC_URI\[(.+\.)?sha[0-9]+sum\]'] |
| 30 | list_vars = ['SRC_URI', 'LIC_FILES_CHKSUM'] | 30 | list_vars = ['SRC_URI', 'LIC_FILES_CHKSUM'] |
| 31 | meta_vars = ['SUMMARY', 'DESCRIPTION', 'HOMEPAGE', 'BUGTRACKER', 'SECTION'] | 31 | meta_vars = ['SUMMARY', 'DESCRIPTION', 'HOMEPAGE', 'BUGTRACKER', 'SECTION'] |
| 32 | 32 | ||
| @@ -47,7 +47,7 @@ def simplify_history(history, d): | |||
| 47 | continue | 47 | continue |
| 48 | has_set = True | 48 | has_set = True |
| 49 | elif event['op'] in ('append', 'prepend', 'postdot', 'predot'): | 49 | elif event['op'] in ('append', 'prepend', 'postdot', 'predot'): |
| 50 | # Reminder: "append" and "prepend" mean += and =+ respectively, NOT _append / _prepend | 50 | # Reminder: "append" and "prepend" mean += and =+ respectively, NOT :append / :prepend |
| 51 | if has_set: | 51 | if has_set: |
| 52 | continue | 52 | continue |
| 53 | ret_history.insert(0, event) | 53 | ret_history.insert(0, event) |
| @@ -342,7 +342,7 @@ def patch_recipe(d, fn, varvalues, patch=False, relpath='', redirect_output=None | |||
| 342 | def override_applicable(hevent): | 342 | def override_applicable(hevent): |
| 343 | op = hevent['op'] | 343 | op = hevent['op'] |
| 344 | if '[' in op: | 344 | if '[' in op: |
| 345 | opoverrides = op.split('[')[1].split(']')[0].split('_') | 345 | opoverrides = op.split('[')[1].split(']')[0].split(':') |
| 346 | for opoverride in opoverrides: | 346 | for opoverride in opoverrides: |
| 347 | if not opoverride in overrides: | 347 | if not opoverride in overrides: |
| 348 | return False | 348 | return False |
| @@ -368,13 +368,13 @@ def patch_recipe(d, fn, varvalues, patch=False, relpath='', redirect_output=None | |||
| 368 | recipe_set = True | 368 | recipe_set = True |
| 369 | if not recipe_set: | 369 | if not recipe_set: |
| 370 | for event in history: | 370 | for event in history: |
| 371 | if event['op'].startswith('_remove'): | 371 | if event['op'].startswith(':remove'): |
| 372 | continue | 372 | continue |
| 373 | if not override_applicable(event): | 373 | if not override_applicable(event): |
| 374 | continue | 374 | continue |
| 375 | newvalue = value.replace(event['detail'], '') | 375 | newvalue = value.replace(event['detail'], '') |
| 376 | if newvalue == value and os.path.abspath(event['file']) == fn and event['op'].startswith('_'): | 376 | if newvalue == value and os.path.abspath(event['file']) == fn and event['op'].startswith(':'): |
| 377 | op = event['op'].replace('[', '_').replace(']', '') | 377 | op = event['op'].replace('[', ':').replace(']', '') |
| 378 | extravals[var + op] = None | 378 | extravals[var + op] = None |
| 379 | value = newvalue | 379 | value = newvalue |
| 380 | vals[var] = ('+=', value) | 380 | vals[var] = ('+=', value) |
| @@ -414,15 +414,13 @@ def copy_recipe_files(d, tgt_dir, whole_dir=False, download=True, all_variants=F | |||
| 414 | 414 | ||
| 415 | fetch_urls(d) | 415 | fetch_urls(d) |
| 416 | if all_variants: | 416 | if all_variants: |
| 417 | # Get files for other variants e.g. in the case of a SRC_URI_append | 417 | # Get files for other variants e.g. in the case of a SRC_URI:append |
| 418 | localdata = bb.data.createCopy(d) | 418 | localdata = bb.data.createCopy(d) |
| 419 | variants = (localdata.getVar('BBCLASSEXTEND') or '').split() | 419 | variants = (localdata.getVar('BBCLASSEXTEND') or '').split() |
| 420 | if variants: | 420 | if variants: |
| 421 | # Ensure we handle class-target if we're dealing with one of the variants | 421 | # Ensure we handle class-target if we're dealing with one of the variants |
| 422 | variants.append('target') | 422 | variants.append('target') |
| 423 | for variant in variants: | 423 | for variant in variants: |
| 424 | if variant.startswith("devupstream"): | ||
| 425 | localdata.setVar('SRCPV', 'git') | ||
| 426 | localdata.setVar('CLASSOVERRIDE', 'class-%s' % variant) | 424 | localdata.setVar('CLASSOVERRIDE', 'class-%s' % variant) |
| 427 | fetch_urls(localdata) | 425 | fetch_urls(localdata) |
| 428 | 426 | ||
| @@ -666,19 +664,23 @@ def get_bbappend_path(d, destlayerdir, wildcardver=False): | |||
| 666 | return (appendpath, pathok) | 664 | return (appendpath, pathok) |
| 667 | 665 | ||
| 668 | 666 | ||
| 669 | def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, machine=None, extralines=None, removevalues=None, redirect_output=None): | 667 | def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, machine=None, extralines=None, removevalues=None, redirect_output=None, params=None, update_original_recipe=False): |
| 670 | """ | 668 | """ |
| 671 | Writes a bbappend file for a recipe | 669 | Writes a bbappend file for a recipe |
| 672 | Parameters: | 670 | Parameters: |
| 673 | rd: data dictionary for the recipe | 671 | rd: data dictionary for the recipe |
| 674 | destlayerdir: base directory of the layer to place the bbappend in | 672 | destlayerdir: base directory of the layer to place the bbappend in |
| 675 | (subdirectory path from there will be determined automatically) | 673 | (subdirectory path from there will be determined automatically) |
| 676 | srcfiles: dict of source files to add to SRC_URI, where the value | 674 | srcfiles: dict of source files to add to SRC_URI, where the key |
| 677 | is the full path to the file to be added, and the value is the | 675 | is the full path to the file to be added, and the value is a |
| 678 | original filename as it would appear in SRC_URI or None if it | 676 | dict with following optional keys: |
| 679 | isn't already present. You may pass None for this parameter if | 677 | path: the original filename as it would appear in SRC_URI |
| 680 | you simply want to specify your own content via the extralines | 678 | or None if it isn't already present. |
| 681 | parameter. | 679 | patchdir: the patchdir parameter |
| 680 | newname: the name to give to the new added file. None to use | ||
| 681 | the default value: basename(path) | ||
| 682 | You may pass None for this parameter if you simply want to specify | ||
| 683 | your own content via the extralines parameter. | ||
| 682 | install: dict mapping entries in srcfiles to a tuple of two elements: | 684 | install: dict mapping entries in srcfiles to a tuple of two elements: |
| 683 | install path (*without* ${D} prefix) and permission value (as a | 685 | install path (*without* ${D} prefix) and permission value (as a |
| 684 | string, e.g. '0644'). | 686 | string, e.g. '0644'). |
| @@ -696,18 +698,32 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, | |||
| 696 | redirect_output: | 698 | redirect_output: |
| 697 | If specified, redirects writing the output file to the | 699 | If specified, redirects writing the output file to the |
| 698 | specified directory (for dry-run purposes) | 700 | specified directory (for dry-run purposes) |
| 701 | params: | ||
| 702 | Parameters to use when adding entries to SRC_URI. If specified, | ||
| 703 | should be a list of dicts with the same length as srcfiles. | ||
| 704 | update_original_recipe: | ||
| 705 | Force to update the original recipe instead of creating/updating | ||
| 706 | a bbapend. destlayerdir must contain the original recipe | ||
| 699 | """ | 707 | """ |
| 700 | 708 | ||
| 701 | if not removevalues: | 709 | if not removevalues: |
| 702 | removevalues = {} | 710 | removevalues = {} |
| 703 | 711 | ||
| 704 | # Determine how the bbappend should be named | 712 | recipefile = rd.getVar('FILE') |
| 705 | appendpath, pathok = get_bbappend_path(rd, destlayerdir, wildcardver) | 713 | if update_original_recipe: |
| 706 | if not appendpath: | 714 | if destlayerdir not in recipefile: |
| 707 | bb.error('Unable to determine layer directory containing %s' % recipefile) | 715 | bb.error("destlayerdir %s doesn't contain the original recipe (%s), cannot update it" % (destlayerdir, recipefile)) |
| 708 | return (None, None) | 716 | return (None, None) |
| 709 | if not pathok: | 717 | |
| 710 | bb.warn('Unable to determine correct subdirectory path for bbappend file - check that what %s adds to BBFILES also matches .bbappend files. Using %s for now, but until you fix this the bbappend will not be applied.' % (os.path.join(destlayerdir, 'conf', 'layer.conf'), os.path.dirname(appendpath))) | 718 | appendpath = recipefile |
| 719 | else: | ||
| 720 | # Determine how the bbappend should be named | ||
| 721 | appendpath, pathok = get_bbappend_path(rd, destlayerdir, wildcardver) | ||
| 722 | if not appendpath: | ||
| 723 | bb.error('Unable to determine layer directory containing %s' % recipefile) | ||
| 724 | return (None, None) | ||
| 725 | if not pathok: | ||
| 726 | bb.warn('Unable to determine correct subdirectory path for bbappend file - check that what %s adds to BBFILES also matches .bbappend files. Using %s for now, but until you fix this the bbappend will not be applied.' % (os.path.join(destlayerdir, 'conf', 'layer.conf'), os.path.dirname(appendpath))) | ||
| 711 | 727 | ||
| 712 | appenddir = os.path.dirname(appendpath) | 728 | appenddir = os.path.dirname(appendpath) |
| 713 | if not redirect_output: | 729 | if not redirect_output: |
| @@ -752,30 +768,48 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, | |||
| 752 | bbappendlines.append((varname, op, value)) | 768 | bbappendlines.append((varname, op, value)) |
| 753 | 769 | ||
| 754 | destsubdir = rd.getVar('PN') | 770 | destsubdir = rd.getVar('PN') |
| 755 | if srcfiles: | 771 | if not update_original_recipe and srcfiles: |
| 756 | bbappendlines.append(('FILESEXTRAPATHS_prepend', ':=', '${THISDIR}/${PN}:')) | 772 | bbappendlines.append(('FILESEXTRAPATHS:prepend', ':=', '${THISDIR}/${PN}:')) |
| 757 | 773 | ||
| 758 | appendoverride = '' | 774 | appendoverride = '' |
| 759 | if machine: | 775 | if machine: |
| 760 | bbappendlines.append(('PACKAGE_ARCH', '=', '${MACHINE_ARCH}')) | 776 | bbappendlines.append(('PACKAGE_ARCH', '=', '${MACHINE_ARCH}')) |
| 761 | appendoverride = '_%s' % machine | 777 | appendoverride = ':%s' % machine |
| 762 | copyfiles = {} | 778 | copyfiles = {} |
| 763 | if srcfiles: | 779 | if srcfiles: |
| 764 | instfunclines = [] | 780 | instfunclines = [] |
| 765 | for newfile, origsrcfile in srcfiles.items(): | 781 | for i, (newfile, param) in enumerate(srcfiles.items()): |
| 766 | srcfile = origsrcfile | ||
| 767 | srcurientry = None | 782 | srcurientry = None |
| 768 | if not srcfile: | 783 | if not 'path' in param or not param['path']: |
| 769 | srcfile = os.path.basename(newfile) | 784 | if 'newname' in param and param['newname']: |
| 785 | srcfile = param['newname'] | ||
| 786 | else: | ||
| 787 | srcfile = os.path.basename(newfile) | ||
| 770 | srcurientry = 'file://%s' % srcfile | 788 | srcurientry = 'file://%s' % srcfile |
| 789 | oldentry = None | ||
| 790 | for uri in rd.getVar('SRC_URI').split(): | ||
| 791 | if srcurientry in uri: | ||
| 792 | oldentry = uri | ||
| 793 | if params and params[i]: | ||
| 794 | srcurientry = '%s;%s' % (srcurientry, ';'.join('%s=%s' % (k,v) for k,v in params[i].items())) | ||
| 771 | # Double-check it's not there already | 795 | # Double-check it's not there already |
| 772 | # FIXME do we care if the entry is added by another bbappend that might go away? | 796 | # FIXME do we care if the entry is added by another bbappend that might go away? |
| 773 | if not srcurientry in rd.getVar('SRC_URI').split(): | 797 | if not srcurientry in rd.getVar('SRC_URI').split(): |
| 774 | if machine: | 798 | if machine: |
| 775 | appendline('SRC_URI_append%s' % appendoverride, '=', ' ' + srcurientry) | 799 | if oldentry: |
| 800 | appendline('SRC_URI:remove%s' % appendoverride, '=', ' ' + oldentry) | ||
| 801 | appendline('SRC_URI:append%s' % appendoverride, '=', ' ' + srcurientry) | ||
| 776 | else: | 802 | else: |
| 803 | if oldentry: | ||
| 804 | if update_original_recipe: | ||
| 805 | removevalues['SRC_URI'] = oldentry | ||
| 806 | else: | ||
| 807 | appendline('SRC_URI:remove', '=', oldentry) | ||
| 777 | appendline('SRC_URI', '+=', srcurientry) | 808 | appendline('SRC_URI', '+=', srcurientry) |
| 778 | copyfiles[newfile] = srcfile | 809 | param['path'] = srcfile |
| 810 | else: | ||
| 811 | srcfile = param['path'] | ||
| 812 | copyfiles[newfile] = param | ||
| 779 | if install: | 813 | if install: |
| 780 | institem = install.pop(newfile, None) | 814 | institem = install.pop(newfile, None) |
| 781 | if institem: | 815 | if institem: |
| @@ -784,9 +818,9 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, | |||
| 784 | instdirline = 'install -d ${D}%s' % os.path.dirname(instdestpath) | 818 | instdirline = 'install -d ${D}%s' % os.path.dirname(instdestpath) |
| 785 | if not instdirline in instfunclines: | 819 | if not instdirline in instfunclines: |
| 786 | instfunclines.append(instdirline) | 820 | instfunclines.append(instdirline) |
| 787 | instfunclines.append('install -m %s ${WORKDIR}/%s ${D}%s' % (perms, os.path.basename(srcfile), instdestpath)) | 821 | instfunclines.append('install -m %s ${UNPACKDIR}/%s ${D}%s' % (perms, os.path.basename(srcfile), instdestpath)) |
| 788 | if instfunclines: | 822 | if instfunclines: |
| 789 | bbappendlines.append(('do_install_append%s()' % appendoverride, '', instfunclines)) | 823 | bbappendlines.append(('do_install:append%s()' % appendoverride, '', instfunclines)) |
| 790 | 824 | ||
| 791 | if redirect_output: | 825 | if redirect_output: |
| 792 | bb.note('Writing append file %s (dry-run)' % appendpath) | 826 | bb.note('Writing append file %s (dry-run)' % appendpath) |
| @@ -795,6 +829,8 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, | |||
| 795 | # multiple times per operation when we're handling overrides) | 829 | # multiple times per operation when we're handling overrides) |
| 796 | if os.path.exists(appendpath) and not os.path.exists(outfile): | 830 | if os.path.exists(appendpath) and not os.path.exists(outfile): |
| 797 | shutil.copy2(appendpath, outfile) | 831 | shutil.copy2(appendpath, outfile) |
| 832 | elif update_original_recipe: | ||
| 833 | outfile = recipefile | ||
| 798 | else: | 834 | else: |
| 799 | bb.note('Writing append file %s' % appendpath) | 835 | bb.note('Writing append file %s' % appendpath) |
| 800 | outfile = appendpath | 836 | outfile = appendpath |
| @@ -804,15 +840,15 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, | |||
| 804 | extvars = {'destsubdir': destsubdir} | 840 | extvars = {'destsubdir': destsubdir} |
| 805 | 841 | ||
| 806 | def appendfile_varfunc(varname, origvalue, op, newlines): | 842 | def appendfile_varfunc(varname, origvalue, op, newlines): |
| 807 | if varname == 'FILESEXTRAPATHS_prepend': | 843 | if varname == 'FILESEXTRAPATHS:prepend': |
| 808 | if origvalue.startswith('${THISDIR}/'): | 844 | if origvalue.startswith('${THISDIR}/'): |
| 809 | popline('FILESEXTRAPATHS_prepend') | 845 | popline('FILESEXTRAPATHS:prepend') |
| 810 | extvars['destsubdir'] = rd.expand(origvalue.split('${THISDIR}/', 1)[1].rstrip(':')) | 846 | extvars['destsubdir'] = rd.expand(origvalue.split('${THISDIR}/', 1)[1].rstrip(':')) |
| 811 | elif varname == 'PACKAGE_ARCH': | 847 | elif varname == 'PACKAGE_ARCH': |
| 812 | if machine: | 848 | if machine: |
| 813 | popline('PACKAGE_ARCH') | 849 | popline('PACKAGE_ARCH') |
| 814 | return (machine, None, 4, False) | 850 | return (machine, None, 4, False) |
| 815 | elif varname.startswith('do_install_append'): | 851 | elif varname.startswith('do_install:append'): |
| 816 | func = popline(varname) | 852 | func = popline(varname) |
| 817 | if func: | 853 | if func: |
| 818 | instfunclines = [line.strip() for line in origvalue.strip('\n').splitlines()] | 854 | instfunclines = [line.strip() for line in origvalue.strip('\n').splitlines()] |
| @@ -824,7 +860,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, | |||
| 824 | splitval = split_var_value(origvalue, assignment=False) | 860 | splitval = split_var_value(origvalue, assignment=False) |
| 825 | changed = False | 861 | changed = False |
| 826 | removevar = varname | 862 | removevar = varname |
| 827 | if varname in ['SRC_URI', 'SRC_URI_append%s' % appendoverride]: | 863 | if varname in ['SRC_URI', 'SRC_URI:append%s' % appendoverride]: |
| 828 | removevar = 'SRC_URI' | 864 | removevar = 'SRC_URI' |
| 829 | line = popline(varname) | 865 | line = popline(varname) |
| 830 | if line: | 866 | if line: |
| @@ -853,11 +889,11 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, | |||
| 853 | newvalue = splitval | 889 | newvalue = splitval |
| 854 | if len(newvalue) == 1: | 890 | if len(newvalue) == 1: |
| 855 | # Ensure it's written out as one line | 891 | # Ensure it's written out as one line |
| 856 | if '_append' in varname: | 892 | if ':append' in varname: |
| 857 | newvalue = ' ' + newvalue[0] | 893 | newvalue = ' ' + newvalue[0] |
| 858 | else: | 894 | else: |
| 859 | newvalue = newvalue[0] | 895 | newvalue = newvalue[0] |
| 860 | if not newvalue and (op in ['+=', '.='] or '_append' in varname): | 896 | if not newvalue and (op in ['+=', '.='] or ':append' in varname): |
| 861 | # There's no point appending nothing | 897 | # There's no point appending nothing |
| 862 | newvalue = None | 898 | newvalue = None |
| 863 | if varname.endswith('()'): | 899 | if varname.endswith('()'): |
| @@ -898,7 +934,12 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, | |||
| 898 | outdir = redirect_output | 934 | outdir = redirect_output |
| 899 | else: | 935 | else: |
| 900 | outdir = appenddir | 936 | outdir = appenddir |
| 901 | for newfile, srcfile in copyfiles.items(): | 937 | for newfile, param in copyfiles.items(): |
| 938 | srcfile = param['path'] | ||
| 939 | patchdir = param.get('patchdir', ".") | ||
| 940 | |||
| 941 | if patchdir != ".": | ||
| 942 | newfile = os.path.join(os.path.split(newfile)[0], patchdir, os.path.split(newfile)[1]) | ||
| 902 | filedest = os.path.join(outdir, destsubdir, os.path.basename(srcfile)) | 943 | filedest = os.path.join(outdir, destsubdir, os.path.basename(srcfile)) |
| 903 | if os.path.abspath(newfile) != os.path.abspath(filedest): | 944 | if os.path.abspath(newfile) != os.path.abspath(filedest): |
| 904 | if newfile.startswith(tempfile.gettempdir()): | 945 | if newfile.startswith(tempfile.gettempdir()): |
| @@ -942,10 +983,9 @@ def replace_dir_vars(path, d): | |||
| 942 | path = path.replace(dirpath, '${%s}' % dirvars[dirpath]) | 983 | path = path.replace(dirpath, '${%s}' % dirvars[dirpath]) |
| 943 | return path | 984 | return path |
| 944 | 985 | ||
| 945 | def get_recipe_pv_without_srcpv(pv, uri_type): | 986 | def get_recipe_pv_with_pfx_sfx(pv, uri_type): |
| 946 | """ | 987 | """ |
| 947 | Get PV without SRCPV common in SCM's for now only | 988 | Get PV separating prefix and suffix components. |
| 948 | support git. | ||
| 949 | 989 | ||
| 950 | Returns tuple with pv, prefix and suffix. | 990 | Returns tuple with pv, prefix and suffix. |
| 951 | """ | 991 | """ |
| @@ -953,7 +993,7 @@ def get_recipe_pv_without_srcpv(pv, uri_type): | |||
| 953 | sfx = '' | 993 | sfx = '' |
| 954 | 994 | ||
| 955 | if uri_type == 'git': | 995 | if uri_type == 'git': |
| 956 | git_regex = re.compile(r"(?P<pfx>v?)(?P<ver>.*?)(?P<sfx>\+[^\+]*(git)?r?(AUTOINC\+))(?P<rev>.*)") | 996 | git_regex = re.compile(r"(?P<pfx>v?)(?P<ver>.*?)(?P<sfx>\+[^\+]*(git)?r?(AUTOINC\+)?)(?P<rev>.*)") |
| 957 | m = git_regex.match(pv) | 997 | m = git_regex.match(pv) |
| 958 | 998 | ||
| 959 | if m: | 999 | if m: |
| @@ -1005,7 +1045,7 @@ def get_recipe_upstream_version(rd): | |||
| 1005 | src_uri = src_uris.split()[0] | 1045 | src_uri = src_uris.split()[0] |
| 1006 | uri_type, _, _, _, _, _ = decodeurl(src_uri) | 1046 | uri_type, _, _, _, _, _ = decodeurl(src_uri) |
| 1007 | 1047 | ||
| 1008 | (pv, pfx, sfx) = get_recipe_pv_without_srcpv(rd.getVar('PV'), uri_type) | 1048 | (pv, pfx, sfx) = get_recipe_pv_with_pfx_sfx(rd.getVar('PV'), uri_type) |
| 1009 | ru['current_version'] = pv | 1049 | ru['current_version'] = pv |
| 1010 | 1050 | ||
| 1011 | manual_upstream_version = rd.getVar("RECIPE_UPSTREAM_VERSION") | 1051 | manual_upstream_version = rd.getVar("RECIPE_UPSTREAM_VERSION") |
| @@ -1029,10 +1069,16 @@ def get_recipe_upstream_version(rd): | |||
| 1029 | else: | 1069 | else: |
| 1030 | ud = bb.fetch2.FetchData(src_uri, rd) | 1070 | ud = bb.fetch2.FetchData(src_uri, rd) |
| 1031 | if rd.getVar("UPSTREAM_CHECK_COMMITS") == "1": | 1071 | if rd.getVar("UPSTREAM_CHECK_COMMITS") == "1": |
| 1032 | revision = ud.method.latest_revision(ud, rd, 'default') | 1072 | bb.fetch2.get_srcrev(rd) |
| 1033 | upversion = pv | 1073 | upversion = None |
| 1034 | if revision != rd.getVar("SRCREV"): | 1074 | revision = None |
| 1035 | upversion = upversion + "-new-commits-available" | 1075 | try: |
| 1076 | revision = ud.method.latest_revision(ud, rd, ud.name) | ||
| 1077 | upversion = pv | ||
| 1078 | if revision != ud.revision: | ||
| 1079 | upversion = upversion + "-new-commits-available" | ||
| 1080 | except bb.fetch2.FetchError as e: | ||
| 1081 | bb.warn("Unable to obtain latest revision: {}".format(e)) | ||
| 1036 | else: | 1082 | else: |
| 1037 | pupver = ud.method.latest_versionstring(ud, rd) | 1083 | pupver = ud.method.latest_versionstring(ud, rd) |
| 1038 | (upversion, revision) = pupver | 1084 | (upversion, revision) = pupver |
| @@ -1071,7 +1117,7 @@ def _get_recipe_upgrade_status(data): | |||
| 1071 | maintainer = data.getVar('RECIPE_MAINTAINER') | 1117 | maintainer = data.getVar('RECIPE_MAINTAINER') |
| 1072 | no_upgrade_reason = data.getVar('RECIPE_NO_UPDATE_REASON') | 1118 | no_upgrade_reason = data.getVar('RECIPE_NO_UPDATE_REASON') |
| 1073 | 1119 | ||
| 1074 | return (pn, status, cur_ver, next_ver, maintainer, revision, no_upgrade_reason) | 1120 | return {'pn':pn, 'status':status, 'cur_ver':cur_ver, 'next_ver':next_ver, 'maintainer':maintainer, 'revision':revision, 'no_upgrade_reason':no_upgrade_reason} |
| 1075 | 1121 | ||
| 1076 | def get_recipe_upgrade_status(recipes=None): | 1122 | def get_recipe_upgrade_status(recipes=None): |
| 1077 | pkgs_list = [] | 1123 | pkgs_list = [] |
| @@ -1113,6 +1159,7 @@ def get_recipe_upgrade_status(recipes=None): | |||
| 1113 | if not recipes: | 1159 | if not recipes: |
| 1114 | recipes = tinfoil.all_recipe_files(variants=False) | 1160 | recipes = tinfoil.all_recipe_files(variants=False) |
| 1115 | 1161 | ||
| 1162 | recipeincludes = {} | ||
| 1116 | for fn in recipes: | 1163 | for fn in recipes: |
| 1117 | try: | 1164 | try: |
| 1118 | if fn.startswith("/"): | 1165 | if fn.startswith("/"): |
| @@ -1137,8 +1184,65 @@ def get_recipe_upgrade_status(recipes=None): | |||
| 1137 | 1184 | ||
| 1138 | data_copy_list.append(data_copy) | 1185 | data_copy_list.append(data_copy) |
| 1139 | 1186 | ||
| 1187 | recipeincludes[data.getVar('FILE')] = {'bbincluded':data.getVar('BBINCLUDED').split(),'pn':data.getVar('PN')} | ||
| 1188 | |||
| 1140 | from concurrent.futures import ProcessPoolExecutor | 1189 | from concurrent.futures import ProcessPoolExecutor |
| 1141 | with ProcessPoolExecutor(max_workers=utils.cpu_count()) as executor: | 1190 | with ProcessPoolExecutor(max_workers=utils.cpu_count()) as executor: |
| 1142 | pkgs_list = executor.map(_get_recipe_upgrade_status, data_copy_list) | 1191 | pkgs_list = executor.map(_get_recipe_upgrade_status, data_copy_list) |
| 1143 | 1192 | ||
| 1144 | return pkgs_list | 1193 | return _group_recipes(pkgs_list, _get_common_include_recipes(recipeincludes)) |
| 1194 | |||
| 1195 | def get_common_include_recipes(): | ||
| 1196 | with bb.tinfoil.Tinfoil() as tinfoil: | ||
| 1197 | tinfoil.prepare(config_only=False) | ||
| 1198 | |||
| 1199 | recipes = tinfoil.all_recipe_files(variants=False) | ||
| 1200 | |||
| 1201 | recipeincludes = {} | ||
| 1202 | for fn in recipes: | ||
| 1203 | data = tinfoil.parse_recipe_file(fn) | ||
| 1204 | recipeincludes[fn] = {'bbincluded':data.getVar('BBINCLUDED').split(),'pn':data.getVar('PN')} | ||
| 1205 | return _get_common_include_recipes(recipeincludes) | ||
| 1206 | |||
| 1207 | def _get_common_include_recipes(recipeincludes_all): | ||
| 1208 | recipeincludes = {} | ||
| 1209 | for fn,data in recipeincludes_all.items(): | ||
| 1210 | bbincluded_filtered = [i for i in data['bbincluded'] if os.path.dirname(i) == os.path.dirname(fn) and i != fn] | ||
| 1211 | if bbincluded_filtered: | ||
| 1212 | recipeincludes[data['pn']] = bbincluded_filtered | ||
| 1213 | |||
| 1214 | recipeincludes_inverted = {} | ||
| 1215 | for k,v in recipeincludes.items(): | ||
| 1216 | for i in v: | ||
| 1217 | recipeincludes_inverted.setdefault(i,set()).add(k) | ||
| 1218 | |||
| 1219 | recipeincludes_inverted_filtered = {k:v for k,v in recipeincludes_inverted.items() if len(v) > 1} | ||
| 1220 | |||
| 1221 | recipes_with_shared_includes = list() | ||
| 1222 | for v in recipeincludes_inverted_filtered.values(): | ||
| 1223 | recipeset = v | ||
| 1224 | for v1 in recipeincludes_inverted_filtered.values(): | ||
| 1225 | if recipeset.intersection(v1): | ||
| 1226 | recipeset.update(v1) | ||
| 1227 | if recipeset not in recipes_with_shared_includes: | ||
| 1228 | recipes_with_shared_includes.append(recipeset) | ||
| 1229 | |||
| 1230 | return recipes_with_shared_includes | ||
| 1231 | |||
| 1232 | def _group_recipes(recipes, groups): | ||
| 1233 | recipedict = {} | ||
| 1234 | for r in recipes: | ||
| 1235 | recipedict[r['pn']] = r | ||
| 1236 | |||
| 1237 | recipegroups = [] | ||
| 1238 | for g in groups: | ||
| 1239 | recipeset = [] | ||
| 1240 | for r in g: | ||
| 1241 | if r in recipedict.keys(): | ||
| 1242 | recipeset.append(recipedict[r]) | ||
| 1243 | del recipedict[r] | ||
| 1244 | recipegroups.append(recipeset) | ||
| 1245 | |||
| 1246 | for r in recipedict.values(): | ||
| 1247 | recipegroups.append([r]) | ||
| 1248 | return recipegroups | ||
