Bug 8254 - Unexpected file ownership in do_install
Summary: Unexpected file ownership in do_install
Status: VERIFIED NOTABUG
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: multimedia (show other bugs)
Version: 1.8
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.0
Assignee: Ross Burton
QA Contact: Alexandru Georgescu
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-09-03 22:50 UTC by Robert Wortman
Modified: 2015-10-23 07:00 UTC (History)
7 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Wortman 2015-09-03 22:50:33 UTC
I am experiencing unexpected behavior from the fakeroot feature in bitbake. Upon completion of the do_compile() function, all files in the build directory are owned by my user and primary group. Upon entry to the do_install() function, all files in the build directory are owned by 1000:pulse (my UID, but not one of my groups). It is my understanding that when entering the fakeroot environment, files not already tracked by fakeroot should be owned by root:root.

The erroneous ownership propagates into the package's RPM file, which causes the message...

> WARNING: log_check: There is a warn message in the logfile
> WARNING: log_check: Matched keyword: [warn]
> WARNING: log_check: warning: group pulse does not exist - using root

... when building the final image.

I have observed this message in three separate packages: apache2-2.4.10-r0, cinematicexperience-1.0-r0, and cpufrequtils-008-r5. I no longer build cinematicexperience, and I used the fix at <http://comments.gmane.org/gmane.comp.handhelds.openembedded/67518> to mask the problem in cpufrequtils. For now, I am keeping the error in place in apache2 so that I can probe at the bug.

In order to observe what I have described above, I added the following apache2_%.bbappend to my local layer:

> do_compile_append() {
> 	id
> 	pwd
> 	find -ls
> }
> 
> do_install_prepend() {
> 	id
> 	pwd
> 	find -ls
> }

At the end of my log.do_compile, I find...

> uid=1000(robert) gid=1000(robert) groups=1000(robert),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)
> /opt/yocto/build/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/apache2/2.4.10-r0/build
> 10252389    4 drwxrwxr-x  12 robert   robert       4096 Sep  3 14:01 .
> 10499673    4 drwxr-xr-x   2 robert   robert       4096 Sep  3 14:01 ./aclocal-copy
> 10499674    0 lrwxrwxrwx   1 robert   robert         68 Sep  3 14:01 ./aclocal-copy/ltdl.m4 -> /opt/yocto/build/tmp/sysroots/x86_64-linux/usr/share/aclocal/ltdl.m4
> 10499683    0 lrwxrwxrwx   1 robert   robert         69 Sep  3 14:01 ./aclocal-copy/glibc21.m4 -> /opt/yocto/build/tmp/sysroots/nitrogen6x/usr/share/aclocal/glibc21.m4
> 10499675    0 lrwxrwxrwx   1 robert   robert         75 Sep  3 14:01 ./aclocal-copy/lt~obsolete.m4 -> /opt/yocto/build/tmp/sysroots/x86_64-linux/usr/share/aclocal/lt~obsolete.m4

... and 1286 more files owned by robert:robert.

At the start of my log.do_install, I find...

> uid=0(root) gid=0(root) groups=0(root)
> /opt/yocto/build/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/apache2/2.4.10-r0/build
> 10252389    4 drwxrwxr-x  12 1000     pulse        4096 Sep  3 14:01 .
> 10499673    4 drwxr-xr-x   2 1000     pulse        4096 Sep  3 14:01 ./aclocal-copy
> 10499674    0 lrwxrwxrwx   1 1000     pulse          68 Sep  3 14:01 ./aclocal-copy/ltdl.m4 -> /opt/yocto/build/tmp/sysroots/x86_64-linux/usr/share/aclocal/ltdl.m4
> 10499683    0 lrwxrwxrwx   1 1000     pulse          69 Sep  3 14:01 ./aclocal-copy/glibc21.m4 -> /opt/yocto/build/tmp/sysroots/nitrogen6x/usr/share/aclocal/glibc21.m4
> 10499675    0 lrwxrwxrwx   1 1000     pulse          75 Sep  3 14:01 ./aclocal-copy/lt~obsolete.m4 -> /opt/yocto/build/tmp/sysroots/x86_64-linux/usr/share/aclocal/lt~obsolete.m4

... and 1286 more files owned by 1000:pulse.

Again, if my understanding of the fakeroot feature is correct, they should be owned by root:root.
Comment 1 Christopher Larson 2015-09-16 23:55:19 UTC
Fakeroot runs *as root*, so you can change owner to root or other users, it doesn't change the existing ownership of existing files, those are left alone. Any do_install which blindly copies files to ${D} without chown'ing them will end up with incorrect ownership in the binary packages, this is expected behavior. Generally buildsystems we call adjust ownership to be correct for the files they install when they run 'make install', so in most cases it's not an issue, only when files are manually installed does it become problematic. Basically, this is working as expected.
Comment 2 Ross Burton 2015-09-23 11:42:58 UTC
What Chris says is right - this is working as expected and the problem is in a recipe and/or class.

Since this bug was filed there's been a new QA test added to vet recipes for this problem at packaging time instead hopefully tripping a rootfs warning, and the problems in oe-core are all fixed (caused by bad ptest install logic which was copying a file without fixing ownership, fixed in ptest.bbclass).
Comment 3 Alexandru Georgescu 2015-10-23 07:00:03 UTC
verified as per above comments