Installing specific systemd service file according to selected distro


davis roman <davis.roman84@...>
 

Hello,

I have a recipe that contains two service files( A and B) and I build
for two distros where each include the foo recipe.

When I build for distro A, I need to use foo's service file A but when
I build distro B, I need to use foo's service file B.

I could add some logic in the foo recipe to detect the DISTRO and
install the proper service file but I have a feeling this isn't the
yocto way.

Is there a better way of handling this use case?

Thank you,

Davis


Konrad Weihmann <kweihmann@...>
 

Fairly easy, each distro creates an OVERRIDE by default, so you could do

A:poky = "foo.service"
A:yourdistro = "bar.service"

SYSTEMD_PACKAGES = "${A}"

do_install:append() {
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/${A} ${D}${systemd_system_unitdir}
}

you could also try to create distro-specific do_install appends like

do_install:append:<yourdistro> if you need to do further step besides installing

On 14.01.22 06:54, davis roman wrote:
Hello,
I have a recipe that contains two service files( A and B) and I build
for two distros where each include the foo recipe.
When I build for distro A, I need to use foo's service file A but when
I build distro B, I need to use foo's service file B.
I could add some logic in the foo recipe to detect the DISTRO and
install the proper service file but I have a feeling this isn't the
yocto way.
Is there a better way of handling this use case?
Thank you,
Davis