【问题标题】:Yocto recipe : how to install in specific folderYocto 配方:如何安装在特定文件夹中
【发布时间】:2015-09-26 09:47:30
【问题描述】:

我为我的程序创建了一个 Yocto 食谱。 从配方构建图像的默认文件夹是什么? 在构建映像时,我想将我的文件移动到另一个文件夹,例如“/opt/xyz”。

我应该简单地做“mv”还是有其他选择?

【问题讨论】:

  • 你能解释更多你试图完成的事情吗?要将文件移动到最终 yocto 图像内部还是外部?
  • 您为什么不简单地让您的食谱将其文件安装在正确的位置(即/opt/xyz)?

标签: embedded-linux yocto recipe


【解决方案1】:

我猜你想把编译好的程序复制到${bindir}这样的文件夹中:

引自 Yocto 参考手册 1.1:
将路径指定为 CONFFILES 变量的一部分时,最好使用适当的路径变量。例如,${sysconfdir} 而不是 /etc 或 ${bindir} 而不是 /usr/bin。您可以在 Source Directory 的 meta/conf/bitbake.conf 文件顶部找到这些变量的列表。

您可以将文件从工作目录复制到目标文件系统中的任何目录。例如参见hello-world example(请注意,该示例取自 1.1 参考手册,但我还没有在较新的版本中找到它):

 DESCRIPTION = "Simple helloworld application"
 SECTION = "examples"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r0"

 SRC_URI = "file://helloworld.c"

 S = "${WORKDIR}"

 do_compile() {
    ${CC} helloworld.c -o helloworld
 }

 do_install() {
    install -d ${D}${bindir}
    install -m 0755 helloworld ${D}${bindir}
 }

 FILES_${PN} = "${bindir}"

在本例中,helloworld 二进制文件将被复制到图像上的 /usr/bin(也可以是 /opt,请参阅源目录了解变量定义)。 为 ${sysconfdir} ${bindir} ${datadir} ${libdir} 目录调整 FILES_${PN} 变量。

【讨论】:

    【解决方案2】:
    do_install(){
      install -d ${D}{base_prefix}/opt/xyz/          
      install -m ${WORKDIR}/yourbinary    ${D}${base_prefix}/opt/xyz/
    }
    
    FILES_${PN} = "${base_prefix}/opt/*"
    

    以上 第一行在 opt/xvz/ 中的 imagedir 中创建目录

    第二行将你的二进制文件复制到 opt/xyz/dir

    第三行用于将您的 opt/xyz/binary 复制到 yocto rootfs。

    【讨论】:

      猜你喜欢
      • 2020-02-08
      • 2022-11-17
      • 1970-01-01
      • 2015-07-12
      • 1970-01-01
      • 1970-01-01
      • 2018-09-04
      • 1970-01-01
      相关资源
      最近更新 更多