[OE-core] [PATCH 1/1] base.bbclass: Check BuildStarted for HOSTTOOLS

Peter Kjellerstedt peter.kjellerstedt at axis.com
Thu Feb 14 03:05:21 UTC 2019


> -----Original Message-----
> From: openembedded-core-bounces at lists.openembedded.org <openembedded-
> core-bounces at lists.openembedded.org> On Behalf Of Robert Yang
> Sent: den 14 februari 2019 03:59
> To: openembedded-core at lists.openembedded.org
> Subject: [OE-core] [PATCH 1/1] base.bbclass: Check BuildStarted for
> HOSTTOOLS
> 
> There might be no bb.event.ConfigParsed event bitbake server is
> running,
> so check bb.event.BuildStarted to make sure HOSTTOOLS_DIR existed when
> BuildStarted.
> 
> Fixed:
> $ export BB_SERVER_TIMEOUT=-1
> $ bitbake quilt-native
> $ rm -fr tmp
> $ bitbake quilt-native
> ERROR: Error running gcc  --version: /bin/sh: gcc: command not found
> 
> This error is caused by enable_uninative(), it runs twice (ConfigParsed
> and
> BuildStarted), the error would happen when there is no ConfigParsed
> event
> (no hosttools is created), but BuildStarted. This patch can fix the
> problem.
> 
> [YOCTO #13022]
> 
> Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
> ---
>  meta/classes/base.bbclass | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index f1a3c0e..283cb0f 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -224,7 +224,11 @@ base_eventhandler[eventmask] =
> "bb.event.ConfigParsed bb.event.MultiConfigParsed
>  python base_eventhandler() {
>      import bb.runqueue
> 
> -    if isinstance(e, bb.event.ConfigParsed):
> +    # There might be no bb.event.ConfigParsed event bitbake server is running,
> +    # so check bb.event.BuildStarted to make sure HOSTTOOLS_DIR existed when
> +    # BuildStarted.
> +    if isinstance(e, bb.event.ConfigParsed) or \
> +            (isinstance(e, bb.event.BuildStarted) and not os.path.exists(d.getVar('HOSTTOOLS_DIR'))):

I don't think you want to do this here since not all of this if statement 
should be done for the BuildStarted event. I think it is better to add a 
separate if statement just for the HOSTTOOLS part (see below). Also, I don't 
think you should be checking if the HOSTTOOLS_DIR exists, because the 
contents of ${HOSTTOOLS} and ${HOSTTOOLS_NONFATAL} may have changed, in 
which case any new tools need to be added to the directory.

>          if not d.getVar("NATIVELSBSTRING", False):
>              d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d))
>          d.setVar('BB_VERSION', bb.__version__)
> --
> 2.7.4

This is my suggestion for how to split the current handling of 
bb.event.ConfigParsed (also note that I corrected the comment before the new 
if statement):

    if isinstance(e, bb.event.ConfigParsed):
        if not d.getVar("NATIVELSBSTRING", False):
            d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d))
        d.setVar('BB_VERSION', bb.__version__)

    # There might be no bb.event.ConfigParsed event if the bitbake server is
    # running, so check bb.event.BuildStarted too to make sure ${HOSTTOOLS_DIR}
    # exists.
    if isinstance(e, bb.event.ConfigParsed) or isinstance(e, bb.event.BuildStarted):
        # Works with the line in layer.conf which changes PATH to point here
        setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS', d)
        setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS_NONFATAL', d, fatal=False)

//Peter



More information about the Openembedded-core mailing list