Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: Robert Yang <liezhi.yang@windriver.com>,
	"openembedded-core@lists.openembedded.org"
	<openembedded-core@lists.openembedded.org>
Cc: "jupiter.hce@gmail.com" <jupiter.hce@gmail.com>
Subject: RE: [OE-core] [PATCH 1/1] bitbake.conf: Add BB_TASK_NETWORK to enable task network globally
Date: Thu, 20 Jan 2022 13:47:07 +0000	[thread overview]
Message-ID: <b42e9f3bde0a4126bde3e4969412ee1b@axis.com> (raw)
In-Reply-To: <bb3ae8dbd929eac83394be5fe3284dd79c895e44.1642662353.git.liezhi.yang@windriver.com>

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-
> core@lists.openembedded.org> On Behalf Of Robert Yang
> Sent: den 20 januari 2022 08:09
> To: openembedded-core@lists.openembedded.org
> Cc: jupiter.hce@gmail.com
> Subject: [OE-core] [PATCH 1/1] bitbake.conf: Add BB_TASK_NETWORK to enable
> task network globally
> 
> The NIS or icecc can't work when task network is dissable, add
> BB_TASK_NETWORK to enable network globally for such exceptions.
> 
> Note, enable nscd on the build machine might be a solution, but that isn't
> reliable since it depends on whether the network function has been cached
> or not.
> 
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>  meta/classes/icecc.bbclass |  2 ++
>  meta/conf/bitbake.conf     |  3 +++
>  meta/lib/oe/utils.py       | 15 +++++++++++++++
>  3 files changed, 20 insertions(+)
> 
> diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass
> index 794e9930ad9..c39c86458a4 100644
> --- a/meta/classes/icecc.bbclass
> +++ b/meta/classes/icecc.bbclass
> @@ -41,6 +41,8 @@ ICECC_ENV_EXEC ?= "${STAGING_BINDIR_NATIVE}/icecc-create-env"
> 
>  HOSTTOOLS_NONFATAL += "icecc patchelf"
> 
> +BB_TASK_NETWORK ? = "1"
> +
>  # This version can be incremented when changes are made to the environment that
>  # invalidate the version on the compile nodes. Changing it will cause a new
>  # environment to be created.
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index fba99e8f0cd..bf5bcd55519 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -946,3 +946,6 @@ MULTILIB_VARIANTS ??= ""
>  # what it would be anyway if the signature generator (e.g. OEEquivHash)
> doesn't
>  # support unihashes.
>  BB_UNIHASH ?= "${BB_TASKHASH}"
> +
> +# Enable task network for remote user such as NIS.
> +BB_TASK_NETWORK ??= "${@['1', '0'][oe.utils.is_local_uid()]}"

I think this is more readable:

BB_TASK_NETWORK ??= "${@0 if oe.utils.is_local_uid() else 1}"

An even more readable solution would be to rename the function to 
is_nonlocal_uid() and make it return the inverse of what it returns 
now.

You probably also want to change it to use := instead of ??= so that 
/etc/passwd is only parsed once. This might require to introduce 
another variable: 

UID_IS_NONLOCAL := "${@0 if oe.utils.is_local_uid() else 1}"
BB_TASK_NETWORK ??= "${UID_IS_NONLOCAL}"

> diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
> index 136650e6f74..c21f034aafc 100644
> --- a/meta/lib/oe/utils.py
> +++ b/meta/lib/oe/utils.py
> @@ -595,3 +595,18 @@ def directory_size(root, blocksize=4096):
>          total += sum(roundup(getsize(os.path.join(root, name))) for name in files)
>          total += roundup(getsize(root))
>      return total
> +
> +def is_local_uid(uid=''):
> +    """
> +    Check whether uid is a local one or not.
> +    Can't use pwd module since it gets all UIDs, not local ones only.
> +    """
> +    if not uid:
> +        uid = os.getuid()
> +    local_uids = set()
> +    with open('/etc/passwd', 'r') as f:
> +        for line in f.readlines():
> +            if not ':' in line:
> +                continue
> +            local_uids.add(line.split(':')[2])
> +    return uid in local_uids
> --
> 2.31.1

//Peter



  parent reply	other threads:[~2022-01-20 13:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20  7:09 [PATCH 0/1] bitbake.conf: Add BB_TASK_NETWORK to enable task network globally Robert Yang
2022-01-20  7:09 ` [PATCH 1/1] " Robert Yang
2022-01-20 13:31   ` [OE-core] " Quentin Schulz
2022-01-21  3:32     ` Robert Yang
2022-01-20 13:38   ` Richard Purdie
2022-01-21  3:53     ` Robert Yang
2022-01-20 13:47   ` Peter Kjellerstedt [this message]
2022-01-21  3:54     ` Robert Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b42e9f3bde0a4126bde3e4969412ee1b@axis.com \
    --to=peter.kjellerstedt@axis.com \
    --cc=jupiter.hce@gmail.com \
    --cc=liezhi.yang@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox