FFSM++  1.1.0
French Forest Sector Model ++
/srv/datadisk03/home/ffsm/code/ffsm_pp/windowsInstallerScript.nsi
Go to the documentation of this file.
1 ; FFSM++ Windows Instal Script
2 ; Writen to be compiled with NSIS
3 ; Antonello Lobianco, 2015
4 
5 ;--------------------------------
6 ; General
7  ; Things that will likelly need to be changed...
8  !define VERSIONSTRING "1.1.0" ; Pythiaversion number (as string). Used to put each version on a separate folder.
9 
10  OutFile "ffsm_pp_${VERSIONSTRING}_setup.exe" ; Filename of the outputted installer
11  !define MINGWDIR "C:\MinGW\bin" ; Directory where thre MinGW DLL is located
12  !define QTDIR "C:\Qt\4.8.2\bin" ; Directory where the Qt run-time DLLs are located
13  !define EXEDIR "." ; Directory where the EXE file is located
14 
15  !include "MUI.nsh" ; Include Modern UI
16  Name "FFSM++" ; Name (?)
17  InstallDir "$PROGRAMFILES\FFSM\${VERSIONSTRING}" ; Default installation directory
18  !define APP_NAME "FFSM++" ; Application name (mainly for links)
19  !define APP_FNAME "FFSM++ ${VERSIONSTRING}" ; Application name with version(mainly for links)
20  !define MAIN_APP_EXE "ffsm.exe" ; Filename of executable
21  !define WEB_SITE "http://ffsm-project.org" ; We-site address
22  Var OPTIONALDATA ; We'll use this variable to put links on sample data only if users have selected to intall sample data
23  Var LOCALDOC ;If user has selected to install documentation
24  Var SM_Folder ; Application shortcuts main folder
25  SetCompressor ZLIB ; Compression used
26  XPStyle on ; Style of the Wizard (look it doesn't change anything)
27 
28 ;--------------------------------
29 ; Interface Settings ( we define all settings before building the pages - next points)
30 
31  !define MUI_ABORTWARNING ; We give a confirmation warning before let the user abort the installation proces
32  !define MUI_ICON "src\imgs\ffsm.ico" ; icon for the installer
33  !define MUI_UNICON "src\imgs\ffsm.ico" ; icon for the uninstaller
34  !define MUI_WELCOMEFINISHPAGE_BITMAP "src\imgs\beech.bmp" ; image for the welcome and finish page
35  !define MUI_UNWELCOMEFINISHPAGE_BITMAP "src\imgs\beech.bmp" ; image for the welcome and finish page (uninstaller)
36  !define MUI_COMPONENTSPAGE_SMALLDESC ; section description on the bottom instead on the default right
37  !define REG_START_MENU "Start Menu Folder" ; ??
38  !define MUI_STARTMENUPAGE_DEFAULTFOLDER "FFSM\${VERSIONSTRING}" ; Default folder where to prompt the user to place links
39  !define MUI_FINISHPAGE_RUN "$INSTDIR\${MAIN_APP_EXE}" ; What propose the user to do after the installation is completed
40  !define MUI_WELCOMEPAGE_TEXT "Version ${VERSIONSTRING}\n\n FFSM++ is a flexible, spatially explicit, coupled resource and economic simulator of the Forest Sector, designed for long-term simulations of effects of government policies over different forest systems.\n\n This Wizard will guide you the installation of FFSM++. \n\n Press Next to start the installation."
41 
42 ;--------------------------------
43 ; Installer pages (steps)
44 
45  !insertmacro MUI_PAGE_WELCOME ; Welcome page
46  !insertmacro MUI_PAGE_LICENSE "COPYING" ; Accept licence page
47  !insertmacro MUI_PAGE_COMPONENTS ; Choose installation components (pieces)
48  !insertmacro MUI_PAGE_DIRECTORY ; Directory where to install
49  !insertmacro MUI_PAGE_STARTMENU Application $SM_Folder ; Write links (and where)
50  !insertmacro MUI_PAGE_INSTFILES ; Installing the files
51  !insertmacro MUI_PAGE_FINISH ; "Done!" page
52  !insertmacro MUI_UNPAGE_CONFIRM ; Confirmation request before uninstalling
53  !insertmacro MUI_UNPAGE_INSTFILES ; Uninstalling files
54 
55 ;--------------------------------
56 ; Languages
57 
58  !insertmacro MUI_LANGUAGE "English" ; ??
59 
60 ;--------------------------------
61 ; Installer Sections (components that user can choose if install it or not)
62 
63 Section "Main program" MainProgram
64  SectionIn RO ; Read only - the user can not delesect it !
65  SetOutPath "$INSTDIR" ; Where files need to be installed
66  File "${EXEDIR}\ffsm.exe" ; Adding this file or directory to the list of files to be installed
67  File "${MINGWDIR}\mingwm10.dll"
68  File "${MINGWDIR}\pthreadGC2.dll"
69  File "${MINGWDIR}\libgcc_s_dw2-1.dll"
70  File "${MINGWDIR}\libgfortran-3.dll"
71  File "${MINGWDIR}\libquadmath-0.dll"
72  File "${MINGWDIR}\libstdc++-6.dll"
73  File "src\ThirdParty\win32\lib\libadolc-1.dll"
74  File "AUTHORS"
75  File "COPYING"
76  File "NEWS"
77  File "README"
78  WriteUninstaller "$INSTDIR\Uninstall_ffsm.exe" ; Creating the uninstaller
79 SectionEnd
80 
81 Section "Run-time libraries" Qt
82  SetOutPath "$INSTDIR"
83  File "${QTDIR}\QtCore4.dll"
84  File "${QTDIR}\QtGui4.dll"
85  File "${QTDIR}\QtXml4.dll"
86 SectionEnd
87 
88 Section "Sample data" Data
89  SetOutPath "$INSTDIR\data"
90  File /r "data\*" ; Adding this file or directory to the list of files to be installed. /r means "recursively"
91  StrCpy $OPTIONALDATA "true" ; Saving the fact the user has chosen to install the sample data so later on me make the links
92 SectionEnd
93 
94 Section /o "Source" Src ; option /o means optional - unselected by default
95  SetOutPath "$INSTDIR\src"
96  File "src\*.h"
97  File "src\*.cpp"
98  File "src\*.pro"
99 SectionEnd
100 
101 Section /o "Documentation" Doc ;
102  ;not yet ready...
103  SetOutPath "$INSTDIR\doc"
104  File "doc\Install run and develop instructions.pdf"
105  File "doc\Input and output data management.pdf"
106  File "doc\Reference manual.pdf"
107  StrCpy $LOCALDOC "true"
108 SectionEnd
109 
110 ;--------------------------------
111 ; Component Descriptions
112 
113  ; Creating "Language strings" objects for each section...
114  LangString DESC_MainProgram ${LANG_ENGLISH} "Main FFSM++ files"
115  LangString DESC_Qt ${LANG_ENGLISH} "Run-time graphical libraries. Unselect this section only if you already have Qt 4.X installed on your PC"
116  LangString DESC_Data ${LANG_ENGLISH} "Sample input data (recommended)"
117  LangString DESC_Src ${LANG_ENGLISH} "FFSM++ C++ source code (not needed to run the program)"
118  LangString DESC_Doc ${LANG_ENGLISH} "Local copy of the documentation (for more doc refer to the site)"
119 
120  ;Assign "Language strings" objects to sections
121  !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
122  !insertmacro MUI_DESCRIPTION_TEXT ${MainProgram} $(DESC_MainProgram)
123  !insertmacro MUI_DESCRIPTION_TEXT ${Qt} $(DESC_Qt)
124  !insertmacro MUI_DESCRIPTION_TEXT ${Data} $(DESC_Data)
125  !insertmacro MUI_DESCRIPTION_TEXT ${Src} $(DESC_Src)
126  !insertmacro MUI_DESCRIPTION_TEXT ${Doc} $(DESC_Doc)
127  !insertmacro MUI_FUNCTION_DESCRIPTION_END
128 
129 ;--------------------------------
130 ; Links & icons
131 
132 Section -Icons_Reg
133  SetOutPath "$INSTDIR" ; Where files need to be installed by default
134 
135  !ifdef REG_START_MENU ; If the user has chosen to make links
136  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
137  ; Create directory for the shrtcuts ($M_Folder has been chosen by the user)
138  CreateDirectory "$SMPROGRAMS\$SM_Folder"
139  ; Shortcut to the main program
140  CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
141  ; Desktop shortcut to the main program
142  CreateShortCut "$DESKTOP\${APP_FNAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
143  ; Shortcut to the uninstaller
144  CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\Uninstall_ffsm.exe"
145  ${If} $OPTIONALDATA == 'true' ; If user has installed the sample data
146  ; Shortcut to data file
147  CreateShortCut "$SMPROGRAMS\$SM_Folder\Edit sample data.lnk" "$INSTDIR\data\ffsmInput.ods"
148  ${EndIf}
149  ${If} $LOCALDOC == 'true' ; If user has installed a local copy of the documentation
150  ; Shortcut to user manual file
151  CreateShortCut "$SMPROGRAMS\$SM_Folder\Install run and develop instructions.lnk" "$INSTDIR\doc\Install run and develop instructions.pdf"
152  ; Shortcut to data management
153  CreateShortCut "$SMPROGRAMS\$SM_Folder\Input and output data management.lnk" "$INSTDIR\doc\Input and output data management.pdf"
154  ; Shortcut to the reference manual
155  CreateShortCut "$SMPROGRAMS\$SM_Folder\Reference Manual.lnk" "$INSTDIR\doc\Reference manual.pdf"
156  ${EndIf}
157  ; Write internet shortcut to the main web-site and link it from the other START MENU shortcuts..
158  WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
159  CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk" "$INSTDIR\${APP_NAME} website.url"
160  ; Write internet shortcut to the on-line documentation and link it from the other START MENU shortcuts..
161  WriteIniStr "$INSTDIR\${APP_NAME} documentation.url" "InternetShortcut" "URL" "${WEB_SITE}"
162  CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Documentation.lnk" "$INSTDIR\${APP_NAME} documentation.url"
163  !insertmacro MUI_STARTMENU_WRITE_END
164  !endif
165 SectionEnd
166 
167 ;--------------------------------
168 ;Uninstaller Section
169 
170 Section "Uninstall"
171  RMDir /r "$INSTDIR" ; Recursivelly remove all files in the install directory
172  RMDir /r "$SMPROGRAMS\$SM_Folder" ; Remove links in the Start Menu ..doesn't works !!!
173  Delete "$DESKTOP\${APP_NAME}.lnk" ; Remove desktop link
174  ;DeleteRegKey /ifempty HKCU "Software\Pythia"
175 SectionEnd
176