summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/recipeutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/recipeutils.py')
-rw-r--r--meta/lib/oe/recipeutils.py135
1 files changed, 88 insertions, 47 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index 407d168894..de1fbdd3a8 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -24,9 +24,9 @@ from collections import OrderedDict, defaultdict
24from bb.utils import vercmp_string 24from 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
27recipe_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'] 27recipe_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
29nowrap_vars = ['SUMMARY', 'HOMEPAGE', 'BUGTRACKER', r'SRC_URI\[(.+\.)?md5sum\]', r'SRC_URI\[(.+\.)?sha256sum\]'] 29nowrap_vars = ['SUMMARY', 'HOMEPAGE', 'BUGTRACKER', r'SRC_URI\[(.+\.)?md5sum\]', r'SRC_URI\[(.+\.)?sha[0-9]+sum\]']
30list_vars = ['SRC_URI', 'LIC_FILES_CHKSUM'] 30list_vars = ['SRC_URI', 'LIC_FILES_CHKSUM']
31meta_vars = ['SUMMARY', 'DESCRIPTION', 'HOMEPAGE', 'BUGTRACKER', 'SECTION'] 31meta_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
669def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, machine=None, extralines=None, removevalues=None, redirect_output=None): 667def 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:
@@ -786,7 +820,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
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 ${WORKDIR}/%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
945def get_recipe_pv_without_srcpv(pv, uri_type): 986def 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,11 @@ 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":
1072 bb.fetch2.get_srcrev(rd)
1032 revision = ud.method.latest_revision(ud, rd, 'default') 1073 revision = ud.method.latest_revision(ud, rd, 'default')
1033 upversion = pv 1074 upversion = pv
1034 if revision != rd.getVar("SRCREV"): 1075 if revision != rd.getVar("SRCREV"):
1035 upversion = upversion + "-new-commits-available" 1076 upversion = upversion + "-new-commits-available"
1036 else: 1077 else:
1037 pupver = ud.method.latest_versionstring(ud, rd) 1078 pupver = ud.method.latest_versionstring(ud, rd)
1038 (upversion, revision) = pupver 1079 (upversion, revision) = pupver