Search code examples
yoctosystemdbitbake

bitbake way to add a system.conf setting


I am trying to find a bitbake way to add a /etc/systemd/system.conf setting (in my case "DisableControllers=cpu") into the [Manager] - currently the system.conf file is just filled with commented out parameters (i.e. nothing is set).

I have not found anything like SYSTEMD_CONF:append to do this, so I guess I have to just do something like:

systemd_%.bbappend

do_install:append() {
    echo "DisableControllers=cpu" >> ${D}${sysconfdir}/systemd/system.conf
}

I can't think of a nicer way to do that - and this looks like its a bit hacky


Solution

  • The recipe that installs system.conf is poky/meta/recipes-core/systemd/systemd-conf_1.0.bb. You can also accomplish this by overriding the system.conf that gets installed to rootfs from your own layer.

    1. Add your custom system.conf file in your layer at recipes-core/systemd/systemd-conf/system.conf
    2. Create an append file for the original recipe in your layer at poky/meta/recipes-core/systemd/systemd-conf_%.bbappend
    3. And add the following line to the append file you created
    FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
    

    As long as your layer has priority over poky (it's priority is 5) something like this should do the trick.

    Edit: If there are other layers that are fiddling with systemd-conf your layers priority needs to be higher than theirs as well.