How does poky/meta/lib/oe/image.py get included when building core-image-minimal.bb?

571 views Asked by At

I am using the Yocto Project, Jethro release. However, I think this question applies to other releases as well.

I need to modify the image creation process. I have read the BitBake manual, but I still don't know how a full python script or several scripts are included.

Here is what I have found so far:

bitbake core-image-mininmal

After bitbake reads all the config files and parses bblayers.conf, it searches all the layer directories for the recipe core-image-minimal.bb

In core-image-minimal.bb, we have:

inherit core-image

This inherits the class core-image.bbclass which in turn inherits image.bbclass which contains the bitbake code:

fakeroot python do_rootfs () {
    from oe.rootfs import create_rootfs
    from oe.image import create_image
    from oe.manifest import create_manifest

    # generate the initial manifest
    create_manifest(d)

    # generate rootfs
    create_rootfs(d)

    # generate final images
    create_image(d)
}

Searching the source tree for the text create_image, I found the following in image.py:

def create_image(d):
    Image(d).create()

and also:

def create(self):
    bb.note("###### Generate images #######")
    pre_process_cmds = self.d.getVar("IMAGE_PREPROCESS_COMMAND", True)
    post_process_cmds = self.d.getVar("IMAGE_POSTPROCESS_COMMAND", True)

I've also created my own class my-class.bbclass and put the following in it:

fakeroot python do_rootfs_prepend () {
    print("==> do_rootfs_prepend")
}

fakeroot python do_rootfs_append () {
    print("==> do_rootfs_append")
}

and I see the messages in the log file, so I know this is working to add my python code to the do_rootfs function in image.bbclass.

However, I would still like to know how image.py and a whole bunch of other *.py files are included (e.g. rootfs.py) from the poky/meta/lib/oe directory.

1

There are 1 answers

0
Jussi Kukkonen On BEST ANSWER

First, note that rootfs/image code has been refactored quite a bit after the Jethro release: the last releases do not have some of the functions referred to in your example.

There's no Yocto-specific magic in the library function usage: they are used via standard python module import, just with meta/lib/ in the module search path, e.g.

from oe.image import create_image

will make the create_image() function from meta/lib/oe/image.py available in the current scope.