summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/patch.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-05-18 16:15:07 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-20 21:41:04 +0100
commitfbfc06a969200e582a059c9943e6fd17aca70e30 (patch)
tree1862fb721f550d42f10e8867224712754a865d34 /meta/lib/oe/patch.py
parentc63adf5c5b4b5984c315e914a7d3cb4b51040602 (diff)
downloadpoky-fbfc06a969200e582a059c9943e6fd17aca70e30.tar.gz
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>
Diffstat (limited to 'meta/lib/oe/patch.py')
-rw-r--r--meta/lib/oe/patch.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index e1f1c53bef..afb0013a4b 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -92,6 +92,69 @@ class PatchSet(object):
92 def Refresh(self, remote = None, all = None): 92 def Refresh(self, remote = None, all = None):
93 raise NotImplementedError() 93 raise NotImplementedError()
94 94
95 @staticmethod
96 def getPatchedFiles(patchfile, striplevel, srcdir=None):
97 """
98 Read a patch file and determine which files it will modify.
99 Params:
100 patchfile: the patch file to read
101 striplevel: the strip level at which the patch is going to be applied
102 srcdir: optional path to join onto the patched file paths
103 Returns:
104 A list of tuples of file path and change mode ('A' for add,
105 'D' for delete or 'M' for modify)
106 """
107
108 def patchedpath(patchline):
109 filepth = patchline.split()[1]
110 if filepth.endswith('/dev/null'):
111 return '/dev/null'
112 filesplit = filepth.split(os.sep)
113 if striplevel > len(filesplit):
114 bb.error('Patch %s has invalid strip level %d' % (patchfile, striplevel))
115 return None
116 return os.sep.join(filesplit[striplevel:])
117
118 copiedmode = False
119 filelist = []
120 with open(patchfile) as f:
121 for line in f:
122 if line.startswith('--- '):
123 patchpth = patchedpath(line)
124 if not patchpth:
125 break
126 if copiedmode:
127 addedfile = patchpth
128 else:
129 removedfile = patchpth
130 elif line.startswith('+++ '):
131 addedfile = patchedpath(line)
132 if not addedfile:
133 break
134 elif line.startswith('*** '):
135 copiedmode = True
136 removedfile = patchedpath(line)
137 if not removedfile:
138 break
139 else:
140 removedfile = None
141 addedfile = None
142
143 if addedfile and removedfile:
144 if removedfile == '/dev/null':
145 mode = 'A'
146 elif addedfile == '/dev/null':
147 mode = 'D'
148 else:
149 mode = 'M'
150 if srcdir:
151 fullpath = os.path.abspath(os.path.join(srcdir, addedfile))
152 else:
153 fullpath = addedfile
154 filelist.append((fullpath, mode))
155
156 return filelist
157
95 158
96class PatchTree(PatchSet): 159class PatchTree(PatchSet):
97 def __init__(self, dir, d): 160 def __init__(self, dir, d):