Patchwork multilib: Only build one kernel

login
register
mail settings
Submitter Dongxiao Xu
Date Sept. 4, 2011, 3:51 a.m.
Message ID <D5AB6E638E5A3E4B8F4406B113A5A19A12D73C62AA@shsmsx501.ccr.corp.intel.com>
Download mbox | patch
Permalink /patch/10961/
State New, archived
Headers show

Comments

Dongxiao Xu - Sept. 4, 2011, 3:51 a.m.
Hi Richard,

> -----Original Message-----
> From: openembedded-core-bounces@lists.openembedded.org
> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
> Richard Purdie
> Sent: Friday, September 02, 2011 9:01 PM
> To: openembedded-core
> Subject: [OE-core] multilib: Only build one kernel
> 
> For a given system we only want one kernel to be built. This change makes the
> main kernel recipe provide all of the provides of the various enabled multilibs
> hence allowing it to fulfil all the appropriate dependencies.
> 
> To make this work a global multilib class file needed to be created.
> 
> This patch also enables this multi provider functionality for "allarch"
> packages.
> 
> [YOCTO #1361]

When testing multilib with latest master, I found bitbake would report failed dependency of kernel-module-*. As we know, kernel-module-* will be recommended by some other recipes, while it is defined in kernel related recipe in PACKAGES_DYNAMIC. I think we need the following patch to make it work:

commit bc04de64057a17ae93be466e32249f9505321f59
Author: Dongxiao Xu <dongxiao.xu@intel.com>
Date:   Sun Sep 4 11:49:33 2011 +0800

    multilib_global.bbclass: handle kernel-module-* for multilib

    bitbake would report failed dependency of kernel-module-* when testing
    multilib. kernel-module-* are recommended by some other recipes.

    Do not extend name for kernel-module-* related packages.

    Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>


Thanks,
Dongxiao

> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
> diff --git a/meta/classes/multilib.bbclass b/meta/classes/multilib.bbclass index
> 5d975fd..583d76b 100644
> --- a/meta/classes/multilib.bbclass
> +++ b/meta/classes/multilib.bbclass
> @@ -6,12 +6,17 @@ python multilib_virtclass_handler () {
>      variant = e.data.getVar("BBEXTENDVARIANT", True)
>      if cls != "multilib" or not variant:
>          return
> +
> +    # There should only be one kernel in multilib configs
> +    if bb.data.inherits_class('kernel', e.data) or
> bb.data.inherits_class('module-base', e.data) or bb.data.inherits_class('allarch',
> e.data):
> +        raise bb.parse.SkipPackage("We shouldn't have multilib variants
> + for the kernel")
> +
>      save_var_name=e.data.getVar("MULTILIB_SAVE_VARNAME", True) or ""
>      for name in save_var_name.split():
>          val=e.data.getVar(name, True)
>          if val:
>              e.data.setVar(name + "_MULTILIB_ORIGINAL", val)
> -
> +
>      override = ":virtclass-multilib-" + variant
> 
>      e.data.setVar("MLPREFIX", variant + "-") @@ -28,16 +33,6 @@
> STAGINGCC_prepend = "${BBEXTENDVARIANT}-"
>  python __anonymous () {
>      variant = d.getVar("BBEXTENDVARIANT", True)
> 
> -    def extend_name(name):
> -        if name.startswith("virtual/"):
> -            subs = name.split("/", 1)[1]
> -            if not subs.startswith(variant):
> -                return "virtual/" + variant + "-" + subs
> -            return name
> -        if not name.startswith(variant):
> -            return variant + "-" + name
> -        return name
> -
>      def map_dependencies(varname, d, suffix = ""):
>          if suffix:
>              varname = varname + "_" + suffix @@ -50,25 +45,15 @@
> python __anonymous () {
>              if dep.endswith(("-native", "-native-runtime")):
>                  newdeps.append(dep)
>              else:
> -                newdeps.append(extend_name(dep))
> +                newdeps.append(multilib_extend_name(variant, dep))
>          d.setVar(varname, " ".join(newdeps))
> 
> -    def map_variable(varname, d):
> -        var = d.getVar(varname, True)
> -        if not var:
> -            return
> -        var = var.split()
> -        newvar = []
> -        for v in var:
> -            newvar.append(extend_name(v))
> -        d.setVar(varname, " ".join(newvar))
> -
>      pkgs_mapping = []
>      for pkg in (d.getVar("PACKAGES", True) or "").split():
>          if pkg.startswith(variant):
>              pkgs_mapping.append([pkg.split(variant + "-")[1], pkg])
>              continue
> -        pkgs_mapping.append([pkg, extend_name(pkg)])
> +        pkgs_mapping.append([pkg, multilib_extend_name(variant, pkg)])
> 
>      d.setVar("PACKAGES", " ".join([row[1] for row in pkgs_mapping]))
> 
> @@ -87,8 +72,8 @@ python __anonymous () {
>          map_dependencies("RCONFLICTS", d, pkg)
>          map_dependencies("PKG", d, pkg)
> 
> -    map_variable("PROVIDES", d)
> -    map_variable("PACKAGES_DYNAMIC", d)
> -    map_variable("PACKAGE_INSTALL", d)
> -    map_variable("INITSCRIPT_PACKAGES", d)
> +    multilib_map_variable("PROVIDES", variant, d)
> +    multilib_map_variable("PACKAGES_DYNAMIC", variant, d)
> +    multilib_map_variable("PACKAGE_INSTALL", variant, d)
> +    multilib_map_variable("INITSCRIPT_PACKAGES", variant, d)
>  }
> diff --git a/meta/classes/multilib_global.bbclass
> b/meta/classes/multilib_global.bbclass
> new file mode 100644
> index 0000000..217349b
> --- a/dev/null
> +++ b/meta/classes/multilib_global.bbclass
> @@ -0,0 +1,39 @@
> +python multilib_virtclass_handler_global () {
> +    if not e.data:
> +        return
> +
> +    variant = e.data.getVar("BBEXTENDVARIANT", True)
> +
> +    if isinstance(e, bb.event.RecipeParsed) and not variant:
> +        if bb.data.inherits_class('kernel', e.data) or
> bb.data.inherits_class('module-base', e.data) or bb.data.inherits_class('allarch',
> e.data):
> +            origprovs = provs = e.data.getVar("PROVIDES", True)
> +            variants = (e.data.getVar("MULTILIB_VARIANTS", True) or
> "").split()
> +            for variant in variants:
> +                provs = provs + " " + multilib_map_variable("PROVIDES",
> variant, e.data)
> +                e.data.setVar("PROVIDES", origprovs)
> +            e.data.setVar("PROVIDES", provs) }
> +
> +addhandler multilib_virtclass_handler_global
> +
> +def multilib_extend_name(variant, name):
> +    if name.startswith("virtual/"):
> +        subs = name.split("/", 1)[1]
> +        if not subs.startswith(variant):
> +            return "virtual/" + variant + "-" + subs
> +        return name
> +    if not name.startswith(variant):
> +        return variant + "-" + name
> +    return name
> +
> +def multilib_map_variable(varname, variant, d):
> +    var = d.getVar(varname, True)
> +    if not var:
> +        return
> +    var = var.split()
> +    newvar = []
> +    for v in var:
> +        newvar.append(multilib_extend_name(variant, v))
> +    newdata =  " ".join(newvar)
> +    d.setVar(varname, newdata)
> +    return newdata
> diff --git a/meta/conf/multilib.conf b/meta/conf/multilib.conf index
> 36793d2..7424b8f 100644
> --- a/meta/conf/multilib.conf
> +++ b/meta/conf/multilib.conf
> @@ -6,6 +6,8 @@ MULTILIB_SAVE_VARNAME = "DEFAULTTUNE"
> 
>  MULTILIBS ??= "multilib:lib32"
> 
> +INHERIT += "multilib_global"
> +
>  BBCLASSEXTEND_append_pn-acl = " ${MULTILIBS}"
>  BBCLASSEXTEND_append_pn-alsa-lib = " ${MULTILIBS}"
>  BBCLASSEXTEND_append_pn-alsa-utils = " ${MULTILIBS}"
> 
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Patch

diff --git a/meta/classes/multilib_global.bbclass b/meta/classes/multilib_global.bbclass
index 217349b..1263e4e 100644
--- a/meta/classes/multilib_global.bbclass
+++ b/meta/classes/multilib_global.bbclass
@@ -17,6 +17,8 @@  python multilib_virtclass_handler_global () {
 addhandler multilib_virtclass_handler_global

 def multilib_extend_name(variant, name):
+    if name.startswith("kernel-module"):
+        return name
     if name.startswith("virtual/"):
         subs = name.split("/", 1)[1]
         if not subs.startswith(variant):