- NSIS Discussion
- Feature Request: info on installed components
Archive: Feature Request: info on installed components
Smile2Me
23rd November 2001 08:38 UTC
Feature Request: info on installed components
I would like to know which components have been
selected before actually installing these components.
Right now, I'm installing the components and at the
end I'm checking which have been installed to pose
some questions....
I know it's not possible with current NSIS but maybe
someone (Justin???) can help me solving this little
problem, because I'm not a C-programmer so I cannot
adapt the source code myself.
Thx greatly,
- :D Hendri :D -
felfert
23rd November 2001 11:15 UTC
Ok, here is a patch for my hacked-up version. It's against version 1.67. With this patch applied, you'll get an NSIS which supports a variable $SECTIONS which is simply a string of all enabled section numbers. E.g. If you have 5 sections and the first and the
last are enabled, the value is "15".
A usage example:
Function IsSectionEnabled
exch $2
push $1
push $0
strlen $0 $SECTIONS
loop:
IntOp $0 $0 - 1
IntCmp $0 -1 notfound
strcpy $1 $SECTIONS 1 $0
strcmp $1 $2 found loop
notfound:
strcpy $2 0
goto return
found:
strcpy $2 1
return:
pop $0
pop $1
exch $2
FunctionEnd
Function Whatever
push 2
call IsSectionEnabled
exch $1
IntCmp $1 1 enabled 0 0
DoSomethingIfSection2IsNotEnabled
goto nomatch
enabled:
DoSomethingIfSection2IsEnabled
nomatch:
pop $1
FunctionEnd
Apart from that, this patch also includes the following additions (i'm too lazy to sort that out for now :p ):
- Support for .onDlgPage callback as described here.
- Support for "ExecDLL", see syntax below.
ExecDLL Description
Syntax:
ExecDLL
PathToDLL FunctionName ParameterString
This loads the DLL specified in PathToDLL, and runs the function FunctionName of that DLL. This function must be exported of course, and declared like this:
typedef struct {
HWND hMainWindow;
HWND HelpText;
int CancelId;
int BackId;
int NextId;
} tNSISparams;
int fun(tNSISparams*, LPCSTR);
On calling this function, params are set with the following
values:
tNSISparams:
hMainWindow = HWND of NSIS main window
HelpText (currently unused)
CancelId = ID of cancel button
BackId = ID of "< Back" button
NextId = ID of "Next >" button
LPCSTR:
The value of ParameterString
On return, the value returned by this function is pushed on the stack for evaluation in the script.
How to apply this patch[list=1][*]Get cygwin from
here.[*]In cygwin's bash shell, cd into the source directory[*]Run
patch -p0 < nsis-1.67misc.patch.txt[/list=1]
Have fun
-Fritz
Smile2Me
24th November 2001 14:29 UTC
thx...
Fritz,
I really thank you for your effort in answering my question.
The problem is, I have run into problems trying to install
CygWin, because I didn't know what to install and I didn't
want to wait to download all components because I have a
dial-up modem...
And because I do not know anything about C or Unix, I'm not
such a pro, I'm just an ordinary econometrician...
I will search for some info on CygWin and download it somewhere
and then I will try your patch!!!
(But maybe Justin will have a new version of NSIS (1.68)
with this variable $SECTIONS available by that time.)
Thanks again,
- :D Hendri :D -
Hando
26th November 2001 16:31 UTC
I'm getting an error applying the patch
I've grabbed Cygwin and extracted Patch.exe and the cygwin1.dll into my NSIS source directory. I applied that patch by typing
patch -p0 < nsis-1.67misc.patch.txt
in a DOS box but I get the following message:
missing header for unified diff at line 5 of patch
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urw /cygdrive/c/Programme/NSIS/Source/build.cpp ./build.cpp ---
|/cygdrive/c/Programme/NSIS/Source/build.cpp Wed Nov 14 21:15:44 2001 +++
|./build.cpp Mon Nov 19 08:48:12 2001 @@ -237,6 +237,7 @@ "SYSDIR\0" // 21
|"HWNDPARENT\0" // 22 "CMDLINE\0" // 23 + "SECTIONS\0" // 24 ; const char *p=in;
--------------------------
File to patch:
(The "File to patch" is a prompt for the filename)
What am I doing wrong?
felfert
26th November 2001 20:37 UTC
The patch file gets corrupted when downloaded, because it is a text-file and the browser changes Unix-LF's to DOS CR/LF. I zipped it now to prevent this.
Sorry
-Fritz
Hando
27th November 2001 15:19 UTC
Encountered another problem..
I should point out that I'm a complete novice when it comes to programming and VC++ so the following could very well be my own darn fault. Anyways, I did a reinstall of NSIS 1.67 and then applied the new patch from the .zip file. I got the following message:
patching file `./build.cpp'
patching file `./exehead/Ui.c'
patching file `./exehead/exec.c'
patching file `./exehead/exec.h'
patching file `./exehead/fileform.h'
patching file `./exehead/util.c'
patching file `./script.cpp'
Hunk #1 FAILED at 57.
Hunk #2 succeeded at 1122 (offset -2 lines).
1 out of 2 hunks FAILED -- saving rejects to ./script.cpp.rej
patching file `./tokens.cpp'
patching file `./tokens.h'
I opened it up in Visual C++ (version 6.0) and built it - this gave me no errors so I thought maybe everything was fine. I then tried to run the proggy but a messagebox pops up saying "Installer corrupted".
Obviously something's screwed up here (whether its me or the patch or my attempts at compiling the code). so if anyone can help out it'd be much appreciated as I'd really like to try out Felfert's .onDlgPage callbacks.
Failing that, maybe someone could post/email me a compiled makensis w/ these extensions.
Thanks
petersa
29th November 2001 08:59 UTC
Re: Feature Request: info on installed components
Originally posted by Smile2Me
I would like to know which components have been
selected before actually installing these components.
Easily done. No patches or hacks or new versions required.
Section 'Optional Section 1'
; ask the questions here, and then add another section further down that does the installation.
StrCpy $0 !
MessageBox MB_OK|MB_ICONQUESTION 'Yould you like to answer some questions?'
SectionEnd
Section 'Optional Section 2'
; ...
StrCpy $1 !
SectionEnd
Section -DoTheWork
StrCmp $0 ! 0 DoneOptionalSection1
; all the stuff for Optional Section 1
DoneOptionalSection1:
StrCmp $1 ! 0 DoneOptionSection2
; all the stuff for Optional Section 2
DoneOptionalSection2:
SectionEnd
I have used this technique to remove components that have been unchecked, if the installer is run again after the program is installed.
Smile2Me
29th November 2001 20:56 UTC
TXH A LOT!!!
Thanks a lot Petersa,
your solution work really great!
thx again,
- :D Hendri :D -
nsfis
30th November 2001 07:35 UTC
Petersa,
your solution works, but...
1) capacity in "Space required" field doesn't show correct values when you uncheck optional sections.
2) takes one valuable variable (we have only 10 of them)
So, ability to query if section is checked or not would be really useful.
petersa
30th November 2001 11:14 UTC
Hi nsfis,[list=1][*]Easily fixed using the AddSize command.[*]No solution for that. Personally, though, I've never used all ten variables.[/list=1]Still, I agree that a feature like that would be useful because it would take away the need to write all that extra code.
s0mbre
30th November 2001 17:04 UTC
Hi nsfis. :)
If you want to save the registers ($0-$9), why not use registry keys as variables, e.g.:
WriteRegStr HKLM SOFTWARE\MyApp "Flag1" "1"
You can treat this much the same way you would a variable, you just have to ReadRegStr and do a StrCmp before using it. :)
Section "-checkflags"
ReadRegStr $0 HKLM SOFTWARE\MyApp "Flag1"
;if flag is set, end this section
StrCmp $0 "1" SkipSection
;if flag is not set, go ahead with this section
...
SkipSection:
SectionEnd
petersa
3rd December 2001 11:43 UTC
That's actually quite a good idea!
By putting stuff in a temporary key in the registry you can pretty much store all the information you need, and then remove it all with one command.
s0mbre
3rd December 2001 21:17 UTC
Thanks petersa, I'm homoured you consider it to be a good idea. :D
I've been using simple one bit flags ever since I wrote assembly for the MC68000 in university. :)
DuaneJeffers
4th December 2001 01:54 UTC
Has Everyone forgotten about IfFileExists????? OMFG!!!! No doubt it
would mean alot of code, but it is much more easier than hacking NSIS with somewhat useful products. Simple Solution:
Name MyApp
OutFile MyApp.exe
;blah
;blah
;blah (Normal install functions)
Section "MySection"
File App.exe
SectionEnd
Section "Plugin 1"
File Plug.dll
SectionEnd
;If you have more than one file per section,
; then add them then use the first file for
; IfFileExists.
Section -post
IfFileExists "Plug.dll" 0 noplug
; the zero is for going to the next line
; 1 will also do
RegDLL "Plug.dll"
noplug:
;Continue on with install functions.
Now if that is hard to understand, sorry, but adding n-number lines Extra to see if someone has installed a certain section. Now if you have more items in the section, then just use the first file to check to see if the installer has installed the section, then do the appropriate code.
-Duane
Smile2Me
4th December 2001 07:44 UTC
Duane,
original post:
I would like to know which components have been
selected before actually installing these components.
So using IfFileExists does not apply here.
But using the solution by Petersa and using AddSize and
some registry keys, it works fine now!
Thanks a lot all!
Greetz.
Hando
4th December 2001 09:01 UTC
Not to flog a dead horse but...
I still haven't found a way to apply Felfert's patch and get it all working. Anyone had any luck or is just my inexperience?