Archive: Section Dependencies


Section Dependencies
Hello all,

I am looking for a way of marking sections as dependent. For example

- Section 1 (Installs Service)
- Section 1.1 (Starts Service)
- Section 1.1.2 (Starts Service)

Obviously the service cannot be started if it hasnt been installed, so I am looking for a method of making 1.1 dependent on 1.

At the moment I have the following snipped "code":


SectionGroup "Runtime Files"

Section "Install Service" sec_svc_install
SectionEnd

Section "Start Service" sec_svc_start
SectionEnd

SectionGroupEnd


After some hunting around I found the following:

http://nsis.sourceforge.net/Section_Dependency

Is this the only way to do this?

It's pretty simple. In .onSelChange you need to check if ${sec_svc_start} is selected and if it is, select ${sec_svc_install}.

!include Sections.nsh

Function .onSelChange

SectionGetFlags ${sec_svc_start} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 ${SF_SELECTED} 0 +4

SectionGetFlags ${sec_svc_install} $R0
IntOp $R0 $R0 | ${SF_SELECTED}
SectionSetFlags ${sec_svc_install} $R0

FunctionEnd


Place it below all of your Sections.

-Stu