From: Oleksiy Obitotskyy <oobitots@cisco.com>
To: openembedded-core@lists.openembedded.org
Cc: Oleksiy Obitotskyy <oobitots@cisco.com>
Subject: [PATCH V2] patch.py: add checks for patch_path
Date: Wed, 14 Jan 2026 04:52:07 -0800 [thread overview]
Message-ID: <20260114125207.497436-1-oobitots@cisco.com> (raw)
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
next reply other threads:[~2026-01-14 12:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 12:52 Oleksiy Obitotskyy [this message]
2026-01-14 13:39 ` [OE-core] [PATCH V2] patch.py: add checks for patch_path Paul Barker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260114125207.497436-1-oobitots@cisco.com \
--to=oobitots@cisco.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox