1

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
}

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.

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.

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.

So my questions are:

  • is this the right approach?
  • or should I create a brand new recipe just to construct this single symlink?
  • or should I create a python3-core.bbappend to do this task?
  • or is there a reason why this isn't being created by the python recipe itself?
4

2 回答 2

2

由于这个符号链接显然与 python3 相关,我建议您使用 bbappend 为该配方创建它。配方名称是 python3_(version).bb,因此要捕获所有版本,请将 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。例如,把它放在你的图像配方中:

my_image_postprocess_function() {
    ln -sf /usr/lib/python3.5/pdb.py ${IMAGE_ROOTFS}/usr/bin/pdb
}

ROOTFS_POSTPROCESS_COMMAND += "my_image_postprocess_function; "
于 2018-03-28T04:40:27.350 回答
0

Erik Botö 的回答可能是做到这一点的最佳方式,但是我想记录下我自己的发现,以防它帮助其他人尝试做类似的事情(在图像配方中创建符号链接,尽管可能不是这个特定的符号链接)。

在我的图像配方(我recipes-core/images/myimage.bb在自定义层中调用)中,我添加了以下几行:

addtask create_pdb_symlink after do_rootfs before do_image
do_create_pdb_symlink () {
    ln -s /usr/lib/python3.5/pdb.py ${IMAGE_ROOTFS}/usr/bin/pdb
}

我在这里必须了解的两个关键事项是使用IMAGE_ROOTFS(我通过搜索 的输出发现bitbake -e)和任务的顺序:符号链接创建必须在do_rootfs否则没有任何内容之后发生${IMAGE_ROOTFS},但显然需要在任何图像之前发生被创建,被包括在内。

但是在这种情况下,我同意在 python3 配方上添加 bbappend 更合适。

于 2018-04-02T22:05:21.440 回答