0

I'm working on a embedded Yocto Linux project that runs QT applications.

Here are my requirements:

  1. I need to deploy binaries and all of their systemd units as well as a custom target for some of those units.

  2. I need to simlink some of those units as wants for other already installed targets on the OS.

  3. I need to set the default.target as a newly deployed target.

  4. Maybe do a systemctl daemon-reload.

Currently I have something working but it's very much coupled between OS build and QT build systems and I was hoping to have more separation. QT deploys to correct folder however the simlinking is done by a bash script that's part of OS and bitbake starts it as part of OPKG postinst instructions.

Qmake code for handling systemd units:

TEMPLATE = aux

UNIT_FILES += \
    ./Targets/main.target \
    ./Targets/additional.target \
    ./Units/unit1.service \
    ./Units/unit2.service \
    ./Units/additional.service \
    ./Units/neededByOSTarget.service

boot2qt: {
    deploy_unit.files = $$unit.files
    deploy_unit.path = /usr/lib/systemd/system
INSTALLS += deploy_unit
}
OTHER_FILES = $$UNIT_FILES

Bitbake code for installing and enabling

pkg_postinst_${PN} () {
   # Simlink systemd units
   ${PKG_ROOT}/usr/bin/autoInstallHandler.sh -i ${PKG_ROOT}
   # Change the default target
   ln -sf /lib/systemd/system/main.target ${PKG_ROOT}/etc/systemd/system/default.target 
   /bin/systemctl daemon-reload
   /bin/systemctl start default.target &

autoInstallHandler.sh simply simlinks all of the units to proper locations

My question is can QT have something like what's in postinst? If not is there a better approach for this that maybe utilizes a different method?

Sarge324
  • 31
  • 7
  • Instead of answering directly, I would approach your problem differently. Use Qt to compile, use Yocto to deploy. I'm surprised to see service and target files in your QMake code as to me, this is really part of how you want to start it on your system (more a Yocto responsibility). Yocto has a dedicated class for that. See --> https://docs.yoctoproject.org/ref-manual/classes.html#systemd – Martin May 10 '23 at 14:04
  • I like your response and thank you for the link. There are other locations I will use this for sure. The reason I don't want to use Yocto to deploy systemd units is because I want to enable other developers to use QT creator to deploy directly to device via deploy button on the laptop. I work for a large-ish company and there's a lot of developers that do manual deploying to devices from their laptops. Second thing is if I write an implementation on Yocto with exact list of units they need to be fixed on the QT side making it more coupled. – Sarge324 May 11 '23 at 11:56
  • I should clarify that I work for the team handling the OS (yocto) side, however I'm also heavily involved in Application development. Another thing I need to add is that the separation of OS and App stack is such due to us using the same base hardware and OS for multiple projects but different app stack on top. Separation in such a way is critical for ease of development in our use case. It makes it super easy for Application team to add a new service or an app and add a systemd service and just deploy from the device to the laptop. – Sarge324 May 11 '23 at 11:59

0 Answers0