Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying patch to file in yocto recipe

I have a yocto recipe to compile a code from github. I modified some files and want to apply a patch to code fetched from github. Following is my recipe for building code.

SUMMARY = "Linux NFC stack for NCI based NXP NFC Controllers"
HOMEPAGE = "https://github.com/NXPNFCLinux/linux_libnfc-nci"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/include/linux_nfc_api.h;endline=17;md5=42fdb99b3ff2c12f594b22a774cb7308"
SECTION = "libs"

SRC_URI = "git://github.com/NXPNFCLinux/linux_libnfc-nci.git \
 
file:///home/pratyush/Desktop/custom_board/drivers/PN7150/linux_libnfc-nci/demoapp-main-patch1.patch"
SRCREV = "7cf539d3d9c0d682c8da5968fbf5615ae9993060"
PV = "2.1+git${SRCPV}"
EXTRA_OECONF =" --enable-pn7150"

S = "${WORKDIR}/git"

inherit autotools
FILES_${PN} += "${libdir}/libnfc_nci_linux-1.so"
FILES_SOLIBSDEV = "${libdir}/libnfc_nci_linux.so"

Following my patch to applied

--- /home/root/PN7150/linux_libnfc-nci/Makefile.am
+++ Makefile.am
@@ -1,7 +1,7 @@
lib_LTLIBRARIES = libnfc_nci_linux.la

-sbin_PROGRAMS = nfcDemoApp 
-nfcDemoApp_DEPENDENCIES = libnfc_nci_linux.la
+sbin_PROGRAMS = readNfc 
+readNfc_DEPENDENCIES = libnfc_nci_linux.la

LDFLAGS = -Bstatic 

@@ -9,13 +9,13 @@
LDFLAGS += -L$(openssldir)/lib -lcrypto -lssl
endif

-nfcDemoApp_FLAGS = -I$(srcdir)/demoapp -I$(srcdir)/src/include 
+readNfc_FLAGS = -I$(srcdir)/demoapp -I$(srcdir)/src/include 

AM_CPPFLAGS = \
-I$(srcdir)/src/include \
$(INCLUDE_PARAMS) \
$(libnfc_nci_linux_la_FLAGS) \
-   $(nfcDemoApp_FLAGS)
+   $(readNfc_FLAGS)

if LLCP1_3
AM_CPPFLAGS += \
@@ -177,7 +177,7 @@
src/service/linux_nfc_api.c \
src/service/linux_nfc_factory_api.c

-nfcDemoApp_SOURCES := \
+readNfc_SOURCES := \
    demoapp/main.c \
    demoapp/tools.c

@@ -231,6 +231,6 @@
libnfc_nci_linux_la_LDFLAGS +=-DPN551C2=3
libnfc_nci_linux_la_LDFLAGS += -shared -pthread -ldl -lrt -fPIC -release 1 -versionnfo 0:0:0

-nfcDemoApp_LDFLAGS = -pthread -ldl -lrt -lnfc_nci_linux
+readNfc_LDFLAGS = -pthread -ldl -lrt -lnfc_nci_linux

Thus I want to apply a patch from local to github fetched code. But whenever I try to bitbake apply patch I always get the following error:

can't find file to patch at input line 3

like image 999
prattom Avatar asked Sep 04 '17 08:09

prattom


People also ask

How do I add a patch to .BB file?

Two ways to apply the patch: Put it into your test-layer, add a line on your . bb file: SRC_URI += " file://example.patch " Put it in another layer, but it's only needed if it isn't your layer (meta-oe, meta-fsl, meta-qt...)


1 Answers

The problem is how you created your patch. The easiest way (if you're used to git) is to use git. Otherwise, diffing two complete source trees is a good and easy way.

One way to solve your issue would be to add ;striplevel=0 to the SRC_URI line. (A strip level of 1 is assumed by bitbake / OE).

Another way would be to modify your patch to start with:

--- a/Makefile.am
+++ b/Makefile.am

That should solve your problem.

like image 125
Anders Avatar answered Sep 27 '22 23:09

Anders