0

I am trying to add few checks in watchdog.c file in below package, but getting patch failure error as below, manual patch works fine without any issue, also patch is created from the file of this pkg only so there is no issue with version mismatch or older version.

https://sourceforge.net/projects/watchdog/files/watchdog/5.13/

ERROR: Command Error: exit status: 1  Output:
Applying patch watchdog.patch
patching file src/watchdog.c
Hunk #2 succeeded at 948 with fuzz 1.
Hunk #3 FAILED at 1057.
1 out of 3 hunks FAILED -- rejects in file src/watchdog.c
Patch watchdog.patch does not apply (enforce with -f)
ERROR: Function failed: patch_do_patch

Tried to search the answers, but

Bitbake recipe not applying patch as expected

Why does this patch applied with a fuzz of 1, and fail with fuzz of 0?

Hunk #1 FAILED at 1. What's that mean?

Above posts mention about pkg or improper patch issue, which doesnt look to be for my pkg, requesting for help on this.

diff --git a/src/watchdog.c b/src/watchdog.c
index 8a09632..bb4a189 100644
--- a/src/watchdog.c
+++ b/src/watchdog.c
@@ -570,6 +570,7 @@
     struct stat s;
     struct icmp_filter filt;
     filt.data = ~(1<<ICMP_ECHOREPLY);
+    int check = FALSE;

 #if USE_SYSLOG
     char *opts = "d:i:n:Ffsvbql:p:t:c:r:m:a:";
@@ -947,6 +948,11 @@
        (void) fclose(fp);
     }

+    check = check_product();
+    if(check == TRUE)
+    {
+       setup_files();
+    }
     /* set signal term to set our run flag to 0 so that */
     /* we make sure watchdog device is closed when receiving SIGTERM */
     signal(SIGTERM, sigterm_handler);
@@ -1051,6 +1057,11 @@
            do_check2(check_bin(act->name, timeout, 1), act->name, rbinary, NULL);
 #endif

+       if(check == TRUE)
+       {
+               do_check(test_files(), repair_bin, NULL);
+       }
+
        /* finally sleep some seconds */
        usleep(tint * 500000); /* this should make watchdog sleep tint seconds alltogther */
        /* sleep(tint); */

.bbappend file

# changes for patching the disk IO check
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
FILESEXTRAPATHS_append := "${THISDIR}/files"
SRC_URI += " \
           file://watchdog.patch \
           "

Above "SRC_URI" & "SRC_URI_machineoverride" tried one-by-one and did not work

SRC_URI_machineoverride += "file://watchdog.patch"
ssg
  • 247
  • 2
  • 15
  • what is the working directory of the command applying the patch? Does it use "patch < watchdog.patch" or "patch -p1 < watchdog.patch"? – A.K. Jul 02 '20 at 10:24
  • using "bitbake " that is watchdog here for building, so as per standard patching apply in yocto it should work – ssg Jul 02 '20 at 10:25
  • @PraveenMuthusamy yes, its resolved fixed patch error with manual patching in the build script. Original patch file & my generated patch file had one blank line issue so I have regenerated patch and applied & got worked – ssg Jul 12 '20 at 07:41

2 Answers2

0

The problem may be that you have file://watchdog.patch twice in your SRC_URI, and bitbake attempts to apply it twice. Thus the second fails.

Try removing the SRC_URI_machineoverride line.

user803422
  • 2,636
  • 2
  • 18
  • 36
  • Sorry, I forgot to put the comment, but I have tried this, I have tried both the FLAGs(one at a time) but did not work – ssg Jul 02 '20 at 10:40
0

your current patch file is mismatching with the source found in https://sourceforge.net/projects/watchdog/files/watchdog/5.13/

I have added changes manually to file from https://sourceforge.net/projects/watchdog/files/watchdog/5.13/ and patch is as below,

--- a/src/watchdog.c    2020-07-02 13:57:45.771971643 +0200
+++ b/src/watchdog.c    2020-07-02 13:57:55.979985941 +0200
@@ -567,6 +567,7 @@
     pid_t child_pid;
     int oom_adjusted = 0;
     struct stat s;
+    int check = FALSE

 #if USE_SYSLOG
     char *opts = "d:i:n:Ffsvbql:p:t:c:r:m:a:";
@@ -1053,6 +1054,10 @@
            do_check2(check_bin(act->name, timeout, 1), act->name, rbinary, NULL);
 #endif

+       if(check == TRUE)
+       {
+               do_check(test_files(), repair_bin, NULL);
+       }
        /* finally sleep some seconds */
        usleep(tint * 500000); /* this should make watchdog sleep tint seconds alltogther */
        /* sleep(tint); */