Archive: nsis and bzip2? you bet! here it is


nsis and bzip2? you bet! here it is
Hi All,

Well I've hacked up the freely available bzip2 and nsis source codes and married them. Here's the result:

http://mentasm.com/~zed/nsis/

Note, the code currently tries ALL NINE different blocksizes (0..9) and picks the best one. This means compression time is VERY long, but decompression isn't affected.

On my installer, I saved about 40k, but it will vary with different filetypes, let me know how you go.

--zz


looks like a good idea - but it didn't work for me :)


RegDLL/UnRegDLL: support for RegDLL not compiled in (NSIS_SUPPORT_ACTIVEXREG)
Error in script "colourificator_full.nsi" on line 58 -- aborting creation proces
s


uh...
it worked fine for me i just made a batch file to compile the script to the new exe but wasnt the point to come up with a smaller installer? mine went from 228,000 bytes to 233,584 bytes, maybe you should look into a better compression format like ACE 2.0 or the now in development 7Z format (Found Here) both seem to perform way better than zip in most all situations...


strike that
not only was the installer larger but it wont run, CRC invalid, but at least it compiled right ;) :eek:


Re: uh...

Originally posted by Kreft
it worked fine for me i just made a batch file to compile the script to the new exe but wasnt the point to come up with a smaller installer? mine went from 228,000 bytes to 233,584 bytes, maybe you should look into a better compression format like ACE 2.0 or the now in development 7Z format (Found Here) both seem to perform way better than zip in most all situations...
bzip2 is used 'cos it's free. Im pretty sure .ace isnt, and although Ive never heard of 7Z Ill assume it's not free either

Re: strike that

Originally posted by Kreft
not only was the installer larger but it wont run, CRC invalid, but at least it compiled right ;) :eek:
Sorry, I should've got all this said in one post, but the download page says

You must put CRCCheck off in your script for this to work

my bad on the crc check, i understand free, but why bother if the results are not a head above what already exists? :confused:


differant files compress differantly. In most cases this will be better compression than normal, but not always. A lot of people will get better results with this. Just as there will be files which ZIP better than they ACE, but in the majority of cases ACE works out better.


The results you get will vary, but generally they will be better! As I said, my installer came out 40kb smaller. The problem is that bzip2 doesn't like small files. In a perfect world, nsis would merge small files so that they can be compressed more efficiently.

I think you'll generally come out infront with installers of 0.5meg+ and with large files inside.

Ace compression would be good to use, but it's not free. I'd really like to use UPX's algorithm, but that's not released either, unless I can come up with some hack that uses the released upx.exe and then strips the exe header. I beleive UPX's uncompress code is available.

Also, you'll find that bzip2 does ALOT better than zlib when it comes to large text files.

--zz.


suggestion
i dont know how feasible this would be but you could since the compress time is already long make it compare zlib compression also and do the best out of all of the bzip2 and zlib compressions, may be a bit more work but theoreticly you would end up with the best that free can give you ;)


Well, the bzip2 would be a good idea if you don't mind ruining your apps. Zed, you have to realize that the marrage between the 2 is and was not a good idea. Not many people care if their installer was to big, because that makes it better for CD and not an internet download. Now (I'm probably sure about this, but I could be wrong) If an internet download was necessary (Like Winamp) Then I would think about using the Bzip2 product. But if I did I would use it's own compression then AFTER I have made the installer. It is hard to explain, but here is an analogy for you, The only reason WinZip doesn't use any other Huge Compressor is because of 2 things. 1) They don't want to ruin their customer's product/Zip file and 2) They don't want to wait for it to finish. I think you did a great job on the coding and the compression, but if one wanted to use it I would tack on a "USE AT YOUR OWN RISK"

-Duane
p.s. I'm sorry if it sounds like jibberish, but I'm on a MAC!!!!!


Originally posted by DuaneJeffers
Well, the bzip2 would be a good idea if you don't mind ruining your apps. Zed, you have to realize that the marrage between the 2 is and was not a good idea. Not many people care if their installer was to big, because that makes it better for CD and not an internet download. .....-Duane
p.s. I'm sorry if it sounds like jibberish, but I'm on a MAC!!!!!
Eh, sorry duane, but isn't the whole point in using NSIS to make small installers, at least that's the best thing about it for most users Im sure. And isn't the #1 way of distributing software over the net? OK, I can maybe see why you might be worried about not being able to have a CRC check in this version so yer files might get trojaned or something and users'll think there fine, but apart from that I think bzip2 is a bloody good idea and if your careful and do your own virus checking your files should be fine. Taking longer to compress isn't a worry either, it only ever needs to be done once, so why is taking longer a worry? As for the use at your own risk, that's kind of a given when using any kind of free software anyway - Justin's NSIS ain't bug free either. (2 fixes only since 1.44: 'Fixed a bug in ui.c which could potentially cause problems.
Fixed a bug in MoveFileOnReboot (thanks to Francis Irving)')

But if you are like me, I use small files, I mean small. Then this will not work for me. But I can see your reasoning. I might have some use for it later on, but I believe NSIS was created to have a great installer that can very at times AND have a small header file. Then when downloading a file, you only download a small installer and then the binaries (relitevely speaking). Plus the zlib compression is widely used by many companies including the ones who make WinZip, PowerArchiver and Microsoft has a ME version for unziping zip files using a varient of zlib compression. Now don't get me wrong, but smaller exes would be great, but it will not happen for very long. Once compression will hit hard drives, that will be the day when we see a difference in EXE sizes. It (like I said before) is hard to explain, but it will not happen any time soon.

-Duane


Sorry DuaneJeffers, but I don't understand a single point you're trying to make. Bzip2 is not a HUGE compressor. The decompression code came out only a few kb larger than the zlib one, and most of this was because I didn't remove all the dead code in there. With a bit of tweaking it would come out roughly the same.

How can you ruin your installers? Are you referring to the CRC check? The only reason the crc check doesn't work is because I temporarily commented it out. This was because it's in the zlib code. A crc check can be re-added without much trouble. Are you trying to say that bzip2 may be unreliable/buggy? I beleive they've tested it on many gigabytes of data.

Why does it make it better to use zlib for CD? Do you realize the decompression code is embedded in the installer executable itself?

Kreft: Your idea is ok, but then you'll have to put both bzip2 and zlib decompression code in the exehead. So you might loose out overall.

--zz


umm 7Z format is free under LGPL i believe if you go to the page it tells you that.. http://www.7-zip.org/


i thought so
i thought i saw that it was free thats why i mentioned it, and about having to have both decompressors in the header... why cant you upon deciding which compression works best for the fileset then decide which decompressor to write to the header, i understand you may have to rewrite the order of some events but the outcome could be worth the effort, especially if you threw in 7Z format also, then you could simple have a command in the script (or command line) to use whichever compressor you want or 'best' where it would decide for you. just a thought but if you implement is smoothly bugfree and with crc checking i think you would have a winner.


The problem with 7z is that it's in C++, and C++ is ummm bad.

Here's another one I'm playing with:

http://mentasm.com/~zed/nsis/makensis_Zzip.exe

you can guess it uses Zzip compression and seems to beat both bzip2/zlib quiet easily. It's right up there with ACE when it comes to binaries. I also compiled it with the crc check and activex-regdll support this time.

Disadvatanges:
- slower decompression (can't you wait 2 seconds instead of 1?)
- high memory usage (could be fixed with some work)

My installer came out 104kb smaller than with zlib.

--pz


Excellant - worked flawlessly and knocked 80k straight off the size of my installer, and I feel much more comfortable with it using CRC check. The disadvantages don't trouble me at all.

Im well impressed - thanks a lot


:)


better
this saved me 1k on one installer and cost me 2k on another, but that is better than bzip2 was doin me...


source?
Could you make the source to the bzip2 and zzip NSIS versions available? thanks!