如何使用 Yocto 修改 rootfs 配置文件? [英] How do I modify a rootfs configuration file with Yocto?

查看:52
本文介绍了如何使用 Yocto 修改 rootfs 配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Thud (2.6),我想清除/etc/default/dropbear 的内容.ROOTFS_POSTPROCESS_COMMAND 看起来很有希望,但以下未能创建空文件.没有错误.

I'm using Thud (2.6) and I'd like to clear the contents of /etc/default/dropbear. ROOTFS_POSTPROCESS_COMMAND seemed promising but the following failed to create the empty file. There were no errors.

配方完成的其他工作成功.

Other work done by the recipe succeeds.

SRC_URI += "file://authorized_keys"
SRC_URI += "file://dropbear_rsa_host_key"
# Configuration file to be installed in /etc/default.
# SRC_URI += "file://dropbear"

S = "${WORKDIR}"

do_install() {

install -d ${D}/etc/dropbear
install -m 0600 ${S}/authorized_keys ${D}/etc/dropbear
install -m 0600 ${S}/dropbear_rsa_host_key ${D}/etc/dropbear

}

clear_dropbear_default_configuration() {

rm ${D}/etc/default/dropbear
touch ${D}/etc/default/dropbear
echo "Hello" > hello.txt

}

FILES_${PN} += "/etc/dropbear"

FILES_${PN} += "/etc/dropbear/authorized_keys"

FILES_${PN} += "/etc/dropbear/dropbear_rsa_host_key"

ROOTFS_POSTPROCESS_COMMAND += "clear_dropbear_default_configuration;"

# FILES_${PN} += "/etc/default/dropbear"

推荐答案

我相信 ROOTFS_POSTPROCESS_COMMAND 是您想要的,但您不能从这样的包配方中调用它.在我们的应用程序中,我们在与 .bb 图像创建配方相同的目录中创建了一个具有一些常用功能的新 .inc 文件,并将其包含在构建目标图像的配方中.这是我们放置这些指令和函数的地方(我有 4 个来制作符号链接并重置 root 密码).挑战在于后处理无法再次调用您的配方,而且我不确定尝试预先声明这样的函数以供以后调用会如何工作.请注意,从外观上看,语法完全正确,只是在需要时运行的位置不正确.

I believe ROOTFS_POSTPROCESS_COMMAND is what you want, but you can't call it from a package recipe like that. In our application, we created a new .inc file with some common functions in the same directory as our .bb image creation recipes and included it in the recipes that build our target images. This is where we put these directives and functions (I have 4 to make symlinks and reset the root password). The challenge is that the postprocess can't call your recipe again, and I'm not sure how it might work to try to predeclare a function like this to be called later. Note the syntax is exactly right by the looks of it, just not in the right location to run when needed.

image-base.inc

image-base.inc

ROOTFS_POSTPROCESS_COMMAND += "clear_dropbear_default_configuration;"

clear_dropbear_default_configuration() {
    rm ${D}/etc/default/dropbear
    touch ${D}/etc/default/dropbear
    echo "Hello" > hello.txt
}

图片名称.bb

require image-base.inc

如果您愿意,您也可以直接将其添加到 .bb 中,这是您的 bitbake.我喜欢 .inc 文件,因为它们可以更轻松地在类似条目之间共享.请注意,此示例忽略了其他内容,但您可以在其所属的位置自由设置.

You could also just add this to the .bb which is your bitbake directly if you wanted. I like the .inc files though as they make it easier to share among similar entries. Note this example ignores the other content, but you can freeform where it belongs.

如果您不想更改现有目标,您可以创建自己的目标,然后在新图像配方中要求 image.bb.

If you don't want to change the existing target, you can create your own and then require the image.bb in your new image recipe.

这篇关于如何使用 Yocto 修改 rootfs 配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆