Python error - Build TorizonCore from Source With Yocto Project/OpenEmbedded

Hi there,

Hardware:
Colibri iMX6DL
with Viola Carrier Board Rev 1.2
TorizonCore 5.7.2
Python 3.10 installed

image

I’m just checking to see if anyone has come across a python error while using a Docker container and build everything inside that container, i.e. Windows 11 + WSL (v2)…

Running the command…
$ docker run --rm -it --name=crops -v ~/yocto-workdir:/workdir --workdir=/workdir -e MACHINE=colibri-imx6 -e IMAGE=[torizon-core-docker](https://github.com/toradex/meta-toradex-torizon/blob/dunfell-5.x.y/recipes-images/images/torizon-core-docker.bb) torizon/crops:dunfell-5.x.y startup-tdx.sh

reports the following output…

Build environment configured. Building target image torizon-core-docker

DISTRO=torizon-upstream MACHINE=colibri-imx6 bitbake torizon-core-docker
Loading cache: 100% |###########################################################################| Time: 0:00:00
Loaded 3850 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:

BB_VERSION           = "1.46.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "arm-tdx-linux-gnueabi"
MACHINE              = "colibri-imx6"
DISTRO               = "torizon-upstream"
DISTRO_VERSION       = "5.7.3-devel-20230725201321+build.0"
TUNE_FEATURES        = "arm armv7a vfp thumb neon callconvention-hard"
TARGET_FPU           = "hard"
meta-toradex-torizon = "HEAD:478c84ed5ea78b87bbe0e79c88aac6e8bf3c1c84"
meta-toradex-distro  = "HEAD:53f241006b8cf69c31c22ce27e837261156ddae8"
meta-toradex-bsp-common = "HEAD:f88e4c50e64ca144a7a15bd50c92a13d325f6780"
meta-oe
meta-networking
meta-filesystems
meta-python
meta-perl            = "HEAD:b5282ece919f016d91a1043769676efb02b4f0fb"
meta-virtualization  = "HEAD:beea119eb529b4a11f266004aee8b548427aea39"
meta-updater         = "HEAD:8e02177c2d9fa416f3117c5da1c0dfba7709dfbf"
meta-toradex-nxp     = "HEAD:8797f291ca2d9c8e0b2efedf37bf3bd10709ee81"
meta-freescale       = "HEAD:f66fdef1c2dc735690a7ec7dd44a534d69ea3918"
meta-freescale-3rdparty = "HEAD:4c0a166fa2809f74c93bd4c56d9a0f7ccb7818c8"
meta-yocto-bsp
meta-poky            = "HEAD:5faf10f83e45aceb3d14c904346d82ea3ce9bdcc"
meta-security        = "HEAD:c62970fda82acf75035243766ecd195243e0f82a"
meta                 = "HEAD:b3fc8ef9aba822b3d485242c8ebd0e0bff0ebfc8"

Initialising tasks: 100% |######################################################################| Time: 0:00:06
Sstate summary: Wanted 1010 Found 136 Missed 874 Current 1118 (13% match, 58% complete)
NOTE: Executing Tasks
WARNING: linux-toradex-mainline-5.4.193+gitAUTOINC+cf62fa8fd9_f5d73fd6e9-r0 do_package: KeyError in ./package
ERROR: linux-toradex-mainline-5.4.193+gitAUTOINC+cf62fa8fd9_f5d73fd6e9-r0 do_package: Error executing a python function in exec_func_python() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:sstate_report_unihash(d)
     0003:
File: '/workdir/torizon/build-torizon-upstream/conf/../../layers/openembedded-core/meta/classes/sstate.bbclass', lineno: 875, function: sstate_report_unihash
     0871:    report_unihash = getattr(bb.parse.siggen, 'report_unihash', None)
     0872:
     0873:    if report_unihash:
     0874:        ss = sstate_state_fromvars(d)
 *** 0875:        report_unihash(os.getcwd(), ss['task'], d)
     0876:}
     0877:
     0878:#
     0879:# Shell function to decompress and prepare a package for installation
File: '/workdir/torizon/layers/openembedded-core/bitbake/lib/bb/siggen.py', lineno: 555, function: report_unihash
     0551:
     0552:            if "." in self.method:
     0553:                (module, method) = self.method.rsplit('.', 1)
     0554:                locs['method'] = getattr(importlib.import_module(module), method)
 *** 0555:                outhash = bb.utils.better_eval('method(path, sigfile, task, d)', locs)
     0556:            else:
     0557:                outhash = bb.utils.better_eval(self.method + '(path, sigfile, task, d)', locs)
     0558:
     0559:            try:
File: '/workdir/torizon/layers/openembedded-core/bitbake/lib/bb/utils.py', lineno: 421, function: better_eval
     0417:    if extraglobals:
     0418:        ctx = copy.copy(ctx)
     0419:        for g in extraglobals:
     0420:            ctx[g] = extraglobals[g]
 *** 0421:    return eval(source, ctx, locals)
     0422:
     0423:@contextmanager
     0424:def fileslocked(files, *args, **kwargs):
     0425:    """Context manager for locking and unlocking file locks."""
File: '<string>', lineno: 1, function: <module>
  File "<string>", line 1, in <module>

File: '/workdir/torizon/build-torizon-upstream/conf/../../layers/openembedded-core/meta/lib/oe/sstatesig.py', lineno: 595, function: OEOuthashBasic
     0591:
     0592:                update_hash("\n")
     0593:
     0594:            # Process this directory and all its child files
 *** 0595:            process(root)
     0596:            for f in files:
     0597:                if f == 'fixmepath':
     0598:                    continue
     0599:                process(os.path.join(root, f))
File: '/workdir/torizon/build-torizon-upstream/conf/../../layers/openembedded-core/meta/lib/oe/sstatesig.py', lineno: 559, function: process
     0555:                    except KeyError as e:
     0556:                        bb.warn("KeyError in %s" % path)
     0557:                        msg = ("KeyError: %s\nPath %s is owned by uid %d, gid %d, which doesn't match "
     0558:                            "any user/group on target. This may be due to host contamination." % (e, path, s.st_uid, s.st_gid))
 *** 0559:                        raise Exception(msg).with_traceback(e.__traceback__)
     0560:
     0561:                if include_timestamps:
     0562:                    update_hash(" %10d" % s.st_mtime)
     0563:
File: '/workdir/torizon/build-torizon-upstream/conf/../../layers/openembedded-core/meta/lib/oe/sstatesig.py', lineno: 553, function: process
     0549:                    add_perm(stat.S_IXOTH, 'x')
     0550:
     0551:                if include_owners:
     0552:                    try:
 *** 0553:                        update_hash(" %10s" % pwd.getpwuid(s.st_uid).pw_name)
     0554:                        update_hash(" %10s" % grp.getgrgid(s.st_gid).gr_name)
     0555:                    except KeyError as e:
     0556:                        bb.warn("KeyError in %s" % path)
     0557:                        msg = ("KeyError: %s\nPath %s is owned by uid %d, gid %d, which doesn't match "
Exception: Exception: KeyError: 'getpwuid(): uid not found: 1000'
Path ./package is owned by uid 1000, gid 1000, which doesn't match any user/group on target. This may be due to host contamination.

ERROR: Logfile of failure stored in: /workdir/torizon/build-torizon-upstream/tmp/work/colibri_imx6-tdx-linux-gnueabi/linux-toradex-mainline/5.4.193+gitAUTOINC+cf62fa8fd9_f5d73fd6e9-r0/temp/log.do_package.413
ERROR: Task (/workdir/torizon/build-torizon-upstream/conf/../../layers/meta-toradex-bsp-common/recipes-kernel/linux/linux-toradex-mainline_5.4.bb:do_package) failed with exit code '1'
NOTE: Tasks Summary: Attempted 3181 tasks of which 3022 didn't need to be rerun and 1 failed.
NOTE: Writing buildhistory
NOTE: Writing buildhistory took: 2 seconds

Summary: 1 task failed:
  /workdir/torizon/build-torizon-upstream/conf/../../layers/meta-toradex-bsp-common/recipes-kernel/linux/linux-toradex-mainline_5.4.bb:do_package
Summary: There was 1 WARNING message shown.
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
pokyuser@c80ef7096946:/workdir/torizon/build-torizon-upstream$

It looks like the getpwuid() method is causing an error as part of the linux-toradex-mainline-5.4.193+gitAUTOINC+cf62fa8fd9_f5d73fd6e9-r0 process.

Let me know if you have any suggestions.

Many Thanks Jon

Greetings @jon2023,

I haven’t seen this exact error before when building TorizonCore with Yocto.

Have you made any changes to the build or is this just the default build?

Best Regards,
Jeremias

Good morning Jeremias,

Thanks for the update.

I’m just running a vanilla build following the steps in…

Build TorizonCore from Source With Yocto Project/OpenEmbedded (5LTS)

in a Containerized TorizonCore Build with Windows WLS2 with Python3 installed.

I’m going to run through the steps on a different PC and see if we get the same issue.

Cheers Jon

I’m going to run through the steps on a different PC and see if we get the same issue.

Are you trying on another Windows PC or a Linux one now? For clarity our build container here is derived from the CROPS container that is used by Yocto. Which supposedly should work on WSL2. Though I can’t say I ever personally tried doing Yocto builds of any kind on Windows/WSL2.

The error you got is also strange:

Path ./package is owned by uid 1000, gid 1000, which doesn't match any user/group on target. This may be due to host contamination.

Yocto does sanity checks on produces files/packages to make sure they have a UID/GID that makes sense for the target system. In this case the error is complaining that a certain package has UID/GID 1000 which doesn’t match any user/group on the target. But that’s simply not true since the torizon user has UID/GID 1000 by default.

Therefore, I’m not actually sure how or why you’re even getting this error. I can’t seem to reproduce this at all on my side with a clean build.

Best Regards,
Jeremias