1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 00:20:08 +00:00

recipetool: add appendfile subcommand

Locating which recipe provides a file in an image that you want to
modify and then figuring out how to bbappend the recipe in order to
replace it can be a tedious process. Thus, add a new appendfile
subcommand to recipetool, providing the ability to create a bbappend
file to add/replace any file in the target system. Without the -r
option, it will search for the recipe packaging the specified file
(using pkgdata from previously built recipes). The bbappend will be
created at the appropriate path within the specified layer directory
(which may or may not be in your bblayers.conf) or if one already exists
it will be updated appropriately.

Fairly extensive oe-selftest tests are also provided.

Implements [YOCTO #6447].

(From OE-Core rev: dd2aa93b3c13d2c6464ef0fda59620c7dba450bb)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton
2015-05-18 16:15:07 +01:00
committed by Richard Purdie
parent c63adf5c5b
commit fbfc06a969
18 changed files with 1167 additions and 7 deletions
+63
View File
@@ -92,6 +92,69 @@ class PatchSet(object):
def Refresh(self, remote = None, all = None):
raise NotImplementedError()
@staticmethod
def getPatchedFiles(patchfile, striplevel, srcdir=None):
"""
Read a patch file and determine which files it will modify.
Params:
patchfile: the patch file to read
striplevel: the strip level at which the patch is going to be applied
srcdir: optional path to join onto the patched file paths
Returns:
A list of tuples of file path and change mode ('A' for add,
'D' for delete or 'M' for modify)
"""
def patchedpath(patchline):
filepth = patchline.split()[1]
if filepth.endswith('/dev/null'):
return '/dev/null'
filesplit = filepth.split(os.sep)
if striplevel > len(filesplit):
bb.error('Patch %s has invalid strip level %d' % (patchfile, striplevel))
return None
return os.sep.join(filesplit[striplevel:])
copiedmode = False
filelist = []
with open(patchfile) as f:
for line in f:
if line.startswith('--- '):
patchpth = patchedpath(line)
if not patchpth:
break
if copiedmode:
addedfile = patchpth
else:
removedfile = patchpth
elif line.startswith('+++ '):
addedfile = patchedpath(line)
if not addedfile:
break
elif line.startswith('*** '):
copiedmode = True
removedfile = patchedpath(line)
if not removedfile:
break
else:
removedfile = None
addedfile = None
if addedfile and removedfile:
if removedfile == '/dev/null':
mode = 'A'
elif addedfile == '/dev/null':
mode = 'D'
else:
mode = 'M'
if srcdir:
fullpath = os.path.abspath(os.path.join(srcdir, addedfile))
else:
fullpath = addedfile
filelist.append((fullpath, mode))
return filelist
class PatchTree(PatchSet):
def __init__(self, dir, d):