applying patch to file in yocto recipe

prattom picture prattom · Sep 4, 2017 · Viewed 7.5k times · Source

I have a yocto recipe to compile a code from github. I modified some files and want to apply 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 patch from local to github fetched code. But when ever I try to bitbake apply patch I always get the following error "can't find file to patch at input line 3"

Answer

Anders picture Anders · Sep 4, 2017

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.