WPatch plug-in

From NSIS Wiki
Jump to navigationJump to search
Author: Wizou (talk, contrib)


WPatch system official page

Presentation

WPatch is an optimized incremental patch system for NSIS (Nullsoft Install System). This patch system consists of 3 tools:

  • WGenPat: Compares 2 versions of the same file and creates a chunk of binary data describing the changes needed to transform the "old" version into the "new" one
  • WGenPatDir: Compares 2 directories (using WGenPat eventually) and creates a NSIS script that can patch the first directory to transform it into the second directory
  • WPatch: NSIS plugin that use this binary data to convert effectively an "old" version of the file into the "new" version of the file.

Original Features

(and improvements over the VPatch system included in NSIS)

  • In-place patching:
WPatch will patch files "in-place" in one pass. It does not create a temporary copy of the files to patch, and modifies the original file directly. This means the final user don't need extra free disk space, only the final file size is required.
  • Fast and Precise mode:
When enabled, for each files to patch, instead of scanning the whole patch database for the file signature, it will locate immediately a specific patch information (by offset). File signature is still verified to prevent patching a wrong version of the file. This mode also allows to patch two identical source files into different target files.
  • Support for huge files:
By default, a MD5 hash of the whole file is calculated as the file signature to verify that the file is really in the patch database. This can lead to a significant slowdown for huge files. For those, you can choose to only use the first & last 64K of the file as the signature. In this case, make sure that the beginning or end of the file contains data that are unique/specific for each patch (typically, I recommend placing a timestamp updated for each version of the huge file)

WPatch has been widely tested and performance improved in a real production environment.

Typical Usage

Using the WPatch system is as simple as calling: (for example)

WGenPatDir.exe --precise --exclude *.tmp;.svn dir1 dir2

to establish the difference between dir1 and dir2 (your "old" and "new" version of your program's directory), and, in your NSIS installer script:

Section
  InitPluginsDir
  ;...
  ; $INSTDIR points to the directory dir1 that is going to be transformed into dir2
SectionEnd
!include WGenPatDir.nsh
Section
  IfErrors 0 +2
    MessageBox MB_OK "There has been some errors !"
  ;...
SectionEnd

License

Copyright (c) 2007-2010 Olivier Marcoux

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. (see complete license in ReadMe.txt file)

Parts of this software are derived from VPatch.