Archive: install vs. upgrade


install vs. upgrade
So, I've been reviewing the faqs, user manual, and forums for a few hours now and am not finding the answer I was hoping for.

My installer needs to do a detect to determine if the software is already installed, in which case we'll treat the install as an upgrade as opposed to a full install.

If during init I determine that an older version is already installed, I'd like to
-show the license
-show a page saying we're ready to do an upgrade
-do the install with specific sections

If no prior version exists, I want to
-show the license
-show the component selection page
-collect install location
-do the install

So the trick is that in one case (new install) I want to render the component page with one set of available sections, and in the other case (upgrade) I want to skip just about everything and install a hidden section. I do not want to use InstType for this because the user isn't getting a choice in the matter. Skipping the pages, although a little messy, can be done with aborts.

The question is, can I conditionally drive sections- i.e. only sections a, b, and c should be rendered as available choices on the component page, but if I don't show the component page, I should section d?


To hide/show sections use SectionSetText. A section with empty text is not displayed on the components page. You can also dynamically set sections to readonly by adding the SF_RO flag with Sections.nsh's SetSectionFlag.

You can also completely skip the page:

http://nsis.sourceforge.net/Skipping_Pages


Thanks for the reply-

I've tried setting setting the section flags to deselect a hidden section during init, but it doesn't seem to work. Even if I deselect the hidden section using the flags, it still gets installed.

Am I doing something wrong or is there no way at runtime to decide whether to install or skip a hidden section?


You've probably put the .onSelChange function before the definition of the sections. The section index define is only set once the Section line is processed.


To be more clear, here is what I'm doing:


Section /o -Shortcut shortcut
CreateShortCut "$DESKTOP\B-Gallery 3.lnk" "$INSTDIR\bgallery.exe"
SectionEnd

Function .onInit
SectionSetFlags ${shortcut} 0
FunctionEnd


It seems to me like by clearing all the flags, the section should be deselected since that bit isn't set. However, this code always results in the shortcut being installed. My sole goal here is to skip this section based on setting something in .onInit. I think maybe I'm misunderstanding something but I'm not sure what :igor:

P.S. using NSIS 2.31

You said earlier that you're using InstType. Hidden sections are marked as they belong to all installation types by default. You'd need to specify a certain installation type with SectionIn, set its flags after the components page, skip it in the section code itself or use SectionSetInstTypes to make belong to no installation type.