Bug 771 - Unrecoverable failure if Poky tree is not writeable
Summary: Unrecoverable failure if Poky tree is not writeable
Status: RESOLVED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: High major
Target Milestone: 1.0 M4
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2011-02-24 21:08 UTC by Gary Thomas
Modified: 2011-02-25 09:25 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments
Better error handling in bb.copyfile (1.15 KB, patch)
2011-02-25 04:40 UTC, Gary Thomas
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Thomas 2011-02-24 21:08:50 UTC
My Poky source tree is in /opt/amltd/poky and is not other/world writeable.
I get this error:
| ERROR: Error executing a python function in /opt/amltd/poky/meta-xyz/packages/images/xyz-server-image.bb:
| OSError: [Errno 1] Operation not permitted: '/opt/amltd/poky/LICENSE'
| 
| ERROR: The stack trace of python calls that resulted in this exception/failure was:
| ERROR:   File "do_populate_lic", line 78, in <module>
| ERROR:
| ERROR:   File "do_populate_lic", line 34, in do_populate_lic
| ERROR:
| ERROR:   File "/opt/amltd/poky/bitbake/lib/bb/__init__.py", line 114, in newFunc
| ERROR:     return func(*args, **kwargs)
| ERROR:
| ERROR:   File "/opt/amltd/poky/bitbake/lib/bb/utils.py", line 773, in copyfile
| ERROR:     os.chmod(src, stat.S_IRUSR) # Make sure we can read it
| ERROR:
| ERROR: The code that was being executed was:
| ERROR:      0074:            bb.warn("This could be either because we do not have a generic for this license or the LICENSE field is incorrect")
| ERROR:      0075:            pass
| ERROR:      0076:
| ERROR:      0077:
| ERROR:  *** 0078:do_populate_lic(d)
| ERROR:      0079:
| ERROR: (file: 'do_populate_lic', lineno: 78, function: <module>)
| ERROR:      0030:    for url in lic_files.split():
| ERROR:      0031:        (type, host, path, user, pswd, parm) = bb.decodeurl(url)
| ERROR:      0032:        # We want the license file to be copied into the destination
| ERROR:      0033:        srclicfile = os.path.join(srcdir, path)
| ERROR:  *** 0034:        ret = bb.copyfile(srclicfile, os.path.join(destdir, os.path.basename(path)))
| ERROR:      0035:        # If the copy didn't occur, something horrible went wrong and we fail out
| ERROR:      0036:        if ret is False or ret == 0:
| ERROR:      0037:            bb.warn("%s could not be copied for some reason. It may not exist. WARN for now." % srclicfile)
| ERROR:      0038:
| ERROR: (file: 'do_populate_lic', lineno: 34, function: do_populate_lic)
| ERROR: Function 'do_populate_lic' failed

The image recipe has this line:
  LIC_FILES_CHKSUM = "file://${POKYBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 "
indicating I want to use just the generic license.

My Poky source tree looks like this:
$ ls -l /opt/amltd/poky/
total 52
drwxrwxr-x  6 root root 4096 Feb  5 13:04 bitbake
drwxrwxr-x  8 root root 4096 Feb  5 13:04 documentation
drwxrwxr-x  3 root root 4096 Oct 22 23:39 handbook
-rw-rw-r--  1 root root  545 Aug 18  2010 LICENSE
drwxrwxr-x 20 root root 4096 Feb  5 13:04 meta
drwxrwxr-x  4 root root 4096 Oct 27 13:33 meta-amltd
drwxrwxr-x  4 root root 4096 Feb  1 21:50 meta-efacec
drwxrwxr-x  4 root root 4096 Feb  5 13:04 meta-oe
drwxrwxr-x  4 root root 4096 Oct 12 21:34 meta-oe_extra
-rwxrwxr-x  1 root root 1493 Feb  5 13:04 poky-init-build-env
-rw-rw-r--  1 root root  636 Aug 18  2010 README
drwxrwxr-x  5 root root 4096 Feb 23 23:46 scripts
drwxrwxr-x  2 root root 4096 Feb 24 01:27 sources

I think this condition should only be a warning as it clearly is under other circumstances which print messages like:
WARNING: zip: Something went wrong with copying: Info-ZIP to /opt/amltd/poky/meta/files/common-licenses
WARNING: This could be either because we do not have a generic for this license or the LICENSE field is incorrect
Comment 1 Gary Thomas 2011-02-25 04:40:18 UTC
Created attachment 96 [details]
Better error handling in bb.copyfile

If the destination directory is write protected, no actions can be taken on files, hence all operations must be protected from exceptions.
Comment 2 Richard Purdie 2011-02-25 09:25:56 UTC
I've fixed this in http://git.pokylinux.org/cgit.cgi/poky/commit/?id=9166b9e32fd6f618f9597b07d88cef09a88916a1

I've taken a different approach to the attachment since I'd rather just not touch the file at all if we already have read access. If we don't and its on a readonly filesystem, we're in trouble regardless.