Yocto:在图像配方中创建符号链接 [英] Yocto: create a symlink in an image recipe
问题描述
我有一个自定义的 Yocto 'image' 配方,它使用 IMAGE_INSTALL += "... "
来构造图像,其中也包含 Python 3.5.不幸的是,没有创建常用的 /usr/bin/pdb
符号链接,我的用户希望能够从命令行运行 pdb
.所以我想在图像中为此制作一个符号链接.如果它在目标上运行,它将是以下命令的结果:
I have a custom Yocto 'image' recipe, that uses IMAGE_INSTALL += "... "
to construct the image, which also contains Python 3.5. Unfortunately, the often-used /usr/bin/pdb
symlink is not created, and my users expect to be able to run pdb
from the command line. So I want to make a single symlink for this, within the image. If it were run on the target, it would be the result of this command:
ln -s/usr/lib/python3.5/pdb.py/usr/bin/pdb
我知道我可以使用这种构造在图像配方中创建自定义任务:
I understand I can create a custom task in the image recipe with this sort of construct:
addtask create_pdb_symlink before do_image
do_create_pdb_symlink () {
ln -s /usr/lib/python3.5/pdb.py ${D}/usr/bin/pdb
}
然而,这不起作用,因为我猜测使用 ${D}
,而且我认为文件系统在那个时候没有上演.它生成此错误:
However this doesn't work because I'm guessing at using ${D}
, and I don't think the filesystem is staged at that point. It generates this error:
DEBUG: Executing shell function do_create_pdb_symlink
ln: failed to create symbolic link
'/home/user/project/build/tmp/work/custom-linux/my-image/1.0-r0/image/usr/bin/pdb': No such file or directory
WARNING: exit code 1 from a shell command.
检查文件系统确认 /home/user/project/build/tmp/work/custom-linux/
存在,但 /home/user/project/build/tmp/work/custom-linux/my-image
没有.
Inspecting the filesystem confirms that /home/user/project/build/tmp/work/custom-linux/
exists, but /home/user/project/build/tmp/work/custom-linux/my-image
does not.
在那个 custom-linux
目录中有一些目录,其中之一被称为 rootfs
并且看起来非常有用,但我不确定我的任务是否应该是在 my-image
目录下翻找.
There are some directories in that custom-linux
directory, one of which is called rootfs
and looks suspiciously useful, but I'm not sure if my task should be poking around below the my-image
directory.
所以我的问题是:
- 这是正确的方法吗?
- 还是我应该创建一个全新的配方来构建这个单一的符号链接?
- 还是我应该创建一个
python3-core.bbappend
来完成这项任务? - 或者有什么原因不是由 python 配方本身创建的?
推荐答案
由于此符号链接显然与 python3 相关,因此我建议您使用该配方的 bbappend 创建它.配方名称是 python3_(version).bb,因此要捕获所有版本,将 bbappend 命名为 python3_%.bbappend.
Since this symlink is clearly related to python3 I would recommend that you create it using a bbappend for that recipe. The recipe name is python3_(version).bb, so to catch all versions name the bbappend python3_%.bbappend.
这应该有效:
# Create symlink at the end of do_install
do_install_append() {
ln -sf /usr/lib/python3.5/pdb.py ${D}/usr/bin/pdb
}
# Include the symlink in the python3-debugger package
FILES_${PN}-debugger += "/usr/bin/pdb"
您也可以创建符号链接作为创建整个 rootfs 的阶段,但在这种情况下我不推荐它.但是,如果您在填充整个 rootfs 时需要做一些事情,请查看使用 ROOTFS_POSTPROCESS_COMMAND.例如.把它放在你的图像配方中:
You can also create symlink as the stage where the whole rootfs is created, but in this case I would not recommend it. But if you have something so need to do when the whole rootfs is populated look into using ROOTFS_POSTPROCESS_COMMAND. E.g. put this in you image recipe:
my_image_postprocess_function() {
ln -sf /usr/lib/python3.5/pdb.py ${IMAGE_ROOTFS}/usr/bin/pdb
}
ROOTFS_POSTPROCESS_COMMAND += "my_image_postprocess_function; "
这篇关于Yocto:在图像配方中创建符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!