summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/recipeutils.py
diff options
context:
space:
mode:
authorJulien Stephan <jstephan@baylibre.com>2023-12-05 15:56:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-06 22:55:49 +0000
commit0ae9cf237394488508d80e7d08edd284c0075ff6 (patch)
tree313dfd13f14be62a2cb333a5c9bf2a4ff474a809 /meta/lib/oe/recipeutils.py
parent29dc0d73154f60635da740f9785f02740816a2fa (diff)
downloadpoky-0ae9cf237394488508d80e7d08edd284c0075ff6.tar.gz
recipeutils: bbappend_recipe: allow to patch the recipe itself
Add a new parameter update_original_recipe to allow to patch a recipe instead of creating/updating a bbappend (From OE-Core rev: 2f68ab2464bfad1b377df44a7b51203df59d66ce) Signed-off-by: Julien Stephan <jstephan@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/recipeutils.py')
-rw-r--r--meta/lib/oe/recipeutils.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index d86873056f..ae02af0fee 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -664,7 +664,7 @@ def get_bbappend_path(d, destlayerdir, wildcardver=False):
664 return (appendpath, pathok) 664 return (appendpath, pathok)
665 665
666 666
667def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, machine=None, extralines=None, removevalues=None, redirect_output=None, params=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):
668 """ 668 """
669 Writes a bbappend file for a recipe 669 Writes a bbappend file for a recipe
670 Parameters: 670 Parameters:
@@ -701,19 +701,29 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
701 params: 701 params:
702 Parameters to use when adding entries to SRC_URI. If specified, 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. 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
704 """ 707 """
705 708
706 if not removevalues: 709 if not removevalues:
707 removevalues = {} 710 removevalues = {}
708 711
709 recipefile = rd.getVar('FILE') 712 recipefile = rd.getVar('FILE')
710 # Determine how the bbappend should be named 713 if update_original_recipe:
711 appendpath, pathok = get_bbappend_path(rd, destlayerdir, wildcardver) 714 if destlayerdir not in recipefile:
712 if not appendpath: 715 bb.error("destlayerdir %s doesn't contain the original recipe (%s), cannot update it" % (destlayerdir, recipefile))
713 bb.error('Unable to determine layer directory containing %s' % recipefile) 716 return (None, None)
714 return (None, None) 717
715 if not pathok: 718 appendpath = recipefile
716 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))) 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)))
717 727
718 appenddir = os.path.dirname(appendpath) 728 appenddir = os.path.dirname(appendpath)
719 if not redirect_output: 729 if not redirect_output:
@@ -758,7 +768,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
758 bbappendlines.append((varname, op, value)) 768 bbappendlines.append((varname, op, value))
759 769
760 destsubdir = rd.getVar('PN') 770 destsubdir = rd.getVar('PN')
761 if srcfiles: 771 if not update_original_recipe and srcfiles:
762 bbappendlines.append(('FILESEXTRAPATHS:prepend', ':=', '${THISDIR}/${PN}:')) 772 bbappendlines.append(('FILESEXTRAPATHS:prepend', ':=', '${THISDIR}/${PN}:'))
763 773
764 appendoverride = '' 774 appendoverride = ''
@@ -791,7 +801,10 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
791 appendline('SRC_URI:append%s' % appendoverride, '=', ' ' + srcurientry) 801 appendline('SRC_URI:append%s' % appendoverride, '=', ' ' + srcurientry)
792 else: 802 else:
793 if oldentry: 803 if oldentry:
794 appendline('SRC_URI:remove', '=', oldentry) 804 if update_original_recipe:
805 removevalues['SRC_URI'] = oldentry
806 else:
807 appendline('SRC_URI:remove', '=', oldentry)
795 appendline('SRC_URI', '+=', srcurientry) 808 appendline('SRC_URI', '+=', srcurientry)
796 param['path'] = srcfile 809 param['path'] = srcfile
797 else: 810 else:
@@ -816,6 +829,8 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
816 # multiple times per operation when we're handling overrides) 829 # multiple times per operation when we're handling overrides)
817 if os.path.exists(appendpath) and not os.path.exists(outfile): 830 if os.path.exists(appendpath) and not os.path.exists(outfile):
818 shutil.copy2(appendpath, outfile) 831 shutil.copy2(appendpath, outfile)
832 elif update_original_recipe:
833 outfile = recipefile
819 else: 834 else:
820 bb.note('Writing append file %s' % appendpath) 835 bb.note('Writing append file %s' % appendpath)
821 outfile = appendpath 836 outfile = appendpath