Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use a specific package version in a Yocto image recipe?

My current project is based on Yocto Daisy, with custom layer declarations in one git repo and application code contained in another git repo. The application code lifecycle is somewhat separate from the custom layer lifecycle, so I'd like to be able to capture that in the build.

To that end, I have two recipes that extend core-image: 'my-image' and 'my-image-dev'. I would like to have 'my-image' always use a tagged version of 'application' (such as v0.1, v0.2, etc). I would like to have 'my-image-dev' always use 'application' HEAD from git master.

I have written recipes 'application_0.1.bb' and 'application_git.bb', and tested them in isolation. They behave as expected - 'application_0.1.bb' gets tag 0.1, and 'application_git.bb' gets master.

The problem comes in when I try to instruct a particular image to use a specific version of 'application'. I would have thought this would be as simple as adding PREFERRED_VERSION_application = "0.1" and PREFERRED_VERSION_application = "git%" to my image recipes, but this gives me no love. The only places that PREFERRED_VERSION seems to work is in layer.conf and machine.conf, which doesn't help me since both images are for the same logical machine.

So this is my question - is there a way to declare a dependency on a particular version of a package from a Yocto image?

like image 490
Nick Stevens Avatar asked Sep 03 '14 03:09

Nick Stevens


1 Answers

I found a solution that allows me to do exactly what I was looking for.

The key was to split my 'application' package into two packages - 'application' and 'application-git'. I then moved the release-versioned recipe to 'application' and the development recipe to 'application-git'. To reduce duplicated code I moved all the common logic between the two recipes into a file 'application/application.inc' and included it in 'application-git.bb' using require recipes-application/application/application.inc.

Now I can include the appropriate package in my images. So 'my-image.bb' contains IMAGE_INSTALL += "application". 'my-image-dev.bb' requires 'my-image.bb', so I added the line IMAGE_INSTALL_remove = "application" and added IMAGE_INSTALL += "application-git".

It's a mild abuse of the system, but since it results in a clear result (release version in image, dev version in image-dev), I think it's worth it.

like image 92
Nick Stevens Avatar answered Nov 10 '22 05:11

Nick Stevens