davidnewcomb
19th December 2006 17:58 UTC
Unable to select sections without going to custom install
I have two sections "Install" and "Extract", and 7 sections.
"Extract" has 1 of the sections selected and this simply extracts the payload.
"Install" does a number of tests and depending on external conditions selects 1 to 6 of the sections.
I want to present the user with "Extract" or "Install". The user will not be able to change any of the sections selected.
Unfortunately, I keep running into problems. If I use SectionIn to designate which sections are assigned to an Install type, it switches to a 'Custom' Install option as soon as I change any of them. If I set the components page to use /NOCUSTOM then on loading it sets the Install component type to blank which disappears when I select another option.
I want it to appear with Install and all the required options preselected, so the user can just click next.
The example below is as close as I can get it :( The type of install is set to blank. When you manually set it to Install it sets the correct options, but this is an extra step which I am trying to get rid of.
!include Sections.nsh
!include MUI.nsh
Name InstTest
OutFile c:\InstText.exe
InstallDir C:\Data\QuentinV3
InstType "Install"
InstType "Extract"
InstType /NOCUSTOM
!insertmacro MUI_PAGE_COMPONENTS
Section "Install Java SDK" sec_install_java
SectionIn ro 1
SectionEnd
Section "Install MySQL database server" sec_install_mysql
SectionIn ro 1
SectionEnd
Section "ISA Manager" sec_install_isa
SectionIn ro 1
SectionEnd
Section "Configure Database" sec_config_db
SectionIn ro 1
SectionEnd
Section "Update Quantel database" sec_config_update
SectionIn ro 1
SectionEnd
Section "Downdate Quantel database" sec_config_downdate
SectionIn ro 1
SectionEnd
Section "File Extract Only" sec_extract_only
SectionIn ro 2
SectionEnd
Function .onInit
!insertmacro ClearSectionInInstType "${sec_install_java}" "${INSTTYPE_1}"
!insertmacro ClearSectionInInstType "${sec_config_update}" "${INSTTYPE_1}"
!insertmacro SetSectionInInstType "${sec_extract_only}" "${INSTTYPE_2}"
FunctionEnd
Red Wine
19th December 2006 22:36 UTC
I guess this is what you're looking for :-)
!define SF_USELECTED 0
!define SF_SELECTED 1
!define SF_RO 16
Name InstTest
OutFile 'InstText.exe'
InstType "Install"
InstType "Extract"
InstType /NOCUSTOM
!include MUI.nsh
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section "Install Java SDK" SEC_1
;;;;;;;;;;;;;;
SectionEnd
Section "Install MySQL database server" SEC_2
;;;;;;;;;;;;;;
SectionEnd
Section "ISA Manager" SEC_3
;;;;;;;;;;;;;;;
SectionEnd
Section "Configure Database" SEC_4
;;;;;;;;;;;;;
SectionEnd
Section "Update Quantel database" SEC_5
;;;;;;;;;;;;;;
SectionEnd
Section "Downdate Quantel database" SEC_6
;;;;;;;;;;;;;
SectionEnd
Section "File Extract Only" SEC_7
;;;;;;;;;;;;;;
SectionEnd
Function .onInit
# execute at least this sample script twice by changing the Push below
# respectively to contition1 contition2 and watch the action :-)
Push contition1
Pop $R0
StrCmp $R0 'contition1' contition1 contition2
contition1:
IntOp $0 ${SF_SELECTED} | ${SF_RO}
SectionSetFlags ${SEC_1} $0
SectionSetInstTypes ${SEC_1} 1
SectionSetFlags ${SEC_5} $0
SectionSetInstTypes ${SEC_5} 1
IntOp $0 ${SF_USELECTED} | ${SF_RO}
SectionSetFlags ${SEC_2} $0
SectionSetFlags ${SEC_3} $0
SectionSetFlags ${SEC_4} $0
SectionSetFlags ${SEC_6} $0
IntOp $0 ${SF_USELECTED} | ${SF_RO}
SectionSetFlags ${SEC_7} $0
SectionSetInstTypes ${SEC_7} 2
contition2:
StrCmp $R0 'contition2' 0 exit
IntOp $0 ${SF_SELECTED} | ${SF_RO}
SectionSetFlags ${SEC_1} $0
SectionSetInstTypes ${SEC_1} 1
SectionSetFlags ${SEC_5} $0
SectionSetInstTypes ${SEC_5} 1
SectionSetFlags ${SEC_2} $0
SectionSetInstTypes ${SEC_2} 1
SectionSetFlags ${SEC_3} $0
SectionSetInstTypes ${SEC_3} 1
IntOp $0 ${SF_USELECTED} | ${SF_RO}
SectionSetFlags ${SEC_4} $0
SectionSetFlags ${SEC_6} $0
IntOp $0 ${SF_USELECTED} | ${SF_RO}
SectionSetFlags ${SEC_7} $0
SectionSetInstTypes ${SEC_7} 2
exit:
FunctionEnd
davidnewcomb
20th December 2006 14:28 UTC
Wow thanks, You have obviously put in a lot of work for this.
It took quite a long time to understand how it works so I will add an explaination for others.
The reason why my orginal showed blank in the selection list was because the selected sections did not match any of the predefined install types.
After a bit of fiddling I found SetSectionInInstType in sections.nsh and wrote 2 macros to help standardise the SectionSet stuff.
!macro AssignInstallSection P_SEC
Push $0
IntOp $0 ${SF_SELECTED} | ${SF_RO}
SectionSetFlags ${P_SEC} $0
Pop $0
!macroend
!macro UnassignInstallSection P_SEC
Push $0
IntOp $0 ${SF_USELECTED} | ${SF_RO}
SectionSetFlags ${P_SEC} $0
Pop $0
!macroend
Function .onInit
!insertmacro SetSectionInInstType ${sec_install_java} 1
!insertmacro AssignInstallSection ${sec_install_java}
!insertmacro ClearSectionInInstType ${sec_install_mysql} 1
!insertmacro UnassignInstallSection ${sec_install_mysql}
!insertmacro ClearSectionInInstType ${sec_install_isa} 1
!insertmacro UnassignInstallSection ${sec_install_isa}
!insertmacro ClearSectionInInstType ${sec_config_db} 1
!insertmacro UnassignInstallSection ${sec_config_db}
!insertmacro SetSectionInInstType ${sec_config_update} 1
!insertmacro AssignInstallSection ${sec_config_update}
!insertmacro ClearSectionInInstType ${sec_config_downdate} 1
!insertmacro UnassignInstallSection ${sec_config_downdate}
!insertmacro SetSectionInInstType ${sec_extract_only} 2
Red Wine
20th December 2006 14:54 UTC
Î¥ou're welcome!. Nice job from your side!
Perhaps you may want to take a look at the attached below sample. I think it is a little more pro looking :-)
davidnewcomb
20th December 2006 18:11 UTC
Maybe 1 for the Wiki!
Red Wine
20th December 2006 18:18 UTC
I've already posted a topic at wiki with the above sample code because here in forum after a few days is not easy to find it by someone who might need it.