OK thanks guys, that's what I though.

I did hack 1 since I could, but good to know the hack 2. in case this ever happensĀ for packages I'm not in control of.

Cheers,
-Damien

On Thu, May 14, 2020 at 11:20 AM Quentin Schulz <quentin.schulz@streamunlimited.com> wrote:
Hi Damienm

On Thu, May 14, 2020 at 11:05:56AM +0300, Damien LEFEVRE wrote:
> Hi,
>
> Should it be possible to set PREFERRED_VERSION in the image definition
> files?
>

Conceptually, no. An image recipe is a recipe. Global data is global and
local data is local. A recipe (image or package) set local data only.

> I have 2 image files:
> - image1.bb
> - image2.bb : PREFERRED_VERSION_package_1.0.0
>
> I have a package with 2 versions:
> - package_1.0.0.bb
> - package_1.1.0.bb
>

Correct way is different distro or machine. Obviously the build impact
is high for such as small difference in images.

Two possible hacks to me:
1. package10_1.0.0.bb and package11_1.1.0.bb but then you need to manage
the dependencies inside recipes (those (r)depending on package10 or
package11). If it's a "final" package which isn't a dependency of
anything else except the image, that's actually not too bad. Then in the
image you add package10 or package11.

2. Have an intermediate recipe which RDEPENDS_${PN} += "package
(=1.1.0)" and the other on "package (=1.0.0)" and install this
intermediate recipe in the appropriate image.

There are shortcomings in both hacks (otherwise they wouldn't be called
that way :) ).

Quentin