Create and apply patch file

Sorry for all these dumb questions.

buildrpm, when applying a patch, always asks which file to patch.

This is what I did:

tar xzvf source.tar.gz
cd sourcedir
cp addons/vtk/vtkmesh.cc addons/vtk/vtkmesh.friends
vi addons/vtk/vtkmesh.cc
diff -Naur addons/vtk/vtkmesh.cc addons/vtk/vtkmesh.cc.friends > ~/rpmbuild/SOURCES/vtkmeshGetTupleValue.patch

In the SPEC file:

...
Patch0:         vtkmeshGetTupleValue.patch
...
%prep
%autosetup -n %{PROJECT}-%{commit}
...

Then when I invoke rpmbuild, I get

...
+ /usr/bin/cat /root/rpmbuild/SOURCES/vtkmeshGetTupleValue.patch
+ /usr/bin/patch -s --fuzz=0 --no-backup-if-mismatch
The text leading up to this was:
--------------------------
|--- addons/vtk/vtkmesh.cc    2019-09-13 17:21:42.394198089 +0000
|+++ addons/vtk/vtkmesh.cc.friends    2019-09-13 17:23:13.352018728 +0000
--------------------------
File to patch: 

If I put the file name, I get

Reversed (or previously applied) patch detected!  Assume -R? [n] 

Where is my fault?

You’ve got your diff args backwards, the modified file should be the second argument.

1 Like

Uh :relaxed: you are right.

1 Like