Skip to content

GumTree Installer Notes_136675359

nxi edited this page Apr 9, 2015 · 1 revision
Created by Tony Lam, last modified on Dec 17, 2009

Introduction

This page describes some notes on the GumTree NSIS installer. The technology we use for creating installers is called NSIS. It is free and provides a nice development environment under Eclipse (EclipseNSIS). The installation strategies are follow:
  • Copy complete instrument specific artefacts to the install directory
  • Create shortcut on desktop and start menu
  • Replace <instrument>.ini depending on installation type
The installation type is about which <instrument>.ini needs to be installed for configurating runtime workspace location and potentially other parameters. In the installer, you we supply the command line argument "-type bragg", for example, to run the installer in bragg type. In this case, the installer will look for a file /ini/quokka.bragg.ini and replace /quokka.ini.

Setup

You need to install NSIS (for example, under D:\build\app for Bragg's continuous build system) and AccessControl plugin from http://nsis.sourceforge.net/AccessControl_plug-in

Script and Customisation

The installer is compiled by NSIS with the following script:
Name &quot;GumTree ${INSTRUMENT_LABEL}&quot;

# General Symbol Definitions
!define REGKEY &quot;SOFTWARE\$(^Name)&quot;
!define VERSION ${APP_VERSION}
!define COMPANY ANSTO
!define URL http://gumtree.codehaus.org

# MUI Symbol Definitions
!define MUI_ICON &quot;${NSISDIR}\Contrib\Graphics\Icons\modern-install-full.ico&quot;
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY}
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup
!define MUI_STARTMENUPAGE_DEFAULTFOLDER GumTree
!define MUI_UNICON &quot;${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico&quot;
!define MUI_UNFINISHPAGE_NOAUTOCLOSE

# Included files
!include &quot;FileFunc.nsh&quot;
!include Sections.nsh
!include MUI2.nsh

# Variables
Var StartMenuGroup

# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

# Installer languages
!insertmacro MUI_LANGUAGE English

# Installer attributes
OutFile ${INSTRUMENT_LABEL}Setup_${VERSION}.exe
InstallDir $PROGRAMFILES\GumTree\${INSTRUMENT}
CRCCheck on
XPStyle on
ShowInstDetails show
VIProductVersion ${APP_VERSION}.0
VIAddVersionKey ProductName &quot;GumTree ${INSTRUMENT_LABEL}&quot;
VIAddVersionKey ProductVersion &quot;${VERSION}&quot;
VIAddVersionKey CompanyName &quot;${COMPANY}&quot;
VIAddVersionKey CompanyWebsite &quot;${URL}&quot;
VIAddVersionKey FileVersion &quot;${VERSION}&quot;
VIAddVersionKey FileDescription &quot;&quot;
VIAddVersionKey LegalCopyright &quot;&quot;
InstallDirRegKey HKLM &quot;${REGKEY}&quot; Path
ShowUninstDetails show

# Installer sections
Section -Main SEC0000
    SetOutPath $INSTDIR
    SetOverwrite on
    File /r ${SOURCE}\${INSTRUMENT}\*
    CreateShortcut &quot;$INSTDIR\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot; $INSTDIR\${INSTRUMENT}.exe
    # Grant access
    AccessControl::GrantOnFile $INSTDIR &quot;BUILTIN\USERS&quot; &quot;FullAccess&quot;
    WriteRegStr HKLM &quot;${REGKEY}\Components&quot; Main 1
SectionEnd

Section -post SEC0001
    WriteRegStr HKLM &quot;${REGKEY}&quot; Path $INSTDIR
    SetOutPath $INSTDIR
    WriteUninstaller $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
    !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
    # For all users
    SetShellVarContext all
    SetOutPath $SMPROGRAMS\$StartMenuGroup
    CopyFiles &quot;$INSTDIR\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot; &quot;$DESKTOP\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
    CopyFiles &quot;$INSTDIR\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot; &quot;$SMPROGRAMS\$StartMenuGroup\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
    Delete &quot;$INSTDIR\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
    CreateShortcut &quot;$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk&quot; $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
    # Replace .ini file based on type
    ${GetOptions} $CMDLINE &quot;-type&quot; $R0
    CopyFiles $INSTDIR\ini\${INSTRUMENT}.$R0.ini $INSTDIR\${INSTRUMENT}.ini
    !insertmacro MUI_STARTMENU_WRITE_END
    WriteRegStr HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; DisplayName &quot;$(^Name)&quot;
    WriteRegStr HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; DisplayVersion &quot;${VERSION}&quot;
    WriteRegStr HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; Publisher &quot;${COMPANY}&quot;
    WriteRegStr HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; URLInfoAbout &quot;${URL}&quot;
    WriteRegStr HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; DisplayIcon $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
    WriteRegStr HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; UninstallString $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
    WriteRegDWORD HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; NoModify 1
    WriteRegDWORD HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; NoRepair 1
SectionEnd

# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
    Push $R0
    ReadRegStr $R0 HKLM &quot;${REGKEY}\Components&quot; &quot;${SECTION_NAME}&quot;
    StrCmp $R0 1 0 next${UNSECTION_ID}
    !insertmacro SelectSection &quot;${UNSECTION_ID}&quot;
    GoTo done${UNSECTION_ID}
next${UNSECTION_ID}:
    !insertmacro UnselectSection &quot;${UNSECTION_ID}&quot;
done${UNSECTION_ID}:
    Pop $R0
!macroend

# Uninstaller sections
Section /o -un.Main UNSEC0000
    RmDir /r /REBOOTOK $INSTDIR
    DeleteRegValue HKLM &quot;${REGKEY}\Components&quot; Main
SectionEnd

Section -un.post UNSEC0001
    # For all users
    SetShellVarContext all
    DeleteRegKey HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot;
    Delete /REBOOTOK &quot;$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk&quot;
    Delete /REBOOTOK &quot;$SMPROGRAMS\$StartMenuGroup\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
    Delete /REBOOTOK $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
    Delete /REBOOTOK &quot;$DESKTOP\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
    DeleteRegValue HKLM &quot;${REGKEY}&quot; StartMenuGroup
    DeleteRegValue HKLM &quot;${REGKEY}&quot; Path
    DeleteRegKey /IfEmpty HKLM &quot;${REGKEY}\Components&quot;
    DeleteRegKey /IfEmpty HKLM &quot;${REGKEY}&quot;
    RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
    RmDir /REBOOTOK $INSTDIR
SectionEnd

# Installer functions
Function .onInit
    InitPluginsDir
FunctionEnd

# Uninstaller functions
Function un.onInit
    ReadRegStr $INSTDIR HKLM &quot;${REGKEY}&quot; Path
    !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup
    !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
FunctionEnd
You can use the EclipseNSIS template dialog to help you to create the basis of above script, but you need to modify and add the following code:
Global:
(M) Name &quot;GumTree ${INSTRUMENT_LABEL}&quot;

General Symbol Definitions:
(M) !define VERSION ${APP_VERSION}

Included files:
(A) !include &quot;FileFunc.nsh&quot;

Installer attributes:
(M) OutFile ${INSTRUMENT_LABEL}Setup_${VERSION}.exe
(M) InstallDir $PROGRAMFILES\GumTree\${INSTRUMENT}

Installer attributes:
(M) VIProductVersion ${APP_VERSION}.0
(M) VIAddVersionKey ProductName &quot;GumTree ${INSTRUMENT_LABEL}&quot;

Section -Main:
(M) File /r ${SOURCE}\${INSTRUMENT}\*
(A) CreateShortcut &quot;$INSTDIR\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot; $INSTDIR\${INSTRUMENT}.exe
(A) # Grant access
(A) AccessControl::GrantOnFile $INSTDIR &quot;BUILTIN\USERS&quot; &quot;FullAccess&quot;

Section -post:
(M) WriteUninstaller $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
(A) # For all users
(A) SetShellVarContext all
(A)     CopyFiles &quot;$INSTDIR\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot; &quot;$DESKTOP\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
(A)    CopyFiles &quot;$INSTDIR\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot; &quot;$SMPROGRAMS\$StartMenuGroup\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
(A) Delete &quot;$INSTDIR\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
(M) CreateShortcut &quot;$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk&quot; $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
(A) # Replace .ini file based on type
(A) ${GetOptions} $CMDLINE &quot;-type&quot; $R0
(A) CopyFiles $INSTDIR\ini\${INSTRUMENT}.$R0.ini $INSTDIR\${INSTRUMENT}.ini
(M) WriteRegStr HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; DisplayIcon $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
(M) WriteRegStr HKLM &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)&quot; UninstallString $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe

Uninstaller sections:
(A) # For all users
(A) SetShellVarContext all
(M) Delete /REBOOTOK &quot;$SMPROGRAMS\$StartMenuGroup\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
(A) Delete /REBOOTOK $INSTDIR\${INSTRUMENT_LABEL}Uninstall.exe
(A) Delete /REBOOTOK &quot;$DESKTOP\${INSTRUMENT_LABEL} ${VERSION}.lnk&quot;
When compile, you need to addtional symbols:
INSTRUMENT quokka
INSTRUMENT_LABEL Quokka
APP_VERSION 1.4.1
SOURCE X:\gumtree\releases\apps

Automation

The installer generation is automated in the CruiseControl build system. The automation needs to go through the following steps:
  1. Clean "export" folder and use it as the temporary space
  2. Copy all necessary artifacts
    1. Copy the generic GumTree runtime except the .exe and .ini file (ie configuration, features, p2, plugins, artifacts.xml)
    2. Copy instrument specific artifacts (ie ini, xxx.exe, xxx.ini, splash.bmp)
    3. Copy GumTree common features
    4. Copy instrument specific feature
    5. Copy properties and scripts
  3. Run makensis to compile nsi script
  4. Create custom batch for running the installer in different mode
  5. Clear all temporary files except the installers and batches
  6. Repeat Step 1 - 5 for all instruments
  7. Copy all installers and batches to the CruiseControl artifacts folder
This automation process should be run manually during the deployment time.  However, due to the restriction in CruiseControl (where all build job must be scheduled to run in a fixed period of time), this process is set to repeat every week.

Bragg Specific Setup

A convenience way to install under Bragg's environment is to use the preconfigured setup batch, and they are in the name of "Bragg <instrument> <version> Install.bat". This batch contains a command:
EchidnaSetup_1.4.1.exe -type bragg
It makes the installer to use Bragg's setting to launch GumTree.
Document generated by Confluence on Apr 01, 2015 00:11
Clone this wiki locally