Archive: redefine InstType


redefine InstType
I am trying to make my installer work more intelligently as an upgrader if previous versions of my software is already installed.

What I want to do is have only certain sections selected if the previous versions are found on the machine. Using '!insertmacro SecSelect' works fine if I do not have any InstTypes set for the installer. If I set InstTypes, the same code runs but when the component page opens, InstType 1 is selected and my choices are not remembered. If I run the '!insertmacro SecSelect' after the components page, I only get Prog Group 1 installed.

I found another potential solution but this is not working for me (see sample code below). Setup like this, the .onInit changes seem to be overwritten by the main code.

Any suggestions?

<code>
!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 ClearSectionInInstType ${SecP1} 1
!insertmacro UnassignInstallSection ${SecP1}
IfFileExists "$PROGRAMFILES\Progs\prog1.exe" +1 +3
!insertmacro SetSectionInInstType ${SecP1} 1
!insertmacro AssignInstallSection ${SecP1}
IfFileExists "$PROGRAMFILES\Progs\prog2.exe" +1 +3
!insertmacro SetSectionInInstType ${SecP2} 1
!insertmacro AssignInstallSection ${SecP2}
IfFileExists "$PROGRAMFILES\Progs\prog3.exe" +1 +3
!insertmacro SetSectionInInstType ${SecP3} 1
!insertmacro AssignInstallSection ${SecP3}
IfFileExists "$PROGRAMFILES\Progs\prog4.exe" +1 +3
!insertmacro SetSectionInInstType ${SecP4} 1
!insertmacro AssignInstallSection ${SecP4}
FunctionEnd

InstType "Prog Group 1"
InstType "Prog Group 2"
InstType "Prog Group 3"
InstType "Prog Group 4"

Section "Prog 1" SecP1
SectionIn 1
SectionEnd
Section "Prog 2" SecP2
SectionIn 2
SectionEnd
Section "Prog 3" SecP3
SectionIn 3
SectionEnd
Section "Prog 4" SecP4
SectionIn 4
SectionEnd
!insertmacro XPUI_PAGE_WELCOME
!insertmacro XPUI_PAGE_COMPONENTS
!insertmacro XPUI_PAGE_INSTFILES
!insertmacro XPUI_PAGE_FINISH


</code>



!macro AssignInstallSection P_SEC
Push $0
SectionGetFlags ${P_SEC} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${P_SEC} $0
Pop $0
!macroend

!macro UnassignInstallSection P_SEC
Push $0
SectionGetFlags ${P_SEC} $0
IntOp $0 $0 ^ ${SF_SELECTED}
SectionSetFlags ${P_SEC} $0
Pop $0
!macroend


This may not fix it, but it would be the correct way to set/unset state flags.

Stu

I made those changes but and put in a message box to show me the status of the changes. The changes are being made in .onInit; however, these changes are lost by the time I display the components page.

It seems that the SectionIN command is checked after .onInit and thus is overwriting the changes that I made.

I tried also making the changes using !define XPUI_PAGE_CUSTOMFUNCTION_PRE RedefInstType right before calling !insertmacro XPUI_PAGE_INSTFILES but I still only get the SectionIN defines.

I am going to try removing the SectionIN commands and see if I get the results I am looking for from .onInit. If I do, I will set the InstTypes there instead and see if I can get it to work.


HI
I need the same, but usingo mememto and MUI
Any ideas?
TIA


Originally posted by Boyito
HI
I need the same, but usingo mememto and MUI
Any ideas?
TIA
http://forums.winamp.com/showthread....hreadid=272285

http://forums.winamp.com/showthread....hreadid=272457

Thanks RW but both links refers to my previous post, and there is not the answer


You're welcome Boyo, allow me to say that your query is answered up to the point where it needs some effort by your side :)


Ah, I think I found a big problem that helps to explain why this is not working. I had not noticed before because when using Component Manager, the compiler always spits out a bunch of warnings.

I just checked and found that I got 40 warnings about unknown variable/constant "{SECHM}" detected, ignoring (macro:AssignInstallSection:4)

If I change the ${SECHM} to a number, I get no warnings and I can actually make the changes that I wish. I did need to adjust the number based on the InstTypes being included in the SectionIndex; however, this is now working for me.


${SECHM} is a compile time hard coded definition, $SECHM could be a variable when it is declared properly.


Red Wine, I agree.

It seems that if I use Section "Name" SEC_1, I can then use ${SEC_1} in the code to modify the InstType; however if I am using Component Manager and thus use the CM_Section macro defined as ${Section} instead, the ${SEC_1} never gets defined and thus the code to modify the InstType does not work.


Sorry! I'd like to help but I've never tried Component Manager.


Its OK. I have the functionality I am looking for now.

I just have to remember to manually change the upgrade code if I change the order or number of sections since the sectionindex will change.