Conditionally starting the swupdate webserver


Morten Bruun
 

Hi Yocto experts!

Background
----------------
I have a device that I build two different images for (test and prod). For the prod variant I do not want the swupdate service to start the webserver.

Currently I have a swupdate.service that overwrites the default from swupdate.

I have been experimenting with an approach where I use OVERRIDES to control the inclusion of the systemd service.

Is this a "good" (tm) way of doing this? Or is there a better way?

-----------------------
DISTRO_VARIANT = "test"

-----------------------
DISTRO_VARIANT = "prod"

swupdate_%.bbappend
-------------------------------
OVERRIDES:append = ":${DISTRO_VARIANT}"

do_install:test:append() { install -d ${D}/${systemd_unitdir}/system install -m 0644 ${WORKDIR}/hello-test.service ${D}/${systemd_unitdir}/system }
do_install:prod:append() {
  install -d ${D}/${systemd_unitdir}/system
  install -m 0644 ${WORKDIR}/hello-prod.service ${D}/${systemd_unitdir}/system
}


Stefano Babic
 

Hi Morten,

On 29.03.23 16:39, Morten Bruun wrote:
Hi Yocto experts!
Background
----------------
I have a device that I build two different images for (test and prod). For the prod variant I do not want the swupdate service to start the webserver.
Currently I have a swupdate.service that overwrites the default from swupdate.
Why ? the default service will load configuration script from /usr/lib/swupdate, and you can already override what yo need.


I have been experimenting with an approach where I use OVERRIDES to control the inclusion of the systemd service.
Is this a "good" (tm) way of doing this? Or is there a better way?
It is enough you do not install the swupdate-www package in the prod image. No Webserver is started.

Best regards,
Stefano Babic

my-test-image.bb <http://my-test-image.bb>
-----------------------
DISTRO_VARIANT = "test"
my-prod-image.bb <http://my-prod-image.bb>
-----------------------
DISTRO_VARIANT = "prod"
swupdate_%.bbappend
-------------------------------
OVERRIDES:append = ":${DISTRO_VARIANT}"
do_install:test:append() {
install -d ${D}/${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/hello-test.service ${D}/${systemd_unitdir}/system
}
do_install:prod:append() {
install -d ${D}/${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/hello-prod.service ${D}/${systemd_unitdir}/system
}
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@...
=====================================================================