1 | ; To generate the installer (on Linux):
|
---|
2 | ; Do an 'svn export' into a directory called e.g. "export-win32"
|
---|
3 | ; makensis -nocd -dcheckoutpath=export-win32 -drevision=1234 -dversion=0.1.2 -dprefix=0ad-0.1.2-alpha export-win32/source/tools/dist/0ad.nsi
|
---|
4 |
|
---|
5 | SetCompressor /SOLID LZMA
|
---|
6 |
|
---|
7 | !include "MUI2.nsh"
|
---|
8 | !include "LogicLib.nsh"
|
---|
9 | !include "source/tools/dist/FileAssociation.nsh"
|
---|
10 |
|
---|
11 | ;Control whether to include source code (and component selection screen)
|
---|
12 | ;Off by default, uncomment or pass directly to use.
|
---|
13 | !ifndef INCLUDE_SOURCE
|
---|
14 | ;!define INCLUDE_SOURCE 1
|
---|
15 | !endif
|
---|
16 |
|
---|
17 | ;--------------------------------
|
---|
18 | ;General
|
---|
19 |
|
---|
20 | ;Properly display all languages (Installer will not work on Windows 95, 98 or ME!)
|
---|
21 | Unicode true
|
---|
22 |
|
---|
23 | ;Name and file
|
---|
24 | Name "0 A.D."
|
---|
25 | OutFile "${PREFIX}-win32.exe"
|
---|
26 |
|
---|
27 | ;Default installation folder
|
---|
28 | InstallDir "$LOCALAPPDATA\0 A.D. alpha"
|
---|
29 | ; NOTE: we can't use folder names ending in "." because they seemingly get stripped
|
---|
30 |
|
---|
31 | ;Get installation folder from registry if available
|
---|
32 | InstallDirRegKey HKCU "Software\0 A.D." ""
|
---|
33 |
|
---|
34 | RequestExecutionLevel user
|
---|
35 |
|
---|
36 | ;--------------------------------
|
---|
37 | ;Variables
|
---|
38 |
|
---|
39 | Var StartMenuFolder
|
---|
40 |
|
---|
41 | ;--------------------------------
|
---|
42 | ;Interface Settings
|
---|
43 |
|
---|
44 | !define MUI_WELCOMEFINISHPAGE_BITMAP ${CHECKOUTPATH}\build\resources\installer.bmp
|
---|
45 | !define MUI_ICON ${CHECKOUTPATH}\build\resources\ps.ico
|
---|
46 | !define MUI_ABORTWARNING
|
---|
47 | !define MUI_LANGDLL_ALLLANGUAGES
|
---|
48 |
|
---|
49 | ;--------------------------------
|
---|
50 | ;Language Selection Dialog Settings
|
---|
51 |
|
---|
52 | ;Remember the installer language
|
---|
53 | !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
|
---|
54 | !define MUI_LANGDLL_REGISTRY_KEY "Software\0 A.D."
|
---|
55 | !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
|
---|
56 |
|
---|
57 | ;--------------------------------
|
---|
58 | ;Pages
|
---|
59 |
|
---|
60 | !insertmacro MUI_PAGE_WELCOME
|
---|
61 | !ifdef INCLUDE_SOURCE
|
---|
62 | !insertmacro MUI_PAGE_COMPONENTS
|
---|
63 | !endif
|
---|
64 | !insertmacro MUI_PAGE_DIRECTORY
|
---|
65 |
|
---|
66 | ;Start Menu Folder Page Configuration
|
---|
67 | !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
|
---|
68 | !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\0 A.D."
|
---|
69 | !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
|
---|
70 | !define MUI_STARTMENUPAGE_DEFAULTFOLDER "0 A.D. alpha"
|
---|
71 |
|
---|
72 | !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
|
---|
73 |
|
---|
74 | !insertmacro MUI_PAGE_INSTFILES
|
---|
75 |
|
---|
76 | !define MUI_FINISHPAGE_SHOWREADME ""
|
---|
77 | !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
|
---|
78 | !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
|
---|
79 | !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopLink
|
---|
80 | !define MUI_FINISHPAGE_RUN $INSTDIR\binaries\system\pyrogenesis.exe
|
---|
81 | !insertmacro MUI_PAGE_FINISH
|
---|
82 |
|
---|
83 | !insertmacro MUI_UNPAGE_CONFIRM
|
---|
84 | !insertmacro MUI_UNPAGE_INSTFILES
|
---|
85 |
|
---|
86 | ;--------------------------------
|
---|
87 | ;Languages
|
---|
88 | ;Keep in sync with build-archives.sh.
|
---|
89 |
|
---|
90 | !insertmacro MUI_LANGUAGE "English" ; The first language is the default language
|
---|
91 | !insertmacro MUI_LANGUAGE "Asturian"
|
---|
92 | !insertmacro MUI_LANGUAGE "Basque"
|
---|
93 | !insertmacro MUI_LANGUAGE "Catalan"
|
---|
94 | !insertmacro MUI_LANGUAGE "Czech"
|
---|
95 | !insertmacro MUI_LANGUAGE "Dutch"
|
---|
96 | !insertmacro MUI_LANGUAGE "Finnish"
|
---|
97 | !insertmacro MUI_LANGUAGE "French"
|
---|
98 | !insertmacro MUI_LANGUAGE "German"
|
---|
99 | !insertmacro MUI_LANGUAGE "Greek"
|
---|
100 | !insertmacro MUI_LANGUAGE "Hungarian"
|
---|
101 | !insertmacro MUI_LANGUAGE "Indonesian"
|
---|
102 | !insertmacro MUI_LANGUAGE "Italian"
|
---|
103 | !insertmacro MUI_LANGUAGE "Polish"
|
---|
104 | !insertmacro MUI_LANGUAGE "PortugueseBR"
|
---|
105 | !insertmacro MUI_LANGUAGE "Russian"
|
---|
106 | !insertmacro MUI_LANGUAGE "ScotsGaelic"
|
---|
107 | !insertmacro MUI_LANGUAGE "Slovak"
|
---|
108 | !insertmacro MUI_LANGUAGE "Spanish"
|
---|
109 | !insertmacro MUI_LANGUAGE "Swedish"
|
---|
110 | !insertmacro MUI_LANGUAGE "Turkish"
|
---|
111 | !insertmacro MUI_LANGUAGE "Ukrainian"
|
---|
112 |
|
---|
113 | ;--------------------------------
|
---|
114 | ;Installer Sections
|
---|
115 |
|
---|
116 | Section "!Game and data files" GameSection
|
---|
117 |
|
---|
118 | SetOutPath "$INSTDIR"
|
---|
119 | File "${CHECKOUTPATH}\*.txt"
|
---|
120 | File "${CHECKOUTPATH}\source\tools\openlogsfolder\*.*"
|
---|
121 |
|
---|
122 | ; Binaries: exclude debug DLLs and related files
|
---|
123 | SetOutPath "$INSTDIR\binaries\data"
|
---|
124 | File /r /x "public" /x "mod" /x "tests" /x "_test.*" /x "dev.cfg" "${CHECKOUTPATH}\binaries\data\"
|
---|
125 |
|
---|
126 | ; Warning: libraries that end in 'd' need to be added explicitly.
|
---|
127 | ; There are currently none.
|
---|
128 | SetOutPath "$INSTDIR\binaries\system"
|
---|
129 | File /r /x "*d.dll" /x "*_dbg*" /x "*debug*" "${CHECKOUTPATH}\binaries\system\*.dll"
|
---|
130 | File /r /x "*d.pdb" /x "*_dbg*" /x "*debug*" /x "test" "${CHECKOUTPATH}\binaries\system\*.pdb"
|
---|
131 | File /r /x "*_dbg*" /x "*debug*" /x "test" "${CHECKOUTPATH}\binaries\system\*.exe"
|
---|
132 | File /r "${CHECKOUTPATH}\binaries\system\*.bat"
|
---|
133 | File /r "${CHECKOUTPATH}\binaries\system\*.txt"
|
---|
134 |
|
---|
135 | ; Copy logs for writable root
|
---|
136 | SetOutPath "$INSTDIR\binaries"
|
---|
137 | File /r "${CHECKOUTPATH}\binaries\logs"
|
---|
138 |
|
---|
139 | !ifdef ARCHIVE_PATH
|
---|
140 | SetOutPath "$INSTDIR\binaries\data\mods\"
|
---|
141 | File /r "${ARCHIVE_PATH}"
|
---|
142 | !else
|
---|
143 | SetOutPath "$INSTDIR\binaries\data\mods\public"
|
---|
144 | File "${CHECKOUTPATH}\binaries\data\mods\public\public.zip"
|
---|
145 | File "${CHECKOUTPATH}\binaries\data\mods\public\mod.json"
|
---|
146 | SetOutPath "$INSTDIR\binaries\data\mods\mod"
|
---|
147 | File "${CHECKOUTPATH}\binaries\data\mods\mod\mod.zip"
|
---|
148 | !endif
|
---|
149 |
|
---|
150 | ; Create shortcuts in the root installation folder.
|
---|
151 | ; Keep synched with the start menu shortcuts.
|
---|
152 | SetOutPath "$INSTDIR"
|
---|
153 | CreateShortCut "$INSTDIR\0 A.D..lnk" "$INSTDIR\binaries\system\pyrogenesis.exe" ""
|
---|
154 | CreateShortCut "$INSTDIR\Map editor.lnk" "$INSTDIR\binaries\system\pyrogenesis.exe" "-editor" "$INSTDIR\binaries\data\tools\atlas\icons\ScenarioEditor.ico"
|
---|
155 | WriteINIStr "$INSTDIR\Web site.url" "InternetShortcut" "URL" "https://play0ad.com/"
|
---|
156 |
|
---|
157 | ;Store installation folder
|
---|
158 | WriteRegStr SHCTX "Software\0 A.D." "" $INSTDIR
|
---|
159 |
|
---|
160 | ;Create uninstaller
|
---|
161 | WriteUninstaller "$INSTDIR\Uninstall.exe"
|
---|
162 |
|
---|
163 | ;Add uninstall information
|
---|
164 | WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "DisplayName" "0 A.D."
|
---|
165 | WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "DisplayVersion" "${VERSION}"
|
---|
166 | WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "VersionMajor" 0
|
---|
167 | WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "VersionMinor" ${REVISION}
|
---|
168 | WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "Publisher" "Wildfire Games"
|
---|
169 | WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "DisplayIcon" "$\"$INSTDIR\binaries\system\pyrogenesis.exe$\""
|
---|
170 | WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "InstallLocation" "$\"$INSTDIR$\""
|
---|
171 | WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
|
---|
172 | WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S"
|
---|
173 | WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "URLInfoAbout" "https://play0ad.com"
|
---|
174 | WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "NoModify" 1
|
---|
175 | WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "NoRepair" 1
|
---|
176 |
|
---|
177 | !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
---|
178 |
|
---|
179 | ;Create shortcuts
|
---|
180 | CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
---|
181 | SetOutPath "$INSTDIR\binaries\system" ;Set working directory of shortcuts
|
---|
182 | CreateShortCut "$SMPROGRAMS\$StartMenuFolder\0 A.D..lnk" "$INSTDIR\binaries\system\pyrogenesis.exe" ""
|
---|
183 | CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Map editor.lnk" "$INSTDIR\binaries\system\pyrogenesis.exe" "-editor" "$INSTDIR\binaries\data\tools\atlas\icons\ScenarioEditor.ico"
|
---|
184 | SetOutPath "$INSTDIR"
|
---|
185 | CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Open logs folder.lnk" "$INSTDIR\OpenLogsFolder.bat"
|
---|
186 | CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
---|
187 | WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Web site.url" "InternetShortcut" "URL" "https://play0ad.com/"
|
---|
188 |
|
---|
189 | !insertmacro MUI_STARTMENU_WRITE_END
|
---|
190 |
|
---|
191 | ;Register .pyromod file association
|
---|
192 | ${registerExtension} "$INSTDIR\binaries\system\pyrogenesis.exe" ".pyromod" "Pyrogenesis mod"
|
---|
193 |
|
---|
194 | SectionEnd
|
---|
195 |
|
---|
196 | !ifdef INCLUDE_SOURCE
|
---|
197 | Section /o "Source code" SourceSection
|
---|
198 |
|
---|
199 | SetOutPath "$INSTDIR"
|
---|
200 | File /r "${CHECKOUTPATH}\source\"
|
---|
201 | File /r "${CHECKOUTPATH}\docs\"
|
---|
202 | File /r "${CHECKOUTPATH}\build"
|
---|
203 | File /r "${CHECKOUTPATH}\libraries"
|
---|
204 |
|
---|
205 | SectionEnd
|
---|
206 | !endif
|
---|
207 |
|
---|
208 | ;--------------------------------
|
---|
209 | ;Installer Functions
|
---|
210 |
|
---|
211 | Function .onInit
|
---|
212 |
|
---|
213 | !insertmacro MUI_LANGDLL_DISPLAY
|
---|
214 |
|
---|
215 | ReadRegStr $R0 SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D." "UninstallString"
|
---|
216 | StrCmp $R0 "" done
|
---|
217 |
|
---|
218 | MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
|
---|
219 | "0 A.D. is already installed.$\n$\nClick $\"OK$\" to remove the previous version, or $\"Cancel$\" to stop this installation." \
|
---|
220 | IDOK uninst
|
---|
221 | Abort
|
---|
222 |
|
---|
223 | ;Run the uninstaller
|
---|
224 | uninst:
|
---|
225 | ClearErrors
|
---|
226 | ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
|
---|
227 |
|
---|
228 | done:
|
---|
229 |
|
---|
230 | FunctionEnd
|
---|
231 |
|
---|
232 | Function CreateDesktopLink
|
---|
233 | CreateShortCut "$DESKTOP\0 A.D..lnk" "$INSTDIR\binaries\system\pyrogenesis.exe" ""
|
---|
234 | FunctionEnd
|
---|
235 |
|
---|
236 | ;--------------------------------
|
---|
237 | ;Descriptions
|
---|
238 |
|
---|
239 | !ifdef INCLUDE_SOURCE
|
---|
240 |
|
---|
241 | ;Assign descriptions to sections
|
---|
242 | !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
---|
243 | !insertmacro MUI_DESCRIPTION_TEXT ${GameSection} "0 A.D. game executable and data."
|
---|
244 | !insertmacro MUI_DESCRIPTION_TEXT ${SourceSection} "Source code and build tools."
|
---|
245 | !insertmacro MUI_FUNCTION_DESCRIPTION_END
|
---|
246 |
|
---|
247 | !endif
|
---|
248 |
|
---|
249 | ;--------------------------------
|
---|
250 | ;Uninstaller Section
|
---|
251 |
|
---|
252 | Section "Uninstall"
|
---|
253 |
|
---|
254 | RMDir /r "$INSTDIR\binaries"
|
---|
255 | !ifdef INCLUDE_SOURCE
|
---|
256 | RMDir /r "$INSTDIR\source"
|
---|
257 | RMDir /r "$INSTDIR\docs"
|
---|
258 | RMDir /r "$INSTDIR\build"
|
---|
259 | RMDir /r "$INSTDIR\libraries"
|
---|
260 | !endif
|
---|
261 | Delete "$INSTDIR\*.txt"
|
---|
262 | Delete "$INSTDIR\*.bat"
|
---|
263 | Delete "$INSTDIR\OpenLogsFolder.vbs"
|
---|
264 | Delete "$INSTDIR\Map editor.lnk"
|
---|
265 | Delete "$INSTDIR\0 A.D..lnk"
|
---|
266 | Delete "$INSTDIR\Web site.url"
|
---|
267 | Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
|
---|
268 | RMDir /REBOOTOK "$INSTDIR"
|
---|
269 |
|
---|
270 | RMDir /r "$LOCALAPPDATA\0ad\cache"
|
---|
271 | RMDir /r "$LOCALAPPDATA\0ad\logs"
|
---|
272 | ; leave the other directories (screenshots, config files, etc)
|
---|
273 |
|
---|
274 | Delete "$DESKTOP\0 A.D..lnk"
|
---|
275 |
|
---|
276 | !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
|
---|
277 |
|
---|
278 | Delete "$SMPROGRAMS\$StartMenuFolder\Open logs folder.lnk"
|
---|
279 | Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
|
---|
280 | Delete "$SMPROGRAMS\$StartMenuFolder\Map editor.lnk"
|
---|
281 | Delete "$SMPROGRAMS\$StartMenuFolder\0 A.D..lnk"
|
---|
282 | Delete "$SMPROGRAMS\$StartMenuFolder\Web site.url"
|
---|
283 | RMDir "$SMPROGRAMS\$StartMenuFolder"
|
---|
284 |
|
---|
285 | DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\0 A.D."
|
---|
286 | DeleteRegKey /ifempty SHCTX "Software\0 A.D."
|
---|
287 |
|
---|
288 | ;Unregister .pyromod file association
|
---|
289 | ${unregisterExtension} ".pyromod" "Pyrogenesis mod"
|
---|
290 |
|
---|
291 | SectionEnd
|
---|
292 |
|
---|
293 | ;--------------------------------
|
---|
294 | ;Uninstaller Functions
|
---|
295 |
|
---|
296 | Function un.onInit
|
---|
297 |
|
---|
298 | !insertmacro MUI_UNGETLANGUAGE
|
---|
299 |
|
---|
300 | FunctionEnd
|
---|