【问题标题】:How patching works in yocto修补程序在 yocto 中的工作原理
【发布时间】:2018-01-16 22:57:56
【问题描述】:

我正在使用 BBB 来了解 yocto 项目。我不确定补丁是如何工作的。这是我的项目目录

├── meta-testlayer
├── poky

元测试层包含一个“helloworld”示例

├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-hello
    └── helloworld
        ├── helloworld-0.1
        │   ├── helloworld.c
        │   ├── helloworld.patch
        │   └── newhelloworld.c
        └── helloworld_0.1.bb

“helloworld.c”和“newhelloworld.c”只有一个printf() 语句不同。以下是“helloworld.c”的内容:

#include <stdio.h>

int main(int argc, char **argv)
{

    printf("Hi, this is my first custom recipe. Have a good day\n");
    return 0;
}

“newhelloworld.c”的内容:

#include <stdio.h>

int main(int argc, char **argv)
{

    printf("Let see if patch works\n");
    printf("Hi, this patch is from the test-layer\n");
    return 0;
}

这是我使用diff helloworld.c newhelloworld.c &gt; helloworld.patch 命令创建的补丁。

6c6,7
<     printf("Hi, this is my first custom recipe. Have a good day\n");
---
>     printf("Let see if patch works\n");
>     printf("Hi, this patch is from the test-layer\n");

这是“helloworld_0.1.bb”文件的内容

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

#here we specify the source we want to build
SRC_URI = "file://helloworld.c"
SRC_URI += "file://helloworld.patch"

#here we specify the source directory, where we can do all the building and expect sources to be placed
S = "${WORKDIR}"

#bitbake task
do_compile() {
         ${CC} ${LDFLAGS} helloworld.c -o helloworld
}

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

这是我运行bitbake -c patch helloworld时的错误信息:

NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: helloworld-0.1-r0 do_patch: Command Error: 'quilt --quiltrc /home/guest/yocto_practice/poky/build-beaglebone/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/helloworld/0.1-r0/recipe-sysroot-native/etc/quiltrc push' exited with 0  Output:
Applying patch helloworld.patch
patch: **** Only garbage was found in the patch input.
Patch helloworld.patch does not apply (enforce with -f)
ERROR: helloworld-0.1-r0 do_patch: Function failed: patch_do_patch
ERROR: Logfile of failure stored in: /home/guest/yocto_practice/poky/build-beaglebone/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/helloworld/0.1-r0/temp/log.do_patch.22267
ERROR: Task (/home/guest/yocto_practice/meta-testlayer/recipes-hello/helloworld/helloworld_0.1.bb:do_patch) failed with exit code '1'
NOTE: Tasks Summary: Attempted 11 tasks of which 8 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/guest/yocto_practice/meta-testlayer/recipes-hello/helloworld/helloworld_0.1.bb:do_patch
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.

【问题讨论】:

  • 这里没有足够的信息来说明您无法应用补丁的原因——但它可能与元测试中的其他补丁冲突?如果您将补丁放在 meta-testlayer 中,那么您根本不需要 bbappend:您只需修改 helloworld_0.1.bb。
  • 要我把日志截图贴在这里吗?还有如何从同一层应用补丁?

标签: yocto bitbake


【解决方案1】:

首先,创建补丁:

diff -u helloworld.c newhelloworld.c > helloworld.patch

或使用 Git(将 x 替换为您要提取补丁的提交数):

git format-patch -x

两种应用补丁的方法:

  • 将其放入您的测试层,在您的 .bb 文件中添加一行: SRC_URI += " file://example.patch "

  • 把它放在另一个层,但只有当它不是你的层时才需要它(meta-oe、meta-fsl、meta-qt...)

对于这种情况,请在您的 .bbappend 文件中使用:

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += " file://helloworld.patch "

【讨论】:

  • 我遵循了这两种方法,但可能是我在补丁文件中做错了什么。在调试消息中,我可以看到 only garbage was found inside the patch input
  • 你的补丁坏了,你是怎么弄的?
  • 我在问题中添加了我的 example.patch 文件内容。如果我这样做 bitabke helloworldbitbake -c patch helloworld 我会出错。还有一件事我必须先应用补丁然后烘烤食谱?或者我可以直接烘焙 helloworld 食谱吗?
  • bitbake helloworld 运行依赖于“补丁”任务的默认“构建”任务:换句话说,补丁会在需要时自动进行
  • 必须从父目录之一调用 diff 命令,这次我使用了diff -u。有效。谢谢
猜你喜欢
  • 2020-03-16
  • 2019-03-12
  • 1970-01-01
  • 1970-01-01
  • 2023-04-09
  • 2013-09-24
  • 2021-03-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多