rauc / meta-rauc

Yocto/Open Embedded meta layer for RAUC, the embedded Linux update framework
MIT License
165 stars 91 forks source link

Can't find rauc.service files #202

Closed twinning92 closed 3 years ago

twinning92 commented 3 years ago

I am attempting to build and install RAUC on my target system. Bitbake is complaining about not being able to find rauc.service. I can see that it is generated in the data/ directory as stated in the documentation, however I can't seem to point the build system to it. When I set S="${WORKDIR}/build/data" I get other errors about not finding other files (license files specifically).

I am confused around the workflow for the .service files. I'm thinking that in my .bbappend I need to do something with the file. When I move rauc.service into ${WORKDIR} I still get the error:

ERROR: rauc-1.5.1-r0 do_package: Didn't find service unit 'rauc.service', specified in SYSTEMD_SERVICE_rauc-service.

When I manually copy the file into my layer (in the files folder next to my .bbappend ) I can resolve the error message, however that doesn't really feel like an appropriate course of action: initial build to generate .service file, inevitably fail to build, copy .service file to directory that can be seen, then build again.

I've got

FILESEXTRAPATHS:prepend := "${THISDIR}/files:${WORKDIR}/build/data/:"
SRC_URI:append := " file://system.conf file://rauc.service "

at the top of my recipe, but bitbake just complains it can't find the file and lists all the places it looks including:

/home/user/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/rauc/%-r0/build/data/

which is where that file would be. I believe this is due to the error occurring during do_fetch, which obviously occurs before the do_package stage.

Unfortunately I feel my infancy with Yocto Project is the limiting factor here, I would be very grateful for some of your input

Here is my rauc_%.bbappend file in it's entirety.

FILESEXTRAPATHS:prepend := "${THISDIR}/files:${WORKDIR}/build/data/:"
SRC_URI:append := " file://system.conf \
file://rauc.service "

FILES_${PN}="${D}/etc/rauc/system.conf ${D}${systemd_unitdir}/rauc.service"

do_install(){
    install -d ${D}/etc/rauc/
    install -d ${D}/lib/systemd/system

    install -m 600 ${WORKDIR}/system.conf ${D}/etc/rauc/
    install -m 600 ${WORKDIR}/rauc.service ${D}${systemd_unitdir}/

}
ejoerns commented 3 years ago

I am attempting to build and install RAUC on my target system. Bitbake is complaining about not being able to find rauc.service. I can see that it is generated in the data/ directory as stated in the documentation, however I can't seem to point the build system to it. When I set S="${WORKDIR}/build/data" I get other errors about not finding other files (license files specifically).

$S is the source directory, it must not point to the build directory (except when S and B happen to be identical for in-tree builds). Do not modify $S at all as long as you do not change the SRC_URI for the rauc source archive.

I am confused around the workflow for the .service files. I'm thinking that in my .bbappend I need to do something with the file. When I move rauc.service into ${WORKDIR} I still get the error:

ERROR: rauc-1.5.1-r0 do_package: Didn't find service unit 'rauc.service', specified in SYSTEMD_SERVICE_rauc-service.

When I manually copy the file into my layer (in the files folder next to my .bbappend ) I can resolve the error message, however that doesn't really feel like an appropriate course of action: initial build to generate .service file, inevitably fail to build, copy .service file to directory that can be seen, then build again.

I've got

FILESEXTRAPATHS:prepend := "${THISDIR}/files:${WORKDIR}/build/data/:"
SRC_URI:append := " file://system.conf file://rauc.service "

Don't do that. Never let input paths point to anything in ${WORKDIR}. It should simply work with ${THISDIR}/files and putting system.conf next to your recipe in a files/ folder.

Do you need to add a modified rauc.service? Otherwise remove everything added for this.

at the top of my recipe, but bitbake just complains it can't find the file and lists all the places it looks including:

/home/user/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/rauc/%-r0/build/data/

which is where that file would be. I believe this is due to the error occurring during do_fetch, which obviously occurs before the do_package stage.

fetch clears source dir and then (in your case) tries to grab a file from there. That won't work.

Unfortunately I feel my infancy with Yocto Project is the limiting factor here, I would be very grateful for some of your input

Here is my rauc_%.bbappend file in it's entirety.

FILESEXTRAPATHS:prepend := "${THISDIR}/files:${WORKDIR}/build/data/:"
SRC_URI:append := " file://system.conf \
file://rauc.service "

FILES_${PN}="${D}/etc/rauc/system.conf ${D}${systemd_unitdir}/rauc.service"

do_install(){
  install -d ${D}/etc/rauc/
  install -d ${D}/lib/systemd/system

  install -m 600 ${WORKDIR}/system.conf ${D}/etc/rauc/
  install -m 600 ${WORKDIR}/rauc.service ${D}${systemd_unitdir}/

}

It shoud better look like

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

This adds your recipes folder subfolder files/ to the search path for SRC_URI items. Place your system.conf there. Not more needed for a simple setup.

Also refer to https://rauc.readthedocs.io/en/latest/integration.html#target-system-setup

twinning92 commented 3 years ago

Do you need to add a modified rauc.service? Otherwise remove everything added for this.

No, I dont need a modified rauc.service. However, without adding the file to SRC_URI and FILES_${PN} the build system complains about not being able to locate rauc.service

This recipe (as I have interpreted the quoted instruction):

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:append := " file://system.conf "

FILES_${PN} +="/etc/rauc/system.conf"

do_install(){
    install -d ${D}/etc/rauc/

    install -m 600 ${WORKDIR}/system.conf ${D}/etc/rauc/

}

with this structure

└─$ tree .
.
├── files
│   ├── keyring.pem
│   └── system.config
├── make-rauc-bundle.bb
└── rauc_%.bbappend

1 directory, 4 files

Gives this error:


ERROR: rauc-1.5.1-r0 do_package: Didn't find service unit 'rauc.service', specified in SYSTEMD_SERVICE_rauc-service.

The only way I could get it to build was with this recipe:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:append := " file://system.conf file://rauc.service "

FILES_${PN} +="/etc/rauc/system.conf /lib/systemd/system/rauc.service /lib/systemd/system/rauc-mark-good.service"

do_install(){
    install -d ${D}/etc/rauc/
    install -d ${D}/lib/systemd/system

    install -m 600 ${WORKDIR}/system.conf ${D}/etc/rauc/
    install -m 600 ${WORKDIR}/rauc.service ${D}/lib/systemd/system/
    install -m 600 ${WORKDIR}/rauc-mark-good.service ${D}/lib/systemd/system/rauc-mark-good.service

}

Interestingly I don't have the same problem with rauc-mark-good.service, I am able to install it without declaring it in SRC_URI and having it in the files directory- the build system seems to be able to locate it.

ejoerns commented 3 years ago

Do you need to add a modified rauc.service? Otherwise remove everything added for this.

No, I dont need a modified rauc.service. However, without adding the file to SRC_URI and FILES_${PN} the build system complains about not being able to locate rauc.service

This recipe (as I have interpreted the quoted instruction):

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:append := " file://system.conf "

FILES_${PN} +="/etc/rauc/system.conf"

do_install(){
  install -d ${D}/etc/rauc/

  install -m 600 ${WORKDIR}/system.conf ${D}/etc/rauc/

}

No, this was literally meant as I wrote.

And what you do here is you override the entire default do_install task. It's no surprise that this leads to no files installed.

with this structure

└─$ tree .
.
├── files
│   ├── keyring.pem
│   └── system.config
├── make-rauc-bundle.bb
└── rauc_%.bbappend

1 directory, 4 files

This looks ok. Except that I would not mix it with the bundle recipe, but this should not be critical here.

Gives this error:


ERROR: rauc-1.5.1-r0 do_package: Didn't find service unit 'rauc.service', specified in SYSTEMD_SERVICE_rauc-service.

The only way I could get it to build was with this recipe:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:append := " file://system.conf file://rauc.service "

FILES_${PN} +="/etc/rauc/system.conf /lib/systemd/system/rauc.service /lib/systemd/system/rauc-mark-good.service"

do_install(){
  install -d ${D}/etc/rauc/
  install -d ${D}/lib/systemd/system

  install -m 600 ${WORKDIR}/system.conf ${D}/etc/rauc/
  install -m 600 ${WORKDIR}/rauc.service ${D}/lib/systemd/system/
  install -m 600 ${WORKDIR}/rauc-mark-good.service ${D}/lib/systemd/system/rauc-mark-good.service

}

Of course. If you override the task, you have to rewrite it on your own.

Just don't touch it. And if you have to (you do not have to for system.conf as this already installs a dummy variant by default), then you should use a do_install:append().

Interestingly I don't have the same problem with rauc-mark-good.service, I am able to install it without declaring it in SRC_URI and having it in the files directory- the build system seems to be able to locate it.

Maybe you did not override do_install there?

twinning92 commented 3 years ago

@ejoerns thank you for your help man, I appreciate it.

On Friday I tried just having the one FILESEXTRAPATHS line as specified in the documentation, I was still getting the service file cannot be found error.

Not sure what I did differently, but it ended up working perfectly after I started on it again after the weekend. My guess would be something was cached in Yocto? I have exactly this as my rauc_%.bbappend file now:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

and

.
├── files
│   ├── ca.cert.pem
│   └── system.conf
└── rauc_%.bbappend

It builds without complaint.

Yocto works in mysterious ways... (was definitely my fault...) Thanks again!

ejoerns commented 3 years ago

It builds without complaint.

Glad you solved it :rocket: :+1:

Yocto works in mysterious ways... (was definitely my fault...) Thanks again!

This works because the base recipe already installs an example system.conf. So what you do here is to tell the bitbake fetcher to look first in your new directory for files before looking into the recipes default paths. This way it finds your specific system.conf instead of our generic example one. So, no mystery involved I hope ;)