Preferences: How to disable packages

When bitbake is asked to build a package and multiple versions of that package are available then bitbake will normally select the version that has the highest version number (where the version number is defined via the PV variable).

For example if we were to ask bitbake to build procps and the following packages are available:

~/oe%> ls packages/procps 
procps-3.1.15/    procps-3.2.1/    procps-3.2.5/    procps-3.2.7/

then we would expect it to select version 3.2.7 (the highest version number) to build.

Sometimes this is not actually what you want to happen though. Perhaps you have added a new version of the package that does not yet work or maybe the new version has no support for your target yet. Help is at hand since bitbake is not only looking at the version numbers to decided which version to build but it is also looking at the preference for each of those version. The preference is defined via the DEFAULT_PREFERENCE variable contained within the recipe.

The default preference (when no DEFAULT_PREFERENCE is specified) is zero. Bitbake will find the highest preference that is available and then for all the packages at the preference level it will select the package with the highest version. In general this means that adding a positive DEFAULT_PREFERENCE will cause the package to be preferred over other versions and a negative DEFAULT_PREFERENCE will cause all other packages to be preferred.

Imagine that you are adding procps version 4.0.0, but that it does not yet work. You could delete or rename your new recipe so you can build a working image, but what you really to do is just ignore the new 4.0.0 version until it works. By adding:


to the recipe this is what will happen. Bitbake will now ignore this version (since all of the existing versions have a preference of 0). Note that you can still call bitbake directly on the recipe:

bitbake -b packages/procps/

This enables you to test, and fix the package manually without having bitbake automatically select normally.

By using this feature in conjunction with overrides you can also disable (or select) specific versions based on the override. The following example from glibc shows that this version has been disabled for the sh3 architecture because it doesn't support sh3. This will force bitbake to try and select one of the other available versions of glibc instead:

packages/glibc/ = "-99"