Old 2nd August 2015, 12:10   #1
erundil
Junior Member
 
Join Date: Apr 2011
Posts: 20
SetCompressor to Best Compressor in script

When compiling an installer with MakeNSISW there is an option to choose the compressor under Script\Choose Compressor to override the SetCompressor line from the script.

There is a list of available compressors, one of them being "Best Compressor".
This of course tries every compression method and leaves the smallest file.

Is there a way to set the same behavior from within the script?
Something like "SetCompressor best"?
I know it doesn't work like that, but it's the best way to describe what I'm trying to accomplish.
It's rather irritating to switch compressors every single time. I'd rather define that in script.
erundil is offline   Reply With Quote
Old 2nd August 2015, 13:12   #2
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
I think this is a feature of MakeNSISW, nothing that's built into the NSIS language or the NSIS compiler (MakeNSIS).

MakeNSISW is simply going to compile your script several times, with different compressor settings. And it keeps the result that came out the smallest. Internally, it is calling MakeNSIS, setting up a different compressor via /X"SetCompressor /FINAL ???" for each run.

I think it shouldn't be too hard to do the same thing with, e.g., a Batch script...

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 3rd August 2015, 19:42   #3
Theresias
Member
 
Join Date: Jun 2006
Posts: 50
Those are the 3 you may want to experiment with... Especially dictionary size did something for me.
code:
SetCompressor /SOLID lzma
SetCompressorDictSize 64
SetDatablockOptimize ON

Theresias is offline   Reply With Quote
Old 3rd August 2015, 20:01   #4
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Yeah, LZMA with /solid switch and the largest possible dictionary value, which doesn't cause MakeNSIS to fail, will generally result in the "best" compression ratio that you can get. Not sure in which case any of the other compressors would beat LZMA. Maybe, when you have a lot of "already compressed" (incompressible) files, it will be more a game of luck which compressor happens to be the least worst...

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 5th August 2015, 01:17   #5
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 923
^^ This. Having a "best" option means the compiler will take 6 times as long (3 compressors, and /solid option for each). Generally LZMA /solid will give the best compression ratio. If all the files being included are compressed already, it's probably quicker to set compression off.

I played around with the idea of adding the LZ4 compressor to nsis a while ago but really there is no point as zlib is fast enough already.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 5th August 2015, 08:51   #6
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 343
There is a no way through which people cant open and extract nsis setup files?
for example "WinUHA" is a program sample winrar or other apps for compress file and after compress file format change to .uha
also with "WinUHA" can compress and create SFX archive.
with "WinUHA" can compress files with Algorithm ALZ,PPM,LZP...and 7zip cant open that after compress,now my question is that: can compress and raise security Such that nsis file format is exe and can run app? and nsis app cant open with 7zip?
is it possible? how?
thanks
r2du-soft is offline   Reply With Quote
Old 5th August 2015, 16:54   #7
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Quote:
Originally Posted by r2du-soft View Post
There is a no way through which people cant open and extract nsis setup files?
Nope, not with standard NSIS. You could compile your own customized (modified) NSIS, in order to make "unpacking" the resulting installer a little bit harder. At least it would prevent the standard tools (e.g. 7-Zip) from working with your installer. Nonetheless, any "self-extracting" archive (or Installer) unavoidably has to contain its own unpacking/extraction code. There obviously is no way around that! So, somebody who really wishes to "extract" your installer, can simply reverse-engineer the extraction routines that the Installer must have built-in. Sure, you may use techniques of "code obfuscation" to make this a little harder. But whatever you do, that's only "security through obscurity", no real protection. Maybe sufficient to defend against the "script kiddies" for a while, but it won't stop the experts...

(Also, think about the "smart cow" problem: If only one "mastermind", anywhere in the world, manages to break your protection and then uploads an "unpacking" tool to the Internet, everybody out there will be able to easily unpack your installer. Surely, in this case you can modify your protection code. And then again. And again. It's an endless "cat and mouse" game, which you cannot win, in the end)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 5th August 2015, 17:10   #8
DrO
 
Join Date: Sep 2003
Posts: 27,873
plus when the user runs the installer and the file(s) are installed, it's somewhat pointless that you made it harder to get them out of the installer as they'll just have the end result anyway.
DrO is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump