]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
lib/oe/patch: handle creating patches for CRLF sources
authorYoann Congal <yoann.congal@smile.fr>
Tue, 5 Dec 2023 08:44:18 +0000 (09:44 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 6 Dec 2023 22:55:46 +0000 (22:55 +0000)
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 <yoann.congal@smile.fr>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/patch.py

index e4bb5a78393b391e74394edeeb9795236a86928c..d5ad4f3dc1f1b6e0675c776eeb2383ebb02b473c 100644 (file)
@@ -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()