Error on SDK build for stm32mp21-disco for scarthgap (and possibly others)
https://github.com/STMicroelectronics/meta-st-stm32mp/blob/scarthgap/recipes-bsp/trusted-firmware-m/tf-m-stm32mp.inc#L263 and the following cp commands preserve the ownership of the file which is a problem for yocto.
When I build the sdk, I am getting the following error:
Exception: Exception: KeyError: 'getpwuid(): uid not found: <my-uid-here>'
Path <path-to-build-folder>/tmp/work/x86_64-nativesdk-<distro-sdk-name>-linux/nativesdk-tf-m-stm32mp-scripts/v2.1.4-stm32mp-r2.1/sstate-build-package/package/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-<distro-sdk-name>-linux/usr/share/tf-m/scripts/wrapper/imgtool/__init__.py is owned by uid <my-uid-here>, gid <my-gid-here>, which doesn't match any user/group on target. This may be due to host contamination.
The fix is quite easy, any instance of “cp -a” needs to be replaced by “cp -a --no-preserve=ownership”. So you copy every other attribute but the ownership.
I fixed it in a .bbappend but that would be nice to fix it in the source code directly: https://github.com/STMicroelectronics/meta-st-stm32mp/blob/scarthgap/recipes-bsp/trusted-firmware-m/tf-m-stm32mp.inc#L263
