Yocto:cp 无法统计文件:没有这样的文件或目录

Yocto: cp can't stat file: no such file or directory

我正在尝试在我的目标 rootfs 中复制两个文件夹(包含一些脚本)。我在其中创建了一个自定义层和一个自定义配方。 我的目录结构是这样的:

../sources/meta-company/recipes-bla_2.06/
└── bla
    ├── bla
    │   ├── dir1
    │   │   ├── dir
    │   │   │   └── files.sh
    │   └── dir2
    │       ├── dir
    │       │   ├── files.sql
    │       ├── test.sh
    └── bla_2.06.bb

我的.bb文件如下:

DESCRIPTION = " bla "

LICENSE = "CLOSED"

SRC_URI = "file://dir1/ \
           file://dir2/ "

do_install() {
    install -d ${D}/root/dir1
    install -d ${D}/root/dir2
    cp -r --no-dereference --preserve=mode,links -v ${S}/dir1/ ${D}/root/dir1
    cp -r --no-dereference --preserve=mode,links -v ${S}/dir2/ ${D}/root/dir2/
}

FILE_$PN = "/root/"

我得到的错误:

> Log data follows: | DEBUG: Executing shell function do_install | cp:
> cannot stat
> '/home/amol/test/fsl-arm-yocto-bsp/build-cl-som-imx7-fsl-imx-x11/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/bla/1.0-r0/bla-1.0/dir1':
> No such file or directory | WARNING: exit code 1 from a shell command.
> | ERROR: Function failed: do_install (log file is located at
> /home/amol/test/fsl-arm-yocto-bsp/build-cl-som-imx7-fsl-imx-x11/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/seriald/1.0-r0/temp/log.do_install.49808)
> NOTE: recipe bla-1.0-r0: task do_install: Failed NOTE: Tasks Summary:
> Attempted 334 tasks of which 333 didn't need to be rerun and 1 failed.

我是 yocto 的新手,我的 .bb 文件是否正确?提前致谢。

你的 do_install 部分有两个问题,

  1. ${S} 指向源目录,但 SRC_URI 将您的内容复制到 ${WORKDIR}。所以你应该在安装部分使用 ${WORKSIR}
  2. 您正试图在 ${D}/root/dir1 中复制 ${S}/dir1/,这意味着您的最终结构是 /root/dir1/dir1/。你可能不想要这个。

所以修改后的版本看起来像,

do_install() {
    install -d ${D}/root/dir1
    install -d ${D}/root/dir2
    cp -r --no-dereference --preserve=mode,links -v ${WORKDIR}/dir1/* ${D}/root/dir1/
    cp -r --no-dereference --preserve=mode,links -v ${WORKDIR}/dir2/* ${D}/root/dir2/
}