-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgherald.nsi
231 lines (170 loc) · 6.37 KB
/
gherald.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
;NSIS Gmail Herald Install Script
;Written by Joost Verburg, updated by Vahan Aghajanyan
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
!include "WordFunc.nsh"
;--------------------------------
;General
; Define version
!define VERSION "0.4"
!define NAME "Gmail Herald"
;Name and file
Name "${NAME}"
OutFile "installation\GmailHerald-Win32-v${VERSION}.exe"
;Default installation folder
InstallDir "$PROGRAMFILES32\Gmail Herald"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\${NAME}" ""
;Request application privileges for Windows Vista
RequestExecutionLevel user
;--------------------------------
;Variables
Var StartMenuFolder
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
; Functions
Function .onInit
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" \
"UninstallString"
StrCmp $R0 "" done
; Get the installed version.
ReadRegStr $R1 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" \
"DisplayVersion"
; Convert version if some characters used, f. e. "0.2.226b"
${VersionConvert} "$R1" "" $R1
; Compare new and installed versions.
${VersionCompare} "${VERSION}" "$R1" "$R2"
; Decide what to do.
IntCmp $R2 1 ask_to_update same_version do_not_update
do_not_update:
MessageBox MB_OK|MB_ICONEXCLAMATION \
"The more recent version $R1 of ${NAME} is already installed."
Abort
same_version:
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${NAME} $R1 is already installed. $\n$\nClick `OK` to reinstall existing \
version or `Cancel` to cancel this upgrade." \
IDOK done
Abort
ask_to_update:
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${NAME} is already installed. $\n$\nClick `OK` to remove the \
previous version $R1 and install new version ${VERSION} or `Cancel` \
to cancel this upgrade." \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
IfErrors no_remove_uninstaller done
;You can either use Delete /REBOOTOK in the uninstaller or add some code
;here to remove the uninstaller. Use a registry key to check
;whether the user has chosen to uninstall. If you are using an uninstaller
;components page, make sure all sections are uninstalled.
no_remove_uninstaller:
done:
FunctionEnd
;--------------------------------
;Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "distrib\License.txt"
; Disabled components page
;!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${NAME}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Gmail Herald" SecDummy
SetOutPath "$INSTDIR"
;ADD YOUR OWN FILES HERE...
File "bin\release\gherald.exe"
File "bin\release\gmaillib.dll"
File "distrib\msvcr90.dll"
File "distrib\msvcp90.dll"
File "distrib\Microsoft.VC90.CRT.manifest"
File "distrib\QtCore4.dll"
File "distrib\QtGui4.dll"
File "distrib\QtNetwork4.dll"
File "distrib\ssleay32.dll"
File "distrib\libeay32.dll"
File "distrib\license.txt"
File "qt.conf"
SetOutPath "$INSTDIR\translations"
File "gherald_ru.qm"
;Store installation folder
WriteRegStr HKCU "Software\${NAME}" "" $INSTDIR
WriteRegStr HKCU "Software\${NAME}" "Version" ${VERSION}
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${NAME}.lnk" "$INSTDIR\gherald.exe"
!insertmacro MUI_STARTMENU_WRITE_END
; Add uninstall information to Add/Remove Programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayName" "${NAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "Publisher" "Vahan Aghajanyan"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayVersion" "${VERSION}"
SectionEnd
;--------------------------------
;Descriptions
;Language strings
;LangString DESC_SecDummy ${LANG_ENGLISH} "${NAME} binary and configuration files."
;Assign language strings to sections
;!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
;!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
;!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
;ADD YOUR OWN FILES HERE...
Delete "$INSTDIR\gherald.exe"
Delete "$INSTDIR\gmaillib.dll"
Delete "$INSTDIR\msvcr90.dll"
Delete "$INSTDIR\msvcp90.dll"
Delete "$INSTDIR\Microsoft.VC90.CRT.manifest"
Delete "$INSTDIR\QtCore4.dll"
Delete "$INSTDIR\QtGui4.dll"
Delete "$INSTDIR\QtNetwork4.dll"
Delete "$INSTDIR\ssleay32.dll"
Delete "$INSTDIR\libeay32.dll"
Delete "$INSTDIR\license.txt"
Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\Uninstall.exe"
Delete "$INSTDIR\settings.ini"
Delete "$INSTDIR\translations\gherald_ru.qm"
; These files could remain from the previous versions of GHerald.
Delete "$INSTDIR\msvcr80.dll"
Delete "$INSTDIR\msvcp80.dll"
Delete "$INSTDIR\Qca2.dll"
RMDir "$INSTDIR\translations"
RMDir "$INSTDIR"
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\${NAME}.lnk"
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
RMDir "$SMPROGRAMS\$StartMenuFolder"
DeleteRegKey /ifempty HKCU "Software\${NAME}"
; Remove uninstall information to Add/Remove Programs
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
SectionEnd