Search code examples
embeddedyoctosystemd

Disable systemD services at compile time


I have looked at this question: Disable a standard systemd service in Yocto build and am trying to implement the solution with the systemd_%.bbappend file, but it doesn't appear to be working. I am trying to remove (preferred) or at least disable two services, the NTP service and the Getty service. I am running Yocto (Pyro) on a 4.14.16 kernel with an i.MX6 target.

I have been putting the file in poky/meta-markem-imaje-bsp/recipes-core/systemd/. Does it need to be somewhere else?

This is the contents of my file:

DESCRIPTION = "Customization of systemD services."

do_install_append() {
    rm ${D}${sysconfdir}/systemd/system/getty.target.wants/getty@tty1.service
}

PACKAGECONFIG_remove = "timesyncd"

FILES_${PN} += "${sysconfdir}/systemd/system"

REQUIRED_DISTRO_FEATURES= "systemd"

Update - I fixed the bb_append to be just bbappend, and it no longer compiles. I am seeing this:

Update 2 - The file is working. For some reason, putting getty in the PACKAGECONFIG_remove didn't work, but the deletion of the link worked to disable the service (once I fixed the rm command). I have updated the bbappend file above with the final version. Thanks all.

Keep in mind that I am a Yocto noob.


Solution

  • After taking a look into systemd_232.bb and systemd.inc on the pyro branch it looks like the first .patch file in your SRC_URI failes to apply with "missing file".

    I think this is because you overwrite S with ${WORKDIR} but in systemd.inc it is set to "${WORKDIR}/git". So the git repository of systemd is cloned to ${WORKDIR}/git and you try to patch it in ${WORKDIR}.

    Remove S=${WORKDIR} from your .bbappend file should do the trick.