* [PATCH V2] patch.py: add checks for patch_path
@ 2026-01-14 12:52 Oleksiy Obitotskyy
2026-01-14 13:39 ` [OE-core] " Paul Barker
0 siblings, 1 reply; 2+ messages in thread
From: Oleksiy Obitotskyy @ 2026-01-14 12:52 UTC (permalink / raw)
To: openembedded-core; +Cc: Oleksiy Obitotskyy
All URLs from SRC checked to be a patch.
In some rare cases, when we have "diff" or
"patch" into URL it is treated as a patch not
like proper resource (e.g. repository). This
happens in case of using mirrors. Without
pre-downloaded repository archive we have
directory into downloads and exit from
patch_path before checking for patch/diff.
Let's limit patch_path call for url's that
has "apply" parameter set or has original
extensions .diff or .patch.
Error example for this URL:
git://github.com/pkg/diff;name=diff;\
destsuffix=build/vendor/src/github.com/pkg/diff;branch=main;protocol=https
ERROR: nativesdk-yq-4.30.8+gitdd6cf3df146f3e2c0f8c765a6ef9e35780ad8cc1-r0 do_patch: \
Importing patch 'github.com.pkg.diff' with striplevel '1'
FileNotFoundError(2, 'No such file or directory')
Signed-off-by: Oleksiy Obitotskyy <oobitots@cisco.com>
---
meta/lib/oe/patch.py | 35 ++++++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 246fc6221f..c5d09a399f 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -884,6 +884,33 @@ class UserResolver(Resolver):
finally:
os.chdir(olddir)
+def is_archive_extension(ext):
+ return ext in ('.gz', '.bz2', '.xz', '.Z')
+
+def is_patch_extension(ext):
+ return ext in ('.diff', '.patch')
+
+def could_be_patch(url):
+ """
+ URI could be treated as patch if:
+ - any resource with parameter apply set to yes/true
+ - any resource without parameter apply explicitly set, but let's limit them to ones with
+ extension .patch or .diff
+ """
+ (_, _, path, _, _, parm) = bb.fetch.decodeurl(url)
+
+ if "apply" in parm:
+ apply = oe.types.boolean(parm["apply"])
+ if apply:
+ return True
+
+ base, ext = os.path.splitext(path)
+ if is_archive_extension(ext):
+ _, ext = os.path.splitext(base)
+ if is_patch_extension(ext):
+ return True
+
+ return False
def patch_path(url, fetch, unpackdir, expand=True):
"""Return the local path of a patch, or return nothing if this isn't a patch"""
@@ -892,7 +919,7 @@ def patch_path(url, fetch, unpackdir, expand=True):
if os.path.isdir(local):
return
base, ext = os.path.splitext(os.path.basename(local))
- if ext in ('.gz', '.bz2', '.xz', '.Z'):
+ if is_archive_extension(ext):
if expand:
local = os.path.join(unpackdir, base)
ext = os.path.splitext(base)[1]
@@ -902,7 +929,7 @@ def patch_path(url, fetch, unpackdir, expand=True):
apply = oe.types.boolean(urldata.parm["apply"])
if not apply:
return
- elif ext not in (".diff", ".patch"):
+ elif not is_patch_extension(ext):
return
return local
@@ -913,7 +940,9 @@ def src_patches(d, all=False, expand=True):
patches = []
sources = []
for url in fetch.urls:
- local = patch_path(url, fetch, unpackdir, expand)
+ local = None
+ if could_be_patch(url):
+ local = patch_path(url, fetch, unpackdir, expand)
if not local:
if all:
local = fetch.localpath(url)
--
2.35.6
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [OE-core] [PATCH V2] patch.py: add checks for patch_path
2026-01-14 12:52 [PATCH V2] patch.py: add checks for patch_path Oleksiy Obitotskyy
@ 2026-01-14 13:39 ` Paul Barker
0 siblings, 0 replies; 2+ messages in thread
From: Paul Barker @ 2026-01-14 13:39 UTC (permalink / raw)
To: oobitots, openembedded-core
[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]
On Wed, 2026-01-14 at 04:52 -0800, Oleksiy Obitotskyy via
lists.openembedded.org wrote:
> All URLs from SRC checked to be a patch.
> In some rare cases, when we have "diff" or
> "patch" into URL it is treated as a patch not
> like proper resource (e.g. repository). This
> happens in case of using mirrors. Without
> pre-downloaded repository archive we have
> directory into downloads and exit from
> patch_path before checking for patch/diff.
>
> Let's limit patch_path call for url's that
> has "apply" parameter set or has original
> extensions .diff or .patch.
>
> Error example for this URL:
> git://github.com/pkg/diff;name=diff;\
> destsuffix=build/vendor/src/github.com/pkg/diff;branch=main;protocol=https
>
> ERROR: nativesdk-yq-4.30.8+gitdd6cf3df146f3e2c0f8c765a6ef9e35780ad8cc1-r0 do_patch: \
> Importing patch 'github.com.pkg.diff' with striplevel '1'
> FileNotFoundError(2, 'No such file or directory')
>
> Signed-off-by: Oleksiy Obitotskyy <oobitots@cisco.com>
You mention the `apply` parameter in your commit message. Can you just
add `;apply=no` to the relevant SRC_URI entry?
Best regards,
--
Paul Barker
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-14 13:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-14 12:52 [PATCH V2] patch.py: add checks for patch_path Oleksiy Obitotskyy
2026-01-14 13:39 ` [OE-core] " Paul Barker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox