> -----Original Message-----
> From: [email protected] <openembedded-
> [email protected]> On Behalf Of Robert Yang
> Sent: den 20 januari 2022 08:09
> To: [email protected]
> Cc: [email protected]
> 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 <[email protected]>
> ---
>  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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#160760): 
https://lists.openembedded.org/g/openembedded-core/message/160760
Mute This Topic: https://lists.openembedded.org/mt/88554465/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to