GreenTea
GreenTea

Reputation: 1057

How to assign patch to specified git source?

In my foo_git.bb:

SRC_URI = "git://github.com/foo/foo.git;branch=main;protocol=https;name=${BPN};destsuffix=git  \
    git://github.com/foo2/foo2;branch=main;protocol=https;name=${FOO2};destsuffix=${FOO2} \
    file://0001-Modify-A_value.patch\
"

I want my patch to apply to foo2 but it always applied to foo. ( patch failed )

Upvotes: 0

Views: 899

Answers (2)

Falital
Falital

Reputation: 327

From the OE manual

Patch files will be copied to ${S}/patches and then applied to source from within the source directory, ${S}.

so for your use case to work your patch filenames should include their base repo name.

For example let’s say 0001-Modify-A_value.patch is as follows:

diff --git a/my.txt b/my.txt
index fa5cb9a..59369cc 100644
--- a/my.txt
+++ b/my.txt
@@ -1 +1 @@
-I am foo who lives in bar
+I am bar who lives in foo

To make it apply to foo2 you must modify it as follows:

--- foo2/my.txt
+++ foo2/my.txt
@@ -1 +1 @@
-I am foo who lives in bar
+I am bar who lives in foo

Bitbake uses Quilt for patching so for errors and so on look at its manual. Another handy tool by bitbake to help you further is the devtool which is designed to handle tasks like updating a recipe or patching it.

Upvotes: 0

GreenTea
GreenTea

Reputation: 1057

I found patchdir appended after the patch can work.

ex:

file://0001-Modify-A_value.patch;patchdir=${WORKDIR}/${FOO2_path}

Upvotes: 1

Related Questions