安装来自Yocto配方的软件时无法创建init.d文件夹。

huangapple go评论74阅读模式
英文:

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

问题

在 Yocto 的 TPM2 配方中,以下配方未能正常工作:

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

它无法创建名为 init.d 的文件夹。如果我将文件夹名称更改为 init_d,它就能够创建该文件夹。
对我来说这似乎很奇怪,因为 init.d 在 Linux 中非常常见,而且我猜在 Yocto 中的许多配方都这样做。
如果我在终端中执行以下命令:install -d /home/builduser/build/tmp/work/armv8a-poky-linux/tpm2-abrmd/2.4.1-r0/image/etc/init.d,它会正确地创建文件夹,应该也会在通过 bitbake 命令运行时从配方内部创建。如果我使用 -v 选项运行 bitbake,我可以看到执行此命令。

有关配方的原始代码在此处:https://gitlab.com/akuster/meta-security/-/blob/master-next/meta-tpm/recipes-tpm2/tpm2-abrmd/tpm2-abrmd_3.0.0.bb#L42

在 Yocto 中使用 meta-tpm2 层安装 tpm2-tools。

英文:

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.

答案1

得分: 1

The 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 set up 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 that provides only init.d files, do not inherit systemd in that recipe.

英文:

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.

huangapple
  • 本文由 发表于 2023年5月29日 17:45:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76356263.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定