All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/oe/patch: handle creating patches for CRLF sources
@ 2023-11-27 13:49 Yoann Congal
  2023-12-05  7:48 ` [OE-core] " Alexandre Belloni
  0 siblings, 1 reply; 3+ messages in thread
From: Yoann Congal @ 2023-11-27 13:49 UTC (permalink / raw)
  To: openembedded-core; +Cc: Yoann Congal

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>
---
 meta/lib/oe/patch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index ff9afc9df9..7bf660978e 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -477,7 +477,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()
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [OE-core] [PATCH] lib/oe/patch: handle creating patches for CRLF sources
  2023-11-27 13:49 [PATCH] lib/oe/patch: handle creating patches for CRLF sources Yoann Congal
@ 2023-12-05  7:48 ` Alexandre Belloni
  2023-12-05  8:11   ` Yoann CONGAL
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2023-12-05  7:48 UTC (permalink / raw)
  To: Yoann Congal; +Cc: openembedded-core

Hello,

This doesn't apply on master, can you rebase?

On 27/11/2023 14:49:03+0100, Yoann Congal wrote:
> 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>
> ---
>  meta/lib/oe/patch.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
> index ff9afc9df9..7bf660978e 100644
> --- a/meta/lib/oe/patch.py
> +++ b/meta/lib/oe/patch.py
> @@ -477,7 +477,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()
> -- 
> 2.30.2
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#191303): https://lists.openembedded.org/g/openembedded-core/message/191303
> Mute This Topic: https://lists.openembedded.org/mt/102828787/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [OE-core] [PATCH] lib/oe/patch: handle creating patches for CRLF sources
  2023-12-05  7:48 ` [OE-core] " Alexandre Belloni
@ 2023-12-05  8:11   ` Yoann CONGAL
  0 siblings, 0 replies; 3+ messages in thread
From: Yoann CONGAL @ 2023-12-05  8:11 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 2459 bytes --]

Le mar. 5 déc. 2023 à 08:48, Alexandre Belloni <
alexandre.belloni@bootlin.com> a écrit :

> Hello,
>
> This doesn't apply on master, can you rebase?
>

Yes! I will send a v2 today

On 27/11/2023 14:49:03+0100, Yoann Congal wrote:
> > 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>
> > ---
> >  meta/lib/oe/patch.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
> > index ff9afc9df9..7bf660978e 100644
> > --- a/meta/lib/oe/patch.py
> > +++ b/meta/lib/oe/patch.py
> > @@ -477,7 +477,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()
> > --
> > 2.30.2
> >
>
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#191303):
> https://lists.openembedded.org/g/openembedded-core/message/191303
> > Mute This Topic: https://lists.openembedded.org/mt/102828787/3617179
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> alexandre.belloni@bootlin.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>


-- 
Yoann Congal
Smile ECS - Tech expert

[-- Attachment #2: Type: text/html, Size: 4146 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-05  8:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-27 13:49 [PATCH] lib/oe/patch: handle creating patches for CRLF sources Yoann Congal
2023-12-05  7:48 ` [OE-core] " Alexandre Belloni
2023-12-05  8:11   ` Yoann CONGAL

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.