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 <[email protected]> --- 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
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#229324): https://lists.openembedded.org/g/openembedded-core/message/229324 Mute This Topic: https://lists.openembedded.org/mt/117260083/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
