forked from emesene/emesene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemesene-installer-MUI.nsi
223 lines (176 loc) · 7.67 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
;--------------------------------
# Compressor Type
SetCompressor /SOLID lzma
;--------------------------------
# Includes
; Modern UI
!include "MUI2.nsh"
;--------------------------------
;Variables
Var StartMenuFolder
;--------------------------------
# Defines
;Program info
!define PROGRAM_NAME "emesene"
!define PROGRAM_VERSION "2.11.6-devel"
!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_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\$StartMenuFolder"
!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 "HKCU" ; HKLM = HKEY_LOCAL_MACHINE | HKCU = HKEY_CURRENT_USER
!define REG_INSTALL "Software\${FILE_DIRECTORY}"
!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FILE_DIRECTORY}"
;--------------------------------
# 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 admin
;--------------------------------
# MUI Settings
!define MUI_ABORTWARNING
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "windows\header.bmp"
!define MUI_ICON "windows\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 Folder 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"
;--------------------------------
# Pages
; Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "GPL"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU "Application" $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
# Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Spanish"
;--------------------------------
;Reserve Files
!insertmacro MUI_RESERVEFILE_LANGDLL
;--------------------------------
# Functions
Function .onInit
; 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
; 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 "dist\*.*"
; Store installation folder
WriteRegStr ${REG_HIVE} "${REG_INSTALL}" "Install_Dir" "$INSTDIR"
; StartMenu Shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
SetShellVarContext current
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
CreateShortCut "$DESKTOP\${SHORTCUT_EXE}" "$INSTDIR\${FILE_EXE}"
SectionEnd
;--------------------------------
# Descriptions
; Language strings
LangString DESC_secInstall ${LANG_ENGLISH} "Install"
LangString DESC_secInstall ${LANG_FRENCH} "Install (French)"
LangString DESC_secInstall ${LANG_ITALIAN} "Install (Italian)"
LangString DESC_secInstall ${LANG_SPANISH} "Install (Spanish)"
LangString DESC_secDesktop ${LANG_ENGLISH} "Desktop Shortcuts"
LangString DESC_secDesktop ${LANG_FRENCH} "Desktop (French)"
LangString DESC_secDesktop ${LANG_ITALIAN} "Desktop (Italian)"
LangString DESC_secDesktop ${LANG_SPANISH} "Desktop (Spanish)"
; Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${secInstall} $(DESC_secInstall)
!insertmacro MUI_DESCRIPTION_TEXT ${secDesktop} $(DESC_secDesktop)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
# Uninstaller Sections
Section "Uninstall"
; 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
SetShellVarContext current
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $StartMenuFolder
Delete "${SHORTCUT_STARTMENU}\*.*"
RMDir /r "${SHORTCUT_STARTMENU}"
; Remove uninstaller
Call un.DeregisterApplication
; Removes install registry files
DeleteRegKey /ifempty ${REG_HIVE} "${REG_INSTALL}"
SectionEnd