Ignoring previously applied (or reversed) patch. 1 out of 1 hunks ignored--saving rejects to Makefile.in.rej => Patch patch-Makefile.in failed to apply cleanly.
Active1 month ago
What's the best way to go about making a patch for a binary file? I want it to be simple for users to apply(a simple MikeMike
patch application would be nice). Running diff on the file just gives Binary files [..] differ
11.5k1616 gold badges6363 silver badges8383 bronze badges
6 Answers
Check out
bsdiff and bspatch (website, manpage, paper, GitHub fork).
To install this tool:
2,66922 gold badges2525 silver badges4242 bronze badges
HeinziHeinzi
127k4242 gold badges281281 silver badges421421 bronze badges
Courgette, by the Google Chrome team, looks like most efficient tool for binary patching executables.
To quote their data:
Here are the sizes for the recent 190.1 -> 190.4 update on the developer channel:
Hibernation Preserves entire state of system and speeds time to recovery. Apc power chute download. Load shedding Turn off select outlet groups in a pre-determined sequence to shed less critical equipment and conserve runtime (UPSs with switched outlet groups). Outlet group control Turn on/off, reboot or shut down select outlet groups to save dispatching technicians to remote locations (for UPSs with switched outlet groups). Sequenced shutdown and restart Configure select outlet groups to shut down and turn on in a pre-determined order (for UPSs with switched outlet groups).
Here are instructions to build it. Here is a Windows binary from 2018 courtesy of Mehrdad.
MultiplyByZer0
2,66922 gold badges2525 silver badges4242 bronze badges
Maxim KholyavkinMaxim Kholyavkin
2,70111 gold badge2828 silver badges7070 bronze badges
xdelta (website, GitHub) is another option. It seems to be more recent, but otherwise I have no idea how it compares to other tools like bsdiff.
Usage:
Installation:
Freebsd Patch Failed To Apply Cleanly
2,66922 gold badges2525 silver badges4242 bronze badges
Jared BeckJared Beck
11k44 gold badges5050 silver badges7979 bronze badges
Modern port: Very useful .NET port for bsdiff/bspatch:
My personal choice.I tested it, and it was the only of all links, I was able out of the box to compile it (with Visual Studio, e.g. 2013). (The C++ source elsewhere is a bit outdated and needs at least a bit polishing and is only 32 bit which sets real memory (diff source size) limits. This is a port of this C++ code bsdiff and even tests if the patch results are identical to original code).
Further idea: With .NET 4.5 you could even get rid of #Zip lib, which is a dependency here.
I haven't measured if it is slightly slowlier than the c++ code, but it worked fine for me, (bsdiff: 90 MB file in 1-2 min.), and time-critical for me is only the bspatch, not the bsdiff.
I am not really sure, if the whole memory of a x64 machine is used, but I assume it. The x64 capable build ('Any CPU') works at least. Tried with a 100 MB file.
-Besides: The cited Google project 'Courgette' may be the best choice if your main target are executable files. But it is work to build it (for Windows measures, at least), and for binary files it is also using pure bsdiff/bspatch, as far as I have understood the doc.
PhilmPhilm
For small, simple patches, it's easiest just to tell diff to treat the files as text with the -a (or --text) option. As far as I understand, more complicated binary diffs are only useful for reducing the size of patches.
If the files are the same size and the patch just modifies a few bytes, you can use xxd, which is commonly installed with the OS. The following converts each file to a hex representation with one byte per line, then diffs the files to create a compact patch, then applies the patch.
cjfpcjfp
Assuming you know the structure of the file you could use a c / c++ program to modify it byte by byte:
Just read in the old file, and write out a new one modified as you like.
Don't forget to include a file format version number in the file so you know how to read any given version of the file format.
Jamie ClarkeJamie Clarke
Not the answer you're looking for? Browse other questions tagged binarypatch or ask your own question.Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |