Neeraj Usadadiya
Neeraj Usadadiya

Reputation: 11

install from yocto recipe not able to create init.d folder

In yocto tpm2 recipe the following recipe is not workin fine:

install -d "${D}${sysconfdir}/init.d"

It's not able to create a folder named init.d. If I change folder name to init_d it is able to create the folder. It appears strange to me becuase init.d is a very common in Linux and it's present under etc and I guess many recipes in Ycoto are doing this. If I execute the command as install -d /home/builduser/build/tmp/work/armv8a-poky-linux/tpm2-abrmd/2.4.1-r0/image/etc/init.d from terminal it creates the folder correctly where if should have created from inside the recipe also when run by bitbake command. I can see this command executed if I run bitbake with -v option.

Original code for recipe is here : https://gitlab.com/akuster/meta-security/-/blob/master-next/meta-tpm/recipes-tpm2/tpm2-abrmd/tpm2-abrmd_3.0.0.bb#L42

installing tpm2-tools using meta-tpm2 layer in yocto.

Upvotes: 1

Views: 467

Answers (2)

Musa
Musa

Reputation: 524

As @deribaucourt said, you should not use legacy /etc/init.d scripts together with systemd in your DISTRO_FEATURES. however if you need it, you can add this config to your recipe file to prevents removing init.d directory:

RMINITDIR_class-target_remove = " rm_sysvinit_initddir"

Upvotes: 0

deribaucourt
deribaucourt

Reputation: 663

Tthe folder is indeed created. However, the recipe also inherits the systemd class. This class will delete /etc/init.d to prevent duplicating systemV and systemd units when DISTRO_FEATURES contains systemd. See rm_sysvinit_initddir in systemd.bbclass:

python rm_sysvinit_initddir (){
    import shutil
    sysv_initddir = oe.path.join(d.getVar("D"), (d.getVar('INIT_D_DIR') or "/etc/init.d"))

    if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \
        not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) and \
        os.path.exists(sysv_initddir):
        systemd_system_unitdir = oe.path.join(d.getVar("D"), d.getVar('systemd_system_unitdir'))

        # If systemd_system_unitdir contains anything, delete sysv_initddir
        if (os.path.exists(systemd_system_unitdir) and os.listdir(systemd_system_unitdir)):
            shutil.rmtree(sysv_initddir)
}

You should not use legacy /etc/init.d scripts together with systemd in your DISTRO_FEATURES. You have to choose between systemd and systemV and setup DISTRO_FEATURES in your distro.conf accordingly. If you plan on keeping the older systemV init manager, then remove systemd from DISTRO_FEATURES. Otherwise, drop /etc/init.d in favor of /lib/systemd/ units.

Note: systemd has compatibility with /etc/init.d but it is not recommended in production. It produces a warning. If you have another recipe which provides only init.d files, do not inherit systemd in that recipe.

Upvotes: 1

Related Questions