From: Yoann Congal Date: Tue, 5 Dec 2023 08:44:18 +0000 (+0100) Subject: lib/oe/patch: handle creating patches for CRLF sources X-Git-Tag: yocto-5.2~4394 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=58f845499c0277a2b8069eefa235430b5f5f7661;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git lib/oe/patch: handle creating patches for CRLF sources Using devtool to patch CRLF based sources creates patch files which have mixed end of lines : LF for headers and CRLF for source context and modified lines. Python open(..., newline=None) (default for newline arg)does detect end-of-line in this mixed file but only outputs LF EOL data. This result in patch files that does not apply on the original sources. Switching to open(..., newline='') allows to detect end-of-line but keep the original end-of-line intact. This generate correct patches for CRLF based sources. Fixes [YOCTO #15285] Signed-off-by: Yoann Congal Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index e4bb5a78393..d5ad4f3dc1f 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py @@ -478,7 +478,7 @@ class GitApplyTree(PatchTree): patchlines = [] outfile = None try: - with open(srcfile, 'r', encoding=encoding) as f: + with open(srcfile, 'r', encoding=encoding, newline='') as f: for line in f: if line.startswith(GitApplyTree.patch_line_prefix): outfile = line.split()[-1].strip()