Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSIS Installer - Displaying different licences

Tags:

nsis

I'm trying to modify an existing NSIS install script to allow for different licence files to be presented to the user depending on whether they are a new or existing user. I have pre-existing code which detects an existing install in the .onInit section.

However I'm running into bumps trying to use the NSIS provided licence screen e.g.

!InsertMacro MUI_PAGE_LICENSE Content\Licence.rtf

I would like to be able to choose between Licence and Licence2.rtf (though they'll be renamed something representative in the final version).

I've tried using selectable sections calling functions which nest the !insertmacro but that doesn't work because it needs to be in the base level of the script.

I can't change the parameter to be runtime definable because it needs to know what the file is at compile time to build it into the installer.

I know I can roll my own custom page called from a function and do it that way but I was wondering if anyone had got the NSIS installer working with using the MUI_PAGE_LICENSE and different licences.

Thanks

like image 325
Wysawyg Avatar asked Mar 12 '10 16:03

Wysawyg


2 Answers

There are two ways to skin this cat:

  • Use 2 license pages and skip one of them
  • Load the license file manually at run-time

Two pages:

!define MUI_PAGE_CUSTOMFUNCTION_PRE skip1
!InsertMacro MUI_PAGE_LICENSE Content\Licence.rtf
!define MUI_PAGE_CUSTOMFUNCTION_PRE skip2
!InsertMacro MUI_PAGE_LICENSE Content\Licence2.rtf
#You need two functions skip1 and skip2, they should call `abort` to skip based on some state you determine at run-time

Manual load:

There is a plugin that does this for you (Not sure if it supports RTF)

I wrote some code that does this using the system plugin, you can find that on the nsis forum. To use that code, you would include your license files with normal File commands and extract the one you want to $pluginsdir and load it in the license page's show callback function.

like image 84
Anders Avatar answered Jan 02 '23 21:01

Anders


There is an easier way. I use this code:

!insertmacro MUI_PAGE_LICENSE $(MUILicense)

Also, you have to put in your code lines like this:

LicenseLangString MUILicense ${LANG_POLISH} "SomeDirectory\licencja_pl.txt"
LicenseLangString MUILicense ${LANG_ENGLISH} "SomeDirectory\license_en.txt"

They don't have to appear before inserting license macro. In my code I defined them just below and it works fine.

like image 41
Erundil Avatar answered Jan 02 '23 21:01

Erundil