Archive: Patch technology in NSIS


Hi everyone,

I'm currently working on a 'patch' program which allows you to update files from 1 version to another.
It'll calculate the CRC of the source file, check if the patch is designed for this purpose, patch it, and then check to see if the CRC of the target file is correct.

However, I'm currently still working on the patch generator - though I have a (very) slow VB version which works.

Does anyone have any suggestions for a patcher?


Working on it
Hello everyone,

I'm still working on it, but I'm currently tracking down some bugs in the patch generator.
Once I got those ironed out, I have a basic patch generator. If you have a 1 MB file which is 90% identical to file #2, the patch will be about 20% - not very good, but it's a start.

After I get some bugs out, I can start on optimizing.

Is anyone interested in a patcher anyway?

Estimated size for the patch program executable itself is 32-64 KB. (Haven't finished it yet).


Re: Working on it

Originally posted by Koen van de Sande
Is anyone interested in a patcher anyway?
Yes. Clickteam has a nice patch proggie, but then again, it's Clickteam. I'd prefer something that's adless.

I am very much interested.


I fixed tons of bugs in my patcher, but there still appears to be one left, there is a problem with files larger than 1 MB and/or non-text characters. I'll just have to keep looking...

Still, the patcher is coming along quite nicely, it can at least generate patches now, and I have a "Patcher" which applies it to a file. Current size of the Patcher is 62 KB (or 28 KB after UPX), which is quite big. However, I'm using Delphi, so you do not need any extra other files. It's 62 KB plus the patch file size and nothing more.

After I get all bugs out, I can start to improve performance (and efficiency) of the patch generator. I'm not using any compression, because the compression inside NSIS is much better than anything I can add.

I'll post any progress I make here.


It works!
I fixed a copy-paste bug (which took me 2 days).

It works very well now, very fast compared to my VB version. I'm going to try and add variable-block size searching next, which'll improve both speed and patch size.

Is anyone else interested besides polaughin and Radioactive Man?

I could use a C(++) programmer who can translate the actual runtime program into C and make it smaller, because it's 61 KB because of the Delphi stuff.

It's a really simple program, less than 200 lines (haven't looked).


I'd be glad to create a very small compiled C version! You can keep all the credit for the program as long as I get to use it in my installer :)

Send me an email - wiked_edge@yahoo.com


That'd be great edgewize! I'm currently brushing up things a bit and making some last changes to the file format. And I just rewrote the CRC code a little which saves 1 kb.

Runtime size is now 61 KB, or 30 KB after UPX. Patch files can be (must be) linked to the exe in order to work. The file format supports multiple patches inside one patch file, but only one patch can be executed at a time.
All this is possible, but I haven't written support for it in the generator.

I'll send you the source code for the patcher tonight (including some test patches/files).

Should I release a first version which works, or should I wait until I've improved compression and speed in the generator?


First release is here!
I've just uploaded VPatch v1.0 (yes, it has a name now) to: http://www.tibed.net/vpatch/vp100.exe

What can it do?
- Create a small patch from an old version to a new version.
- Attach patches for multiple files to the patcher (so you only need to include this 30 KB once)
- Configure compression through genpat.ini (make sure you do this in order to have acceptable creation times).
- On my test files, it makes Clickteam Patch Maker look like crap: I have smaller patches (but it takes much longer than in Patch Maker).

E-mail koen@tibed.net or post here with suggestions/bug reports!


Replacement vpatch.bin for smaller patches

This is a replacement vpatch.bin with full source code, and a project file for MSVC++ 6.0 (sp4). Only 4k, much smaller for less overhead on the patch EXE file.

http://edgewize.cjb.net/vpatch_c.zip


GUI
Are you planning on implementing a GUI for this patch program?


Yes, a GUI is planned, but I haven't started yet. If someone makes a good GUI for NSIS, perhaps the patcher could be integrated.
But I can probably make an application where you can select original/new versions, create patches, save projects, etc. Then you'd no longer have to use any of the commandline utilities.

But I'm going to work on the Patch Generator itself first, I'm hoping to make it a little faster.

Question: v1.0 uses very little memory, but read the file the whole time from disk. Does anyone mind if the program is going to use SourceSize+TargetSize MB of RAM? Adding this will make patch creation of large files slower, but other things will be faster.


maybe as an option
Maybe you could make it an option so you can choose to use more RAM or read the file from disk.

Bor


I just made it use memory instead of disk - this causes a major speed increase :) - my new version works 80% faster. I'll be releasing this new version soon.
(now that it's faster, I can increase the default compression to be better).


80% faster is not a correct measure.
I mean 5 times faster.