如何通过添加新层来安装tar.gz包到Yocto ?



我是新手,所以可能有一些错误和误解,如果你能帮助我,我很感激。

所以,我想添加一个新的包(tar文件)到我的自定义映像。

我已经按照手册上的步骤和一些网上的说明做了。当运行:"bitbake mylayer"时,层构建得很好,但我在构建图像时遇到了这个错误,这是日志文件:

DEBUG: Executing python function rootfs_deb_bad_recommendations
DEBUG: Python function rootfs_deb_bad_recommendations finished
DEBUG: Executing python function extend_recipe_sysroot
NOTE: Installed into sysroot: []
NOTE: Skipping as already exists in sysroot: ['depmodwrapper-cross', 'apt-native', 'dpkg-native', 'pseudo-native', 'update-rc.d-native', 'prelink-native', 'makedevs-native', 'ldconfig-native', 'opkg-util$
DEBUG: Python function extend_recipe_sysroot finished
DEBUG: Executing python function do_rootfs
NOTE: ###### Generate rootfs #######
NOTE: Installing the following packages: apt busybox copy-uefiimg-to-sda coreutils dpkg e2fsprogs-resize2fs libfontconfig1 libfreetype6 libglib-2.0-0 gptfdisk libjemalloc2 kernel-module-axi-dma-sensor ku$
ERROR: Unable to install packages. 
Reading package lists...
Building dependency tree...
Reading state information...
Package mypackage is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'mylayer' has no installation candidate
DEBUG: Python function do_rootfs finished
ERROR: Function failed: do_rootfs

这里是mylayer。bb:

SUMMARY = ""
LICENSE = "CLOSE"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://mypackage.tar"

另外,我已经在conf/local.conf中包含了这个包:

IMAGE_INSTALL_append += " mylayer"

所以除了想办法解决这个问题,我还有一些问题:

  1. 我读过一些。bb的例子,他们提到了LIC_FILES_CHKSUM。myppackage .tar.gz是一个为设备安装平台的包,我不太了解源代码,所以不知道是否需要包含license?或者怎么知道这个包需要许可证才能安装?

  2. 在我在网上找到的一些答案中,有一个说我需要包括PACKAGE_CLASSES ?= "package_deb"(他们想要安装。deb文件),所以可能在我的情况下,我需要PACKAGE_CLASSES ?= "package.tar"对吗?我试着改变变量,但仍然不成功。

  3. myppackage .tar包含一些deb文件。如果我不能安装mypackage.tar,我可以安装这些.deb文件吗?我能把它们都放到我的图层。bb里吗?

提前谢谢你,我已经尽我所能地研究了很多文件,但是我很困惑,有大量的信息需要消化。

首先,在回答你的问题之前

让我给你提一些最佳实践建议:

将配方重命名为与压缩包相关的重要名称。

将配方命名为mylayer会使Yocto用户感到困惑,因为也有术语layer

关于你的食谱:

不需要FILESEXTRAPATHS,因为配方路径会自动添加到Yocto路径中。

FILESEXTRAPATHS.bbappend文件所必需的。

您需要覆盖do_install任务函数,默认情况下它不做任何事情。

do_install是确保您的源代码包含在最终图像中的第一个重要任务。

除此之外,当将压缩的源文件指定为SRC_URI时,yocto会自动解压缩。

这里已经提到了。

那么,你的食谱应该是这样的:

SUMMARY = ""
LICENSE = "CLOSED"
# Prevent Yocto from decompressing the file
SRC_URI = "file://mypackage.tar;unpack=0"
do_install(){
# Create the opt folder into the final image, ${D} is ${WORKDIR}/image
install -d ${D}/opt
# Copy the compressed file there; You can change permissions as you want
install -m 0755 ${WORKDIR}/mypackage.tar ${D}/opt
}
# Very important to specify what you installed in (do_install)
FILES_${PN} = "/opt/*"

现在,当您运行IMAGE_INSTALL_append += " mylayer"时,您的文件将被安装。

关于你的问题:

  1. 您提到您的压缩文件包含.deb文件,我假设不需要许可证校验和。此外,我理解您可能希望指向SRC_URI[md5sum]或完整包的其他校验和。对于本地文件也不需要,它用于检查在线源的完整性。

  2. 这里提到的
  3. PACKAGE_CLASSES是系统用来知道数据应该打包成什么类型的。这里的the data指的是你用do_install安装的数据。根据您的PACKAGE_CLASSES变量,例如,将该数据打包到deb文件中。它与所有其他食谱包一起用于构建最终的rootfs。

  4. 是的,如果您正在将tar文件安装到映像中,然后解包以安装所有deb文件,例如,使用dpkg。您可以使用bin_package类来做到这一点,现在必须为此更改配方:

  • 解压tar文件,提供deb文件到本地files文件夹

  • 将所有deb文件添加到SRC_URI

  • 继承bin_package

  • 指定打包的文件。

你的食谱应该是这样的:

SUMMARY = ""
LICENSE = "CLOSED"
SRC_URI = "file://deb_file1.deb 
file://deb_file2.deb"
# No need to `do_install` , it is invoked by the (bin_package) class
FILES_${PN} = ""

重要:

关于FILES_${PN},您需要将所有deb安装到image文件夹

示例,如果你的deb文件安装了这个:

/usr/bin/hello
/etc/hello.cfg

指定:

FILES_${PN} = "/usr/bin/*"
FILES_${PN} += "/etc/*"

使用*,这样如果其他deb文件安装到与其他文件相同的文件夹中,它将包含所有文件。