Upgrading Wine with a Patch

If you have the Wine source code, as opposed to a binary distribution, you have the option of applying patches to the source tree to fix bugs and add experimental features. Perhaps you've found a bug, reported it to the Wine mailing list, and received a patch file to fix the bug. You can apply the patch with the patch command, which takes a streamed patch from stdin:

$ cd wine
$ patch -p0 < ../patch_to_apply.diff
      

To remove the patch, use the -R option:

$ patch -p0 -R < ../patch_to_apply.diff
      

If you want to do a test run to see if the patch will apply successfully (e.g., if the patch was created from an older or newer version of the tree), you can use the --dry-run parameter to run the patch without writing to any files:

$ patch -p0 --dry-run < ../patch_to_apply.diff
      

patch is pretty smart about extracting patches from the middle of a file, so if you save an email with an inlined patch to a file on your hard drive, you can invoke patch on it without stripping out the email headers and other text. patch ignores everything that doesn't look like a patch.

The -p0 option to patch tells it to keep the full file name from the patch file. For example, if the file name in the patch file was wine/programs/clock/main.c. Setting the -p0 option would apply the patch to the file of the same name i.e. wine/programs/clock/main.c . Setting the -p1 option would strip off the first part of the file name and apply the patch instead to programs/clock/main.c . The -p1 option would be useful if you named your top level wine directory differently to the person who sent you the patch. For the -p1 option patch should be run from the top level wine directory.