Patchwork base.bbclass: allow specifying an lsb distro hook via the metadata

login
register
mail settings
Submitter Christopher Larson
Date Aug. 2, 2012, 10:10 p.m.
Message ID <1343945450-26806-1-git-send-email-kergoth@gmail.com>
Download mbox | patch
Permalink /patch/33727/
State Accepted
Commit 0e9932b2dba8573736c92bd07e59bad21b9fda2d
Headers show

Comments

Christopher Larson - Aug. 2, 2012, 10:10 p.m.
From: Christopher Larson <chris_larson@mentor.com>

This is useful when you have a rather large set of compatible distros. For
example: Centos 5.4, 5.5, 5.6, etc, RHEL server 5.x, RHEL workstation 5.x.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 meta/classes/base.bbclass |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Saul Wold - Aug. 16, 2012, 5:49 p.m.
On 08/02/2012 03:10 PM, Christopher Larson wrote:
> From: Christopher Larson <chris_larson@mentor.com>
>
> This is useful when you have a rather large set of compatible distros. For
> example: Centos 5.4, 5.5, 5.6, etc, RHEL server 5.x, RHEL workstation 5.x.
>
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> ---
>   meta/classes/base.bbclass |   12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index e15fa26..192c777 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -34,11 +34,21 @@ def oe_import(d):
>   python oe_import_eh () {
>       if isinstance(e, bb.event.ConfigParsed):
>           oe_import(e.data)
> -        e.data.setVar("NATIVELSBSTRING", oe.lsb.distro_identifier())
> +        e.data.setVar("NATIVELSBSTRING", lsb_distro_identifier(e.data))
>   }
>
>   addhandler oe_import_eh
>
> +def lsb_distro_identifier(d):
> +    adjust = d.getVar('LSB_DISTRO_ADJUST', True)
> +    adjust_func = None
> +    if adjust:
> +        try:
> +            adjust_func = globals()[adjust]
> +        except KeyError:
> +            pass
> +    return oe.lsb.distro_identifier(adjust_func)
> +
>   die() {
>   	bbfatal "$*"
>   }
>
Merged into OE-Core

Thanks
	Sau!

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index e15fa26..192c777 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -34,11 +34,21 @@  def oe_import(d):
 python oe_import_eh () {
     if isinstance(e, bb.event.ConfigParsed):
         oe_import(e.data)
-        e.data.setVar("NATIVELSBSTRING", oe.lsb.distro_identifier())
+        e.data.setVar("NATIVELSBSTRING", lsb_distro_identifier(e.data))
 }
 
 addhandler oe_import_eh
 
+def lsb_distro_identifier(d):
+    adjust = d.getVar('LSB_DISTRO_ADJUST', True)
+    adjust_func = None
+    if adjust:
+        try:
+            adjust_func = globals()[adjust]
+        except KeyError:
+            pass
+    return oe.lsb.distro_identifier(adjust_func)
+
 die() {
 	bbfatal "$*"
 }