Old 10th March 2008, 12:39   #1
********
Junior Member
 
Join Date: May 2004
Posts: 43
Improve NSIS unpacking

Is it possible to improve unpacking algorithm for NSIS installers in 7-Zip tool to restore original path relative to installdir directory? I understand that some paths are dynamically calculated, but are they calculated at compile time or during installation?
******** is offline   Reply With Quote
Old 16th March 2008, 19:33   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
I don't understand what you're asking for. The compression algorithm used and the paths where files are extracted are completely unrelated. Could you provide an example for clarity?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 16th March 2008, 20:50   #3
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
Paths can depend on variables that are set at run-time. In such cases it's impossible to obtain a location from installer file.
Joost Verburg is offline   Reply With Quote
Old 2nd September 2008, 12:06   #4
********
Junior Member
 
Join Date: May 2004
Posts: 43
Quote:
Originally posted by kichik
I don't understand what you're asking for.
I often use 7-Zip to get a file or two from my old NSIS installations for testing. Recently I decided to implement some automation for extracting these files. With ordinary archive, filepath relative to InstallDir is enough to get the file out of distribution. With NSIS it is not true.

One improvement is to detect when one file is added to several directories.

SetOutPath $INSTDIR
File example1.nsi
SetOutPath $INSTDIR\Kewl
File example1.nsi

In archive listing there will be only one entry of example1.nsi at root.

I understand that some paths are dynamically calculated at runtime, but these are rare. Most paths depends on unconditional combination of static strings that can be calculated relative to InstallDir at compile time. For example, when two strings are unconditionally assigned static values in some block and concatenated afterwards then resulting string is also static. I.e.

StrCpy $mydir "$INSTDIR\Kewl"
SetOutPath $mydir
File example2.nsi

This could create "Kewl\example2.nsi" entry inside archive instead of "$[32]\example2.nsi" Here is "unconditional assignment" - $mydir is initialized as constant and there is no branching that could make it contain different value until it is used in SetOutPath.

If the function receives only the same string variable that is written only once during script lifetime with the same constant value then this parameter to function can also be calculated as constant.
******** is offline   Reply With Quote
Old 5th September 2008, 11:57   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
So you're suggesting a static analysis of the code to remove redundant assignments and parameter passing? It's a great feature and I do plan for it with the nobjs branch. That said, it's far from a simple task and has much more use at optimization rather than making file extraction easier for external applications. I suggest you find a better solution for keeping your original files rather than modifying the installer or compiler's behavior. It's out of their scope.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th September 2008, 12:50   #6
********
Junior Member
 
Join Date: May 2004
Posts: 43
Yes, I think it can be called static analysis and I am glad you considered it a great feature. The idea of marking bundled file paths as being static or dynamic is just a single use case, but it would be nice to see it at least partially working. NSIS in not an SFX archiver, of course, and extracting files from an installer is more like occasional feature, but it also appeared very useful feature in my case. =)
******** 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