forked from emesene/emesene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emesene-installer-MUI.nsi
320 lines (258 loc) · 11.7 KB
/
emesene-installer-MUI.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#--------------------------------
# Compressor Type
SetCompressor /SOLID lzma
#--------------------------------
# Includes
; Modern UI
!include "MUI2.nsh"
; Logic Lib (select and if statements)
!include "LogicLib.nsh"
#--------------------------------
;Variables
; Holds user-selected StartMenu Directory
Var StartMenuDir
#--------------------------------
# Defines
; Program info
!define PROGRAM_NAME "emesene"
!define PROGRAM_VERSION "2.12.9"
!define /date PROGRAM_BUILDTIME "%Y%m%d_%H%M"
!define PROGRAM_TYPE "installer"
!define PROGRAM_PUBLISHER "emesene team"
!define PROGRAM_WEBSITE "http://www.emesene.org"
!define PROGRAM_ISSUE "https://github.com/emesene/emesene/issues/"
; File info
!define FILE_CONFIG "$APPDATA\${PROGRAM_NAME}\${FILE_DIRECTORY}"
!define FILE_DIRECTORY "emesene2"
!define FILE_EXE "emesene.exe" ; Include ".exe"
!define FILE_DEBUG "emesene_debug.exe" ; Include ".exe"
!define FILE_UNINSTALL "uninstall.exe" ; Include ".exe"
; Shortcut info
!define SHORTCUT_STARTMENU "$SMPROGRAMS\$StartMenuDir"
!define SHORTCUT_EXE "emesene2.lnk" ; Include ".lnk"
!define SHORTCUT_DEBUG "emesene2 (Debug).lnk" ; Include ".lnk"
!define SHORTCUT_REPORT "Report Issue.lnk" ; Include ".lnk"
!define SHORTCUT_UNINSTALL "Uninstall.lnk" ; Include ".lnk"
; Registry info
!define REG_HIVE "HKLM" ; Sets registry time to local computer, all users
!define REG_INSTALL "Software\${FILE_DIRECTORY}"
!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FILE_DIRECTORY}"
; User info
!define USER_PRIVILEGES "admin" ; "admin" required to write to 'Program Files'
!define USER_SHELLCONTEXT "all" ; "all" will write to all, not just current
; Window info
!define WINDOW_CLASS "gdkWindowToplevel"
!define WINDOW_TITLE "emesene"
#--------------------------------
# General
; Name and output file
Name "${PROGRAM_NAME} ${PROGRAM_VERSION}"
OutFile "${PROGRAM_NAME}-${PROGRAM_VERSION}-${PROGRAM_BUILDTIME}-${PROGRAM_TYPE}.exe"
; The default installation directory
InstallDir "$PROGRAMFILES\${FILE_DIRECTORY}"
; Get installation folder from registry if available
InstallDirRegKey ${REG_HIVE} "${REG_INSTALL}" "Install_Dir"
; Request application privileges for Windows Vista/7
RequestExecutionLevel ${USER_PRIVILEGES}
#--------------------------------
# MUI Settings
; Abort warning, header image, and icons
!define MUI_ABORTWARNING
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "windows\header.bmp"
!define MUI_ICON "emesene.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "${REG_HIVE}"
!define MUI_LANGDLL_REGISTRY_KEY "${REG_INSTALL}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Install_Lang"
; StartMenu page configuration
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${FILE_DIRECTORY}"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_HIVE}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${REG_INSTALL}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenu_Dir"
; Finish page configuration
!define MUI_FINISHPAGE_RUN "$INSTDIR\${FILE_EXE}"
#--------------------------------
# Pages
; Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU "Application" $StartMenuDir
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
#--------------------------------
# Languages
; List of installer languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Spanish"
#--------------------------------
# Reserve Files
; Reserves language files
!insertmacro MUI_RESERVEFILE_LANGDLL
#--------------------------------
# Functions
; Runs before before everything else during installation
Function ".onInit"
; Detects if the program is running and asks user to close it
FindWindow $0 "${WINDOW_CLASS}" "${WINDOW_TITLE}"
StrCmp $0 0 notRunning
MessageBox MB_OK|MB_ICONEXCLAMATION "${PROGRAM_NAME} is currently running. Please close it and try again." /SD IDOK
Abort
notRunning:
; Select language on installer start
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
; Register uninstaller into Add/Remove panel (for local user only)
Function "RegisterApplication"
WriteRegStr ${REG_HIVE} "${REG_UNINSTALL}" "DisplayName" "${PROGRAM_NAME}"
WriteRegStr ${REG_HIVE} "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\${FILE_EXE}$\""
WriteRegStr ${REG_HIVE} "${REG_UNINSTALL}" "Publisher" "${PROGRAM_PUBLISHER}"
WriteRegStr ${REG_HIVE} "${REG_UNINSTALL}" "DisplayVersion" "${PROGRAM_VERSION}"
WriteRegStr ${REG_HIVE} "${REG_UNINSTALL}" "HelpLink" "${PROGRAM_ISSUE}"
WriteRegStr ${REG_HIVE} "${REG_UNINSTALL}" "URLInfoAbout" "${PROGRAM_WEBSITE}"
WriteRegStr ${REG_HIVE} "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\""
WriteRegDWORD ${REG_HIVE} "${REG_UNINSTALL}" "NoModify" 1
WriteRegDWORD ${REG_HIVE} "${REG_UNINSTALL}" "NoRepair" 1
WriteRegStr ${REG_HIVE} "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\${FILE_UNINSTALL}$\""
FunctionEnd
; Runs before before everything else during uninstallation
Function "un.onInit"
; Detects if the program is running and asks user to close it
FindWindow $0 "${WINDOW_CLASS}" "${WINDOW_TITLE}"
StrCmp $0 0 notRunning
MessageBox MB_OK|MB_ICONEXCLAMATION "${PROGRAM_NAME} is currently running. Please close it and try again." /SD IDOK
Abort
notRunning:
FunctionEnd
; Deregister uninstaller from Add/Remove panel
Function "un.DeregisterApplication"
DeleteRegKey ${REG_HIVE} "${REG_UNINSTALL}"
FunctionEnd
#--------------------------------
# Installer Sections
; Main installation (Required)
Section "${PROGRAM_NAME} ${PROGRAM_VERSION}" secInstall
SectionIn RO
SetOutPath "$INSTDIR"
SetOverwrite on
File /r /x *.py /x *portable* dist\*.*
; Store installation folder
WriteRegStr ${REG_HIVE} "${REG_INSTALL}" "Install_Dir" "$INSTDIR"
; StartMenu Shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN "Application"
; Sets the context of shell folders
SetShellVarContext ${USER_SHELLCONTEXT}
; Creates shortcut in the StartMenu
CreateDirectory "${SHORTCUT_STARTMENU}"
CreateShortCut "${SHORTCUT_STARTMENU}\${SHORTCUT_EXE}" "$INSTDIR\${FILE_EXE}"
CreateShortCut "${SHORTCUT_STARTMENU}\${SHORTCUT_DEBUG}" "$INSTDIR\${FILE_DEBUG}"
CreateShortCut "${SHORTCUT_STARTMENU}\${SHORTCUT_REPORT}" "${PROGRAM_ISSUE}"
CreateShortCut "${SHORTCUT_STARTMENU}\${SHORTCUT_UNINSTALL}" "$INSTDIR\${FILE_UNINSTALL}"
!insertmacro MUI_STARTMENU_WRITE_END
; Create uninstaller
Call RegisterApplication
WriteUninstaller "$INSTDIR\${FILE_UNINSTALL}"
SectionEnd
/*
; Plug-ins (Optional)
Section "Plug-ins" secPlugins
;Plug-ins here :)
SectionEnd
*/
; Desktop Shortcuts (Optional)
Section "Desktop Shortcuts" secDesktop
; Sets the context of shell folders
SetShellVarContext ${USER_SHELLCONTEXT}
; Creates shortcut on desktop
CreateShortCut "$DESKTOP\${SHORTCUT_EXE}" "$INSTDIR\${FILE_EXE}"
SectionEnd
#--------------------------------
# Uninstaller Sections
; Main uninstallation
Section "un.${PROGRAM_NAME} ${PROGRAM_VERSION}" secUninstall
; Sets the context of shell folders
SetShellVarContext ${USER_SHELLCONTEXT}
; Removes install directory (no data is stored there anyway)
Delete "$INSTDIR\${FILE_UNINSTALL}"
RMDir /r "$INSTDIR"
; Removes Desktop shortcuts
Delete "$DESKTOP\${SHORTCUT_EXE}"
; Removes StartMenu shortcuts
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $StartMenuDir
Delete "${SHORTCUT_STARTMENU}\*.*"
RMDir /r "${SHORTCUT_STARTMENU}"
; Remove uninstaller
Call un.DeregisterApplication
; Removes install registry files
DeleteRegKey /ifempty ${REG_HIVE} "${REG_INSTALL}"
SectionEnd
; Configuration directory (Optional)
Section "un.Profile/Settings" secConfig
; Sets the context of shell folders
SetShellVarContext current
; Removes config folder
RMDir /r "${FILE_CONFIG}"
SectionEnd
; Cleans up old registry files
Section "un.Old Registry Files" secRegistry
${If} ${REG_HIVE} == "HKLM"
DeleteRegKey HKCU "${REG_UNINSTALL}"
DeleteRegKey /ifempty HKCU "${REG_INSTALL}"
${ElseIf} ${REG_HIVE} == "HKCU"
DeleteRegKey HKLM "${REG_UNINSTALL}"
DeleteRegKey /ifempty HKLM "${REG_INSTALL}"
${EndIf}
SectionEnd
#--------------------------------
# Descriptions
; English Language strings
LangString DESC_secInstall ${LANG_ENGLISH} "Install"
;LangString DESC_secPlugins ${LANG_ENGLISH} "Plug-ins"
LangString DESC_secDesktop ${LANG_ENGLISH} "Desktop Shortcuts"
LangString DESC_secUninstall ${LANG_ENGLISH} "Uninstall"
LangString DESC_secConfig ${LANG_ENGLISH} "Configurations"
LangString DESC_secRegistry ${LANG_ENGLISH} "Old Registry Files"
; French Language strings
LangString DESC_secInstall ${LANG_FRENCH} "Installer"
;LangString DESC_secPlugins ${LANG_FRENCH} "Plug-ins (French)"
LangString DESC_secDesktop ${LANG_FRENCH} "Raccourcis Bureau"
LangString DESC_secUninstall ${LANG_FRENCH} "Desinstaller"
LangString DESC_secConfig ${LANG_FRENCH} "Configurations"
LangString DESC_secRegistry ${LANG_FRENCH} "Anciens fichiers du Registre"
; Italian Language strings
LangString DESC_secInstall ${LANG_ITALIAN} "Installa"
;LangString DESC_secPlugins ${LANG_ITALIAN} "Plug-ins (Italian)"
LangString DESC_secDesktop ${LANG_ITALIAN} "Collegamenti sul desktop"
LangString DESC_secUninstall ${LANG_ITALIAN} "Disinstalla"
LangString DESC_secConfig ${LANG_ITALIAN} "Configurazioni"
LangString DESC_secRegistry ${LANG_ITALIAN} "Vecchi file di registro"
; Spanish Language strings
LangString DESC_secInstall ${LANG_SPANISH} "Instalar"
;LangString DESC_secPlugins ${LANG_SPANISH} "Plug-ins (Spanish)"
LangString DESC_secDesktop ${LANG_SPANISH} "Accesos directos de escritorio"
LangString DESC_secUninstall ${LANG_SPANISH} "Desinstalar"
LangString DESC_secConfig ${LANG_SPANISH} "Configuraciones"
LangString DESC_secRegistry ${LANG_SPANISH} "Antiguo archivos de registro"
; Assign language strings to install sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${secInstall} $(DESC_secInstall)
;!insertmacro MUI_DESCRIPTION_TEXT ${secPlugins} $(DESC_secPlugins)
!insertmacro MUI_DESCRIPTION_TEXT ${secDesktop} $(DESC_secDesktop)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
; Assign language strings to uninstall sections
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${secUninstall} $(DESC_secUninstall)
!insertmacro MUI_DESCRIPTION_TEXT ${secConfig} $(DESC_secConfig)
!insertmacro MUI_DESCRIPTION_TEXT ${secRegistry} $(DESC_secRegistry)
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END