[英]How should I sed files on the Yocto-generated rootfs?
I would like to find a way to run sed scripts on files within a Yocto-generated OS from a .bbappend file. 我想找到一种方法从.bbappend文件在Yocto生成的操作系统中的文件上运行sed脚本。 My OS has a read-only rootfs, which seems to stop any possibility of a post-installation script.
我的操作系统有一个只读的rootfs,它似乎阻止了安装后脚本的任何可能性。 Specifically, I need to make these changes to
/etc/default/ssh
(as run after booting the generated OS): 具体来说,我需要对
/etc/default/ssh
进行这些更改(在启动生成的操作系统后运行):
sed -i 's/var\/run/etc/' /etc/default/ssh
sed -i 's/_readonly//' /etc/default/ssh
Here's my openssh_7.1p1.bbappend
which I've created in an attempt to solve these problems: 这是我为解决这些问题而创建的
openssh_7.1p1.bbappend
:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += " \
file://ssh_host_dsa_key.pub \
file://ssh_host_rsa_key.pub \
...
"
do_install_append() {
sed -i 's/var\/run/etc/' ${D}${sysconfdir}/default/ssh
sed -i 's/_readonly//' ${D}${sysconfdir}/default/ssh
# these lines work fine
install -m 0755 ${WORKDIR}/ssh_host_dsa_key ${D}/etc/ssh
install -m 0755 ${WORKDIR}/ssh_host_dsa_key.pub ${D}/etc/ssh
...
}
FILES_${PN} += "${sysconfdir}/default/ssh"
#these lines work
FILES_${PN} += "${sysconfdir}/ssh/ssh_host_dsa_key"
FILES_${PN} += "${sysconfdir}/ssh/ssh_host_dsa_key.pub"
...
BitBake fails during the execution of do_install_append()
with this error: 执行
do_install_append()
期间BitBake失败并出现此错误:
sed: can't read ${TMPDIR}/work/x86-poky-linux/openssh/image/etc/default/ssh: No such file or directory
(where TMPDIR is my actual tmp directory) Obviously this file doesn't exist because the proper copy is created in a separate MULTIMACH_TARGET_SYS
directory (ie not x86-poky-linux
) by image.bbclass. (其中TMPDIR是我的实际tmp目录)显然这个文件不存在,因为
MULTIMACH_TARGET_SYS
在单独的MULTIMACH_TARGET_SYS
目录(即x86-poky-linux
)中创建了正确的副本。
Is this sort of thing possible to do from within a .bbappend file (or some other compartmentalized way)? 这种事情是否可以在.bbappend文件(或其他一些分区方式)中完成? I have found a way to do it within a .inc file with
ROOTFS_POSTPROCESS_COMMAND
within my core-image, but this method is leading to a poor organizational structure. 我已经找到了一种在我的核心映像中使用
ROOTFS_POSTPROCESS_COMMAND
在.inc文件中ROOTFS_POSTPROCESS_COMMAND
此操作的方法,但是这种方法导致组织结构不佳。
Maybe moving the operations to a post-installation function in your .bbappend is appropriate for your circumstance? 也许在.bbappend中将操作移动到安装后功能适合您的情况?
pkg_postinst_${PN} () {
#!/bin/sh
if [ x"$D" = "x" ]; then
sed -i 's/var\/run/etc/' /etc/default/ssh
sed -i 's/_readonly//' /etc/default/ssh
else
exit 1
fi
}
The function above will cause the sed operations to execute on first boot, rather than during the build. 上面的函数将导致sed操作在首次启动时执行,而不是在构建期间执行。
在SRC_URI变量中包含您尝试sed
的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.