How to build a recipe but not include it in the OS image - yocto

I have custom recipes in my project which I include in the build process using IMAGE_INSTALL_append. This builds & adds all the recipes to the image.
What I need is that only certain recipes get added to the image and others are just built but not added to the image, so That I can install these manually using the rpms.
Is there a way to do this?
Thanks in advance

you can build every package independently using bitbake without including it in the final image:
bitbake <recipe name>
This will build the recipe and put the rpm in the build/deploy/rpm directory.

Related

Restrict a library from going into final image

I am building a Yocto image. There are some GPLv3 libraries which are required only at build time. I have put GPLv3 as INCOMPATIBLE_LICENSE and whitelisted the libraries which are required at build time. But these libraries are getting into the final image. How can I restrict them into the final image and only use them at the build time?
If we think about the Yocto basics, we know that everything goes into the final image is a collection of recipes providing packages that are collected together in a single root file system.
So, what makes a recipe goes into the final rootfs ?
Added via IMAGE_INSTALL.
Be set as RDEPENDS of another recipe.
You need to analyse that deeply to find out what goes into your final rootfs.
Also, you may not find it obvious in the content of IMAGE_INSTALL by running:
bitbake -e <your_image_recipe> | grep ^IMAGE_INSTALL=
but, you may see some packagegroups that are shipped. A packagegroup is a group that RDEPENDS on a list of other recipes.
So, you need to carefully analyse them (if found) to see what provides the lib you want to inhibit from rootfs.
packagegroups usually gets shipped dynamically via IMAGE_FEATURES variable.
So, those are the most important points that are responsible of shipping a recipe to the rootfs. So, Analyse your wanted recipe.
Is it an RDEPENDS of another recipe ?
Find out where exactly it gets called to be shipped.
Removing the installation of lib from do_install task by adding something like this in recipe e.g gdb as you said
do_install:append()
{
#remove the lib which you don't want to ship into image
}
And make sure the same lib is not added to FILES var in recipe
e.g FILES:${PN} += "< lib >"
PACKAGE_EXCLUDE worked for me. If packages listed under PACKAGE_EXCLUDE is getting into the final image, then this will raise an error.
Also if any other package has a runtime dependency on a package listed under PACKAGE_EXCLUDE, then this will raise an error too.
References:
https://docs.yoctoproject.org/ref-manual/variables.html#term-PACKAGE_EXCLUDE
https://git.yoctoproject.org/poky/tree/meta/conf/documentation.conf#n313

Avoid a library from going to final image in Yocto

I am working on building an Yocto image in which I use some Open Source libraries whiich are required only during the build time. Currently they are not part of the final image. Is there a way to make sure that they do not make it to the final image in the future also?
Thanks in advance.
If any recipe is found in the final image that means the recipe is specified into one of the install variables (IMAGE_INSTALL, IMAGE_FEATURES, ...) or it is specified as a run time dependency of another recipe (RDEPENDS).
I could be one of these cases:
If the libraries are provided by a separate recipe and that recipe is specified as DEPENDS of your main recipe. Make sure that the recipe of the libraries is not present in IMAGE_INSTALL or any image installation variable. And make sure that it is not present in any RDEPENDS variable.
If the main recipe is generating libraries and using them to compile the final result, it is easy, just make sure that they are not installed or mentioned in do_install task.
I found PACKAGE_EXCLUDE to be more helpful which throws an error when the packages of the OSS libraries are being installed on the image by anyone.
Refer the doc - https://docs.yoctoproject.org/2.5.1/ref-manual/ref-manual.html#var-PACKAGE_EXCLUDE

IMX7D Sabre Yocto Project with OP-TEE examples

First time I am trying to create SD-Card Linux image for imx7d sabre with OP-TEE using Yocto. I followed this document https://www.nxp.com/docs/en/user-guide/i.MX_Yocto_Project_User's_Guide_Linux.pdf for building the image. I was able to build the image with OP-TEE and successfully run the OP-TEE Xtest. But now I do not know how to run OP-TEE examples in the image. These binaries are not present in the bin folder
Questions
How to include OP-TEE examples to Yocto
In future how to add my own trusted applications to Yocto.
Thanks
How to include OP-TEE examples to Yocto
Add to your local.conf:
IMAGE_INSTALL_append = " optee-examples"
In future how to add my own trusted applications to Yocto.
Create a recipe based on recipes-security/optee/optee-examples.bb and add it to the image as stated above.

How can I add or delete the recipe in Yocto image by toaster

I use Yocto image to development some product.
And I need to add or delete recipe in my Yocto image.
I try to using toaster and success to analysis my Yocto image.
But I can't delete already including recipes.
This image is customized and already using in developing.
When starting the toaster, it doesn't have any UI for delete package or recipe.
Only can analysis build image.
Someone has any ideas??
Open toaster and find the bitbake variable at bottom side. then you will find the Add variable.
To remove recipe use IMAGE_INSTALL_remove
To add recipe use IMAGE_INSTALL_append

how to remove specific packages from the final rootfs image built by bitbake

I am trying to remove some open source packages that have GPLv3 licensing attached to them that we cannot distribute as part of the final production image . While these packages can be removed using "INCOMPATIBLE_LICENSE=GPLv3" in local.conf but it removes every package that's tagged GPLv3.
I have used
PREFERRED_VERSION_recipename=(GPLv2 recipe_version)
and downgraded all the GPLv3 packages to GPLv2 that we want to push into the final image. But there are several GPLv3 packages that we want to keep as part of the debug image for example M4, make, gdb, bison. There is no need for these packages to be in the final production image but these cannot be removed from the build completely as they are needed during the build/debug.
SO, How do i remove these packages/recipe from the final rootfs image while letting them being as part of the build process and letting them build. In other words I want to let the bitbake build them from the GPLv3 source but keep them out the of the final rootfs image.
I did look at the poky/lib/oe/manifest.py and rootfs.py create function ==> where the final rootfs manifest is being created but couldn't figure out what exactly needs to be set from the bitbake. Does the do_rootfs need to be overwritten. if so what variables need to be set for overriding the final manifest.
There's no single way of doing what you want. One way is to have your production image consists of what you need to deliver, and then let your dev-image require production-image.bb. In that way you can easily extend the dev image with your extra packages.
I've got a similar issue, as I want gdbserver in my dev-image. (Sofar, nothing else that's GPLv3 is necessary / wanted in my dev image). What I've done, is to set
INCOMPATIBLE_LICENSE = "GPL-3.0 LGPL-3.0 AGPL-3.0"
INCOMPATIBLE_LICENSE_pn-gdb = ""
That basically allows gdb to be built, but nothing else that's GPLv3 licensed. Then, my images inherit a company-image.bbclass instead of directly inheriting image.bbclass. In company-image.bbclass, I've got a function like:
python () {
for p in d.getVar('IMAGE_INSTALL', True).split():
if p in ['gdb', 'gdbserver'] and not d.getVar('IMAGE_BASENAME', True) == 'company-dev-image':
bb.fatal("gdb/gdbserver is not allowed in this image!")
}
That will ensure that gdb and gdbserver can only be installed in company-dev-image; thus, there's no risk of having them distributed in the production image.
I would like to provide an example that is , if we would like to remove the "openssh" package from build, needs to be updated "local.conf" file as mentioned below.
Please the add the following line into BUILDFOLDER/conf/local.conf file
PACKAGECONFIG_remove = "openssh"