yoctobitbakerecipe

Yocto - Bitbake - Example recipe to add a line in /etc/inittab file


I created a recipe "loader_0.1.bb" as examplified below:

PACKAGE_ARCH = "all"

SRC_URI = "file://startapp.py"


do_install () {
   install -d ${D}/sbin
   install -m 755 ${WORKDIR}/startapp.py ${D}/sbin/startapp.py
}

FILES_${PN} += "/sbin/startapp.py"

RDEPENDS_${PN} = "python"

But I need to create a new command inside inittab something like

MM:12345:respawn:/sbin/startapp.py

I found some solutions to add the entire file "inittab", but I can't use this way, because there will be other recipes with other entries in inittab.

Any ideas ? Thanks in advance


Solution

  • I created a bbappend for the recipe which installs inittab. In my case it was sysvinit-inittab_2.88dsf.bb. In the bbappend file add:

    do_install_append(){
    
        echo "MM:12345:respawn:/sbin/startapp.py" >> ${D}${sysconfdir}/inittab
    
    }