summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/patch.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/patch.py')
-rw-r--r--meta/lib/oe/patch.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index cad50157dd..05e0faa5b7 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -415,16 +415,24 @@ class GitApplyTree(PatchTree):
415 out = runcmd(["sh", "-c", " ".join(shellcmd)], tree) 415 out = runcmd(["sh", "-c", " ".join(shellcmd)], tree)
416 if out: 416 if out:
417 for srcfile in out.split(): 417 for srcfile in out.split():
418 patchlines = [] 418 for encoding in ['utf-8', 'latin-1']:
419 outfile = None 419 patchlines = []
420 with open(srcfile, 'r') as f: 420 outfile = None
421 for line in f: 421 try:
422 if line.startswith(GitApplyTree.patch_line_prefix): 422 with open(srcfile, 'r', encoding=encoding) as f:
423 outfile = line.split()[-1].strip() 423 for line in f:
424 continue 424 if line.startswith(GitApplyTree.patch_line_prefix):
425 if line.startswith(GitApplyTree.ignore_commit_prefix): 425 outfile = line.split()[-1].strip()
426 continue 426 continue
427 patchlines.append(line) 427 if line.startswith(GitApplyTree.ignore_commit_prefix):
428 continue
429 patchlines.append(line)
430 except UnicodeDecodeError:
431 continue
432 break
433 else:
434 raise PatchError('Unable to find a character encoding to decode %s' % srcfile)
435
428 if not outfile: 436 if not outfile:
429 outfile = os.path.basename(srcfile) 437 outfile = os.path.basename(srcfile)
430 with open(os.path.join(outdir, outfile), 'w') as of: 438 with open(os.path.join(outdir, outfile), 'w') as of: