classes/patch: return "other" elements found on the SRC_URI

Submitted by Bruce Ashfield on Feb. 1, 2012, 2:42 p.m.

Details

Message ID 1328107366-22541-2-git-send-email-bruce.ashfield@windriver.com
State New
Headers show

Commit Message

Bruce Ashfield Feb. 1, 2012, 2:42 p.m.
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.

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
 meta/classes/patch.bbclass |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index 1ea4bc5..d664215 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -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"""

Comments

Richard Purdie Feb. 1, 2012, 3:52 p.m.
On Wed, 2012-02-01 at 09:42 -0500, Bruce Ashfield wrote:
> 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.
> 
> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
> ---
>  meta/classes/patch.bbclass |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
> index 1ea4bc5..d664215 100644
> --- a/meta/classes/patch.bbclass
> +++ b/meta/classes/patch.bbclass
> @@ -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):


>  	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

if all:
    return others
return patches

You might want to call it sources instead of others too.

Cheers,

Richard
Bruce Ashfield Feb. 1, 2012, 3:56 p.m.
On 12-02-01 10:52 AM, Richard Purdie wrote:
> On Wed, 2012-02-01 at 09:42 -0500, Bruce Ashfield wrote:
>> 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.
>>
>> Signed-off-by: Bruce Ashfield<bruce.ashfield@windriver.com>
>> ---
>>   meta/classes/patch.bbclass |   11 +++++++++--
>>   1 files changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
>> index 1ea4bc5..d664215 100644
>> --- a/meta/classes/patch.bbclass
>> +++ b/meta/classes/patch.bbclass
>> @@ -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:

I disliked it as well, but was stumped for something better at the
time :)

>
> +def src_patches(d, all = False):
>
>
>>   	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
>
> if all:
>      return others
> return patches
>
> You might want to call it sources instead of others too.

Yep. Works for me. I'll do those fixups here.

Cheers,

Bruce

>
> Cheers,
>
> Richard
>