如何在yocto中打补丁 [英] How patching works in yocto

查看:1137
本文介绍了如何在yocto中打补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用BBB来了解yocto项目.我不确定修补的工作方式.这是我的项目目录

I am using BBB to understand the yocto-project. I am not sure how patching works. This is my project directory

├── meta-testlayer
├── poky

元测试层包含一个helloworld示例

meta-test layer contains a helloworld example

├── 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的内容

helloworld.c and newhelloworld.c differ by only one printf statement. Here is the content of 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

newhelloworld.c #include

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 > helloworld.patch命令创建的补丁.

Here is the patch I created using diff helloworld.c newhelloworld.c > helloworld.patch command.

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文件的内容

This is the content of helloworld_0.1.bb file

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.

推荐答案

首先,创建补丁:

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

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

or using Git (replace x by the number of commits you want to extract a patch):

git format-patch -x

两种应用补丁的方法:

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

  • Put it into your test-layer, add a line on your .bb file: SRC_URI += " file://example.patch "

将其放置在另一层中,但仅当它不是您的层时才需要(meta-oe,meta-fsl,meta-qt ...)

Put it in another layer, but it's only needed if it isn't your layer (meta-oe, meta-fsl, meta-qt...)

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

For this case, use in your .bbappend file:

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

这篇关于如何在yocto中打补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆