forked from Wargus/stargus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstargus.nsi
332 lines (248 loc) · 9.83 KB
/
stargus.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
321
322
323
324
325
326
327
328
329
330
331
332
; _________ __ __
; / _____// |_____________ _/ |______ ____ __ __ ______
; \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
; / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
; /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
; \/ \/ \//_____/ \/
; ______________________ ______________________
; T H E W A R B E G I N S
; Stratagus - A free fantasy real time strategy game engine
;
; stargus.nsi - Windows NSIS Installer for Stargus
; Copyright (C) 2010-2012 Pali Rohár <[email protected]>
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;
;--------------------------------
!ifdef QUIET
!verbose 2
!endif
!define redefine "!insertmacro redefine"
!macro redefine symbol value
!undef ${symbol}
!define ${symbol} "${value}"
!macroend
!include "MUI2.nsh"
;--------------------------------
!define NAME "Stargus"
!define VERSION "2.4.1"
!define VIVERSION "${VERSION}.0"
!define HOMEPAGE "https://github.com/Wargus/stargus"
!define LICENSE "GPL v2"
!define COPYRIGHT "Copyright (c) 1998-2015 by The Stratagus Project and Pali Rohar"
!define STRATAGUS_NAME "Stratagus"
!define STRATAGUS_HOMEPAGE "https://github.com/Wargus/stratagus"
;--------------------------------
!define ICON "stargus.ico"
!define STARGUS "stargus.exe"
!define STARTOOL "startool.exe"
!define MPQLIST "mpqlist.txt"
!define UNINSTALL "uninstall.exe"
!define INSTALLER "${NAME}-${VERSION}.exe"
!define INSTALLDIR "$PROGRAMFILES\${NAME}\"
!define LANGUAGE "English"
; -- have to try and copy these, VS might have put them under (Release|Debug)
!system "powershell -Command $\"& {cp **\${STARTOOL} ${STARTOOL}}$\""
!system "powershell -Command $\"& {cp **\${STARGUS} ${STARGUS}}$\""
!system "powershell -Command $\"& {cp **\${MPQLIST} ${MPQLIST}}$\""
!ifdef x86_64
${redefine} INSTALLER "${NAME}-${VERSION}-x86_64.exe"
${redefine} INSTALLDIR "$PROGRAMFILES64\${NAME}\"
${redefine} NAME "Stargus (64 bit)"
${redefine} STRATAGUS_NAME "Stratagus (64 bit)"
!endif
!define REGKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
!define STRATAGUS_REGKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${STRATAGUS_NAME}"
;--------------------------------
LangString INSTALLER_RUNNING ${LANG_ENGLISH} "${NAME} Installer is already running"
LangString NO_STRATAGUS ${LANG_ENGLISH} "${STRATAGUS_NAME} ${VERSION} is not installed.$\nYou need ${STRATAGUS_NAME} ${VERSION} to run ${NAME}!$\nFirst install ${STRATAGUS_NAME} ${VERSION} from ${STRATAGUS_HOMEPAGE}"
LangString REMOVEPREVIOUS ${LANG_ENGLISH} "Removing previous installation"
LangString REMOVECONFIGURATION ${LANG_ENGLISH} "Removing configuration and data files:"
LangString DESC_REMOVEEXE ${LANG_ENGLISH} "Remove ${NAME} binary executables"
LangString DESC_REMOVECONF ${LANG_ENGLISH} "Remove all other configuration and extracted data files and directories in ${NAME} install directory created by user or ${NAME}"
!ifdef x86_64
LangString x86_64_ONLY ${LANG_ENGLISH} "This version is for 64 bits computers only"
!endif
;--------------------------------
!ifndef NO_DOWNLOAD
!endif
!addplugindir .
;--------------------------------
SetCompressor lzma
Var STARTMENUDIR
!define MUI_ICON "${ICON}"
!define MUI_UNICON "${ICON}"
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_RUN "$INSTDIR\${STARGUS}"
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
!define MUI_UNFINISHPAGE_NOREBOOTSUPPORT
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${REGKEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenu"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "COPYING"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENUDIR
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "${LANGUAGE}"
;--------------------------------
Name "${NAME}"
Icon "${ICON}"
OutFile "${INSTALLER}"
InstallDir "${INSTALLDIR}"
InstallDirRegKey HKLM "${REGKEY}" "InstallLocation"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${NAME} Installer"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "InternalName" "${NAME} Installer"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${COPYRIGHT}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "License" "${LICENSE}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Homepage" "${HOMEPAGE}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "OriginalFilename" "${INSTALLER}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${NAME} Installer"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${VERSION}"
VIProductVersion "${VIVERSION}"
BrandingText "${NAME} - ${VERSION} ${HOMEPAGE}"
ShowInstDetails Show
ShowUnInstDetails Show
XPStyle on
RequestExecutionLevel admin
ReserveFile "${STARTOOL}"
;--------------------------------
Function .onInit
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${NAME}") i .r1 ?e'
Pop $0
StrCmp $0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "$(INSTALLER_RUNNING)"
Abort
!ifdef x86_64
System::Call "kernel32::GetCurrentProcess() i .s"
System::Call "kernel32::IsWow64Process(i s, *i .r0)"
IntCmp $0 0 0 0 +3
MessageBox MB_OK|MB_ICONSTOP "$(x86_64_ONLY)"
Abort
!endif
FunctionEnd
;--------------------------------
Section "-${NAME}" UninstallPrevious
SectionIn RO
ReadRegStr $0 HKLM "${REGKEY}" "InstallLocation"
StrCmp $0 "" +7
DetailPrint "$(REMOVEPREVIOUS)"
SetDetailsPrint none
ExecWait "$0\${UNINSTALL} /S _?=$0"
Delete "$0\${UNINSTALL}"
RMDir $0
SetDetailsPrint lastused
SectionEnd
Section "${NAME}"
SectionIn RO
SetOutPath "$INSTDIR"
File "${STARGUS}"
File "${STARTOOL}"
; -- XXX TODO: include Stratagus and dependencies some better way
File "stratagus.exe"
File "libfluidsynth.dll"
File "libglib-2.0-0.dll"
File "libgthread-2.0-0.dll"
File "lua51.dll"
File "SDL.dll"
!cd ${CMAKE_CURRENT_SOURCE_DIR}
File "${MPQLIST}"
SetOutPath "$INSTDIR\scripts"
File /r "scripts\"
SetOutPath "$INSTDIR\contrib"
File /r "contrib\"
SetOutPath "$INSTDIR"
CreateDirectory "$INSTDIR\graphics"
CreateDirectory "$INSTDIR\graphics\tilesets"
File "/oname=graphics\tilesets\fog.png" "contrib\fog.png"
!cd ${CMAKE_CURRENT_BINARY_DIR}
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$STARTMENUDIR"
CreateShortCut "$SMPROGRAMS\$STARTMENUDIR\${NAME}.lnk" "$INSTDIR\${STARGUS}"
CreateShortCut "$SMPROGRAMS\$STARTMENUDIR\${NAME} (Retro).lnk" "$INSTDIR\${STARGUS} -Z -x 1"
CreateShortCut "$SMPROGRAMS\$STARTMENUDIR\Uninstall.lnk" "$INSTDIR\${UNINSTALL}"
CreateShortcut "$DESKTOP\${NAME}.lnk" "$INSTDIR\${STARGUS}"
!insertmacro MUI_STARTMENU_WRITE_END
WriteRegStr HKLM "${REGKEY}" "DisplayName" "${NAME}"
WriteRegStr HKLM "${REGKEY}" "UninstallString" "$\"$INSTDIR\${UNINSTALL}$\""
WriteRegStr HKLM "${REGKEY}" "QuietUninstallString" "$\"$INSTDIR\${UNINSTALL}$\" /S"
WriteRegStr HKLM "${REGKEY}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "${REGKEY}" "DisplayIcon" "$\"$INSTDIR\${STARGUS}$\",0"
WriteRegStr HKLM "${REGKEY}" "DisplayVersion" "${VERSION}"
WriteRegStr HKLM "${REGKEY}" "HelpLink" "${HOMEPAGE}"
WriteRegStr HKLM "${REGKEY}" "URLUpdateInfo" "${HOMEPAGE}"
WriteRegStr HKLM "${REGKEY}" "URLInfoAbout" "${HOMEPAGE}"
WriteRegDWORD HKLM "${REGKEY}" "NoModify" 1
WriteRegDWORD HKLM "${REGKEY}" "NoRepair" 1
WriteRegStr HKLM "${STRATAGUS_REGKEY}\Games" "${NAME}" "${VERSION}"
WriteUninstaller "$INSTDIR\${UNINSTALL}"
SectionEnd
;--------------------------------
Section "un.${NAME}" Executable
SectionIn RO
Delete "$INSTDIR\${STARGUS}"
Delete "$INSTDIR\${STARTOOL}"
Delete "$INSTDIR\${MPQLIST}"
Delete "$INSTDIR\graphics\tilesets\fog.png"
RMDir "$INSTDIR\graphics\tilesets"
RMDir "$INSTDIR\graphics"
RMDir /r "$INSTDIR\scripts"
RMDir "$INSTDIR"
!insertmacro MUI_STARTMENU_GETFOLDER Application $STARTMENUDIR
Delete "$SMPROGRAMS\$STARTMENUDIR\${NAME}.lnk"
Delete "$SMPROGRAMS\$STARTMENUDIR\${NAME} (Retro).lnk"
Delete "$SMPROGRAMS\$STARTMENUDIR\Uninstall.lnk"
RMDir "$SMPROGRAMS\$STARTMENUDIR"
Delete "$DESKTOP\${NAME}.lnk"
DeleteRegKey HKLM "${REGKEY}"
DeleteRegValue HKLM "${STRATAGUS_REGKEY}\Games" "${NAME}"
ClearErrors
EnumRegValue $0 HKLM "${REGKEY}\Games" 0
IfErrors +2
DeleteRegKey /ifempty HKLM "${STRATAGUS_REGKEY}\Games"
SectionEnd
Section /o "un.Configuration" Configuration
DetailPrint "$(REMOVECONFIGURATION)"
RMDir /r "$INSTDIR"
SectionEnd
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT "${Executable}" "$(DESC_REMOVEEXE)"
!insertmacro MUI_DESCRIPTION_TEXT "${Configuration}" "$(DESC_REMOVECONF)"
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
;--------------------------------
!ifdef UPX
!ifndef UPX_FLAGS
!define UPX_FLAGS "-9"
!else
${redefine} UPX_FLAGS "${UPX_FLAGS} -9"
!endif
!ifdef QUIET
${redefine} UPX_FLAGS "${UPX_FLAGS} -q"
!endif
!packhdr "exehead.tmp" "${UPX} ${UPX_FLAGS} exehead.tmp"
!endif
;!finalize "gpg --armor --sign --detach-sig %1"
;--------------------------------
!ifndef NO_DOWNLOAD
!endif
;--------------------------------