Bug 8335 - Image generation fails with an exception in image.py
Summary: Image generation fails with an exception in image.py
Status: RESOLVED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: unspecified
Hardware: x86 arm
: Medium major
Target Milestone: 1.4.5
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-09-20 19:34 UTC by Jin
Modified: 2015-09-24 16:27 UTC (History)
2 users (show)

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


Attachments
This patch fixes the problem described in the ticket. (547 bytes, patch)
2015-09-20 19:34 UTC, Jin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jin 2015-09-20 19:34:30 UTC
Created attachment 2746 [details]
This patch fixes the problem described in the ticket.

An image that I am trying to build fails with the following error:

The stack trace of python calls that resulted in this exception/failure was:
File: 'do_rootfs', lineno: 17, function: <module>
     0013:    # generate final images
     0014:    create_image(d)
     0015:
     0016:
 *** 0017:do_rootfs(d)
     0018:
File: 'do_rootfs', lineno: 14, function: do_rootfs
     0010:    # generate rootfs
     0011:    create_rootfs(d)
     0012:
     0013:    # generate final images
 *** 0014:    create_image(d)
     0015:
     0016:
     0017:do_rootfs(d)
     0018:
File: '/poky/meta/lib/oe/image.py', lineno: 380, function: create_image
     0376:        execute_pre_post_process(self.d, post_process_cmds)
     0377:
     0378:
     0379:def create_image(d):
 *** 0380:    Image(d).create()
     0381:
     0382:if __name__ == "__main__":
     0383:    """
     0384:    Image creation can be called independent from bitbake environment.
File: '/poky/meta/lib/oe/image.py', lineno: 374, function: create
     0370:                    bb.fatal(result)
     0371:
     0372:            for image_type, subimages, script in image_cmds:
     0373:                bb.note("Creating symlinks for %s image ..." % image_type)
 *** 0374:                self._create_symlinks(subimages)
     0375:
     0376:        execute_pre_post_process(self.d, post_process_cmds)
     0377:
     0378:
File: '/poky/meta/lib/oe/image.py', lineno: 205, function: _create_symlinks
     0201:                if os.path.exists(img_name + ".rootfs." + type):
     0202:                    dst = link_name + "." + type
     0203:                    src = img_name + ".rootfs." + type
     0204:                    bb.note("Creating symlink: %s -> %s" % (dst, src))
 *** 0205:                    os.symlink(src, dst)
     0206:
     0207:            if manifest_name is not None and \
     0208:                    os.path.exists(manifest_name) and \
     0209:                    not os.path.exists(link_name + ".manifest"):
Exception: OSError: [Errno 17] File exists

The destination link indeed does exist in the deploy directory, can't say when it was created (I did a clean build from scratch).

I figured it won't hurt to delete the link before recreating it, the attached patch fixes the problem for me.
Comment 1 Richard Purdie 2015-09-24 14:43:23 UTC
We need more info to better debug and fix this. Is there a way we could reliably reproduce the problem? Which MACHINE are you using? Which IMAGE_FSTYPES? What was the file that failed?
Comment 2 Jin 2015-09-24 15:05:14 UTC
(In reply to comment #1)
> We need more info to better debug and fix this. Is there a way we could
> reliably reproduce the problem? 

Well, the configuration uses our own layers, I guess I could try to find a similar machine and build stock poky to make it reproducible for you; here it worked fine with Yocto 1.7 and failed after a switch to Yocto master/2.0

We do not use any custom fs generation classes for this machine though, so that part should really be "stock OE".

> Which MACHINE are you using? 

A custom spinoff config from at91sam9g20ek, there should not be anything fancy  there:

https://git.digitalstrom.org/dss-oe/dss-oe/blob/master/yocto/dS/meta-digitalstrom-devel/conf/machine/dss11-1gb-t1.conf

The stock image with which I can reproduce the problem is core-image-minimal,
it fails the same way with our custom image too.


> Which IMAGE_FSTYPES?

Checked with bitbake -e to make sure no one messes with it:

IMAGE_FSTYPES="ubi"


> What was the file that failed?

The log output:

NOTE: Creating symlink: core-image-minimal-dss11-1gb-t1.ubi -> core-image-minimal-dss11-1gb-t1-20150924145517.rootfs.ubi

Matches to:

     0204:                    bb.note("Creating symlink: %s -> %s" % (dst, src))
 *** 0205:                    os.symlink(src, dst)

The content of my /build/deploy/images/dss11-1gb-t1/ directory a the time of build failure is:

[jin@builder dss11-1gb-t1]$ ls -all core-image-minimal-dss11-1gb-t1*
-rw------- 1 jin jin      931 Sep 24 16:55 core-image-minimal-dss11-1gb-t1-20150924145517.rootfs.manifest
-rw-r--r-- 1 jin jin 11534336 Sep 24 16:55 core-image-minimal-dss11-1gb-t1-20150924145517.rootfs.ubi
-rw-r--r-- 1 jin jin 10321920 Sep 24 16:55 core-image-minimal-dss11-1gb-t1-20150924145517.rootfs.ubifs
lrwxrwxrwx 1 jin jin       57 Sep 24 16:55 core-image-minimal-dss11-1gb-t1.ubi -> core-image-minimal-dss11-1gb-t1-20150924145517.rootfs.ubi
lrwxrwxrwx 1 jin jin       59 Sep 24 16:55 core-image-minimal-dss11-1gb-t1.ubifs -> core-image-minimal-dss11-1gb-t1-20150924145517.rootfs.ubifs

So for some reason the core-image-minimal-dss11-1gb-t1.ubi link already exists (there where no core-image* fiels/links in deploy dir when I started the build).

Hope that helps, otherwise let me know if you need more info/debugging, thanks!
Comment 3 Richard Purdie 2015-09-24 15:49:04 UTC
Did you have http://git.yoctoproject.org/cgit.cgi/poky/commit/?h=master&id=9241ec579309e9d27e9391815a167911d20b38c1 applied in your test
Comment 4 Jin 2015-09-24 16:27:15 UTC
(In reply to comment #3)
> Did you have
> http://git.yoctoproject.org/cgit.cgi/poky/commit/
> ?h=master&id=9241ec579309e9d27e9391815a167911d20b38c1 applied in your test

Sorry I did not, my state was from the date of the ticket submission, this commit indeed does fix the problem for me! Thank you!