classes/patch: return "other" elements found on the SRC_URI
cover classes/patch: return "other" elements found on the SRC_URI
Richard,
When working with Tom on some BSP usability cases, he noted that it was nice that we can specify more complex features in the SRC_URI now that patch ordering and location is maintained by using the src_patches abstraction that Chris added to patch.bbclass. But .. there's always a but, you had to specify some sort of patch to trigger the processing.
Rather than hack something in that is specific to linux-yocto, it seemed like a good idea to add the ability to get 'anything that isn't a patch' from the same routines that Chris added to patch.bbclass.
I'm now using this support to pickup all sorts of things from the SRC_URI, without knowing anything about the format of the SRC_URI itself. Extra filtering on 'other' is the responsibility of the caller.
I'm not the worlds top python coder yet, so I'm sure there are better ways to do this, hence why I'm calling this an RFC patch. I can re-work it as appropriate to get it into the tree, and I'll follow up with my user of the new functionality.
Cheers,
Bruce
PATCH 1/1 classes/patch: return "other" elements found on the SRC_URI
commit:
patch.bbclass: abstract out logic that determines patches to apply
gives the ability for other clases to emit series files for use outside of a build system, or even within the build system. There are sometimes elements on the SRC_URI that while not directly applicable to patching, can be related to patching the package. For example, the yocto kernel class would like to know about these 'other' items on the SRC_URI to locate out of tree kernel features.
This change keeps the default the same, but adds the ability to query for anything 'non-patch' that may be on the SRC_URI. Additional filtering is left up to the caller of the routine.
--- meta/classes/patch.bbclass | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
meta/classes/patch.bbclass +9 -2
@@ -7,13 +7,17 @@ PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot" inherit terminal -def src_patches(d): +def src_patches(d, type = "patches"): workdir = d.getVar('WORKDIR', True) fetch = bb.fetch2.Fetch([], d) patches = [] + others = [] for url in fetch.urls: local = patch_path(url, fetch, workdir) if not local: + if type == "others": + local = fetch.localpath(url) + others.append(local) continue urldata = fetch.ud[url]
@@ -43,7 +47,10 @@ def src_patches(d): localurl = bb.encodeurl(('file', '', local, '', '', patchparm)) patches.append(localurl) - return patches + if type == "others": + return others + else: + return patches def patch_path(url, fetch, workdir): """Return the local path of a patch, or None if this isn't a patch"""
Signature · 1 line
1.7.4.1
Quoted 25 lines · Bruce Ashfield
commit:
patch.bbclass: abstract out logic that determines patches to apply
gives the ability for other clases to emit series files for use outside of a build system, or even within the build system. There are sometimes elements on the
SRC_URIthat while not directly applicable to patching, can be related to patching the package. For example, the yocto kernel class would like to know about these 'other' items on theSRC_URIto locate out of tree kernel features.This change keeps the default the same, but adds the ability to query for anything 'non-patch' that may be on the
SRC_URI. Additional filtering is left up to the caller of the routine.Signed-off-by Bruce Ashfield <[email protected]>--- meta/classes/patch.bbclass | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)meta/classes/patch.bbclass +0
-0
meta/classes/patch.bbclass PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot" · line 10
Quoted 5 lines
meta/classes/patch.bbclass +1
-1@@ -7,13 +7,17 @@ PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot" inherit terminal -def src_patches(d): +def src_patches(d, type = "patches"):
Knowing "magic" strings to pass to functions isn't very intuitive. You could do:
+def src_patches(d, all = False):
Quoted 14 lines
meta/classes/patch.bbclass +4
-0workdir = d.getVar('WORKDIR', True) fetch = bb.fetch2.Fetch([], d) patches = [] + others = [] for url in fetch.urls: local = patch_path(url, fetch, workdir) if not local: + if type == "others": + local = fetch.localpath(url) + others.append(local) continue urldata = fetch.ud[url]
meta/classes/patch.bbclass def src_patches(d): · line 53
Quoted 8 lines
meta/classes/patch.bbclass +4
-1@@ -43,7 +47,10 @@ def src_patches(d): localurl = bb.encodeurl(('file', '', local, '', '', patchparm)) patches.append(localurl) - return patches + if type == "others": + return others + else: + return patches
if all:
return others
return patches
You might want to call it sources instead of others too.
Cheers,
Richard
Quoted 27 lines · Richard Purdie
Quoted 26 lines · Bruce Ashfield
commit:
patch.bbclass: abstract out logic that determines patches to apply
gives the ability for other clases to emit series files for use outside of a build system, or even within the build system. There are sometimes elements on the
SRC_URIthat while not directly applicable to patching, can be related to patching the package. For example, the yocto kernel class would like to know about these 'other' items on theSRC_URIto locate out of tree kernel features.This change keeps the default the same, but adds the ability to query for anything 'non-patch' that may be on the
SRC_URI. Additional filtering is left up to the caller of the routine.Signed-off-by Bruce Ashfield<[email protected]>--- meta/classes/patch.bbclass | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)meta/classes/patch.bbclass +0
-0@@ -7,13 +7,17 @@ PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot"
Quoted 7 lines
meta/classes/patch.bbclass PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot" · line 10
Quoted 4 lines
meta/classes/patch.bbclass +1
-1inherit terminal -def src_patches(d): +def src_patches(d, type = "patches"):Knowing "magic" strings to pass to functions isn't very intuitive. You could do:
I disliked it as well, but was stumped for something better at the time :)
Quoted 31 lines
+def
src_patches(d, all = False):Quoted 14 lines
meta/classes/patch.bbclass +4
-0workdir = d.getVar('WORKDIR', True) fetch = bb.fetch2.Fetch([], d) patches = [] + others = [] for url in fetch.urls: local = patch_path(url, fetch, workdir) if not local: + if type == "others": + local = fetch.localpath(url) + others.append(local) continue urldata = fetch.ud[url]meta/classes/patch.bbclass def src_patches(d): · line 53
Quoted 8 lines
meta/classes/patch.bbclass +4
-1@@ -43,7 +47,10 @@ def src_patches(d): localurl = bb.encodeurl(('file', '', local, '', '', patchparm)) patches.append(localurl) - return patches + if type == "others": + return others + else: + return patchesif all:
return others
return patches
Quoted 1 line
You might want to call it sources instead of others too.
Yep. Works for me. I'll do those fixups here.
Cheers,
Bruce
Quoted 5 lines
Cheers,
Richard