0

A source code tree contains a modified dnsmasq-2.80test4 source (and git files).

Now I'd like to apply the newest 2.86 dnsmasq source code to that modified 2.80test4 using diff and patch, while working in the users home folder.

So I start copying .../dnsmasq-2.80test4 to the users home dir, and create the diff file using:

~$ diff -urN ./dnsmasq-2.80test4 ./dnsmasq-2.86 > dnsmasq-2.86.diff

Then I'm trying to patch the old ~/dnsmasq-2.80test4 folder using:

~$ cd ./dnsmasq-2.80test4
~$ patch --dry-run -i ../dnsmasq-2.86.diff

which runs ok for CHANGELOG, FAQ, Makefile and Version. First file Android.mk in subdir bld fails, which is not a big deal. The real deal breaker is the second file in the same subdir:

can't find file to patch at input line 466
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff -ur ./dnsmasq-2.80test4/bld/get-version ./dnsmasq-2.86/bld/get-version
|--- ./dnsmasq-2.80test4/bld/get-version    2022-07-03 17:32:08.541879257 +0200
|+++ ./dnsmasq-2.86/bld/get-version 2021-09-08 22:21:22.000000000 +0200
--------------------------

Workaround

When changing the working directory to one level up and renaming the newer /dnsmasq-2.86 source directory to a different name (or just removing it), the patch seems to be correctly applied to the old /dnsmasq-2.80test4 dir using:

~$ patch --dry-run --verbose -p0 -i dnsmasq-2.86.diff

Question

How to modify the diff and/or patch commands, allowing me to patch from within the directory that needs to changed (cd ./parent/dnsmasq-2.80test4) as working directory, instead of working from cd ./parent dir?

2
  • This sounds like a great example of where working with git would make things easier to manage (have your custom changes in branch off the 2.80test4 tag, rebase them onto 2.86, resolve conflicts, etc). Commented Jul 3, 2022 at 20:40
  • 1
    Even without git, you'd be better off generating a diff of your custom modified dnsmasq 2.80 versus official upstream 2.80, then try to apply that patch to 2.86. There'll probably still be conflicts to resolve but your custom patch is likely to be a lot small than the diff between 2.80 and 2.86, so merging will be a lot less work. Commented Jul 4, 2022 at 5:28

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.