Mercurial > parpg-core
comparison nsis/setup.nsi @ 0:1fd2201f5c36
Initial commit of parpg-core.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Sat, 14 May 2011 01:12:35 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1fd2201f5c36 |
---|---|
1 ############################################################### | |
2 #NSIS script for PARPG | |
3 # | |
4 # Non standard plugins | |
5 # | |
6 # ZipDLL : http://nsis.sourceforge.net/ZipDLL_plug-in | |
7 # Please note the install instructions | |
8 # | |
9 # Advanced Uninstall Log 2 | |
10 # Header for that is in the same directory as this script - AdvUninstLog2.nsh | |
11 # | |
12 # Python module installer | |
13 # Header for that is in the same directory as this script - python-module.nsh | |
14 # | |
15 !define PRODUCT_NAME "PARPG Techdemo 2" | |
16 !define PRODUCT_VERSION "SVN trunk r788" | |
17 !define PRODUCT_PUBLISHER "PARPG Development Team" | |
18 !define PRODUCT_WEB_SITE "http://www.parpg.net/" | |
19 !define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" | |
20 !define INSTDIR_REG_ROOT "HKLM" | |
21 | |
22 !define PARPG_DIR "game" | |
23 !define EXEC_SCRIPT_NAME "parpg-run.py" | |
24 # MUI 1.67 compatible ------ | |
25 !include "MUI2.nsh" | |
26 !include "AdvUninstLog2.nsh" | |
27 !include "python-module.nsh" | |
28 !include "download_mirror.nsh" | |
29 | |
30 # MUI Settings | |
31 !define MUI_ABORTWARNING | |
32 !define MUI_ICON "${PARPG_DIR}\gui\icons\window_icon.ico" | |
33 !define MUI_UNICON "${PARPG_DIR}\gui\icons\window_icon.ico" | |
34 | |
35 # Welcome page | |
36 !insertmacro MUI_PAGE_WELCOME | |
37 !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesCheck | |
38 !insertmacro MUI_PAGE_COMPONENTS | |
39 | |
40 # License page | |
41 !insertmacro MUI_PAGE_LICENSE "${PARPG_DIR}\license\gpl30.license" | |
42 # Instfiles page Externals | |
43 !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesExternals | |
44 !insertmacro MUI_PAGE_INSTFILES | |
45 # Directory page PARPG | |
46 !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesPARPG | |
47 !insertmacro MUI_PAGE_DIRECTORY | |
48 !insertmacro PAGE_PYTHON_MODULE | |
49 # Instfiles page PARPG | |
50 !insertmacro MUI_PAGE_INSTFILES | |
51 | |
52 | |
53 # Finish page | |
54 !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt" | |
55 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE DeleteSectionsINI | |
56 !insertmacro MUI_PAGE_FINISH | |
57 | |
58 # Uninstaller pages | |
59 !insertmacro MUI_UNPAGE_INSTFILES | |
60 | |
61 # Language files | |
62 !insertmacro MUI_LANGUAGE "English" | |
63 | |
64 # ZipFile Support | |
65 !include "ZipDLL.nsh" | |
66 | |
67 # MUI end ------ | |
68 | |
69 RequestExecutionLevel admin #For Vista. Admin is needed to install in program files directory | |
70 | |
71 Name "${PRODUCT_NAME}" | |
72 OutFile "parpg_td2_r877_win32.exe" | |
73 InstallDir "$PROGRAMFILES\PARPG" | |
74 ShowInstDetails show | |
75 ShowUnInstDetails show | |
76 | |
77 !insertmacro UNATTENDED_UNINSTALL | |
78 | |
79 #Externals, at least Python, have to be installed first | |
80 SectionGroup Externals Externals | |
81 #---------- DOWNLOAD PYTHON ------- | |
82 Section "ActivePython (required)" Python | |
83 DetailPrint "Downloading Python" | |
84 NSISdl::download http://downloads.activestate.com/ActivePython/releases/2.7.1.4/ActivePython-2.7.1.4-win32-x86.msi $TEMP\pysetup.msi | |
85 Pop $R0 #Get the return value | |
86 StrCmp $R0 "success" +3 | |
87 MessageBox MB_OK "Failed to download Python installer: $R0" | |
88 Quit | |
89 | |
90 DetailPrint "Installing Python" | |
91 ExecWait '"msiexec" /i "$TEMP\pysetup.msi"' | |
92 | |
93 DetailPrint "Deleting Python installer" | |
94 Delete $TEMP\pysetup.msi | |
95 SectionEnd | |
96 | |
97 #------------ PyYAML -------------- | |
98 Section "PyYAML (required)" PyYAML | |
99 DetailPrint "Downloading PyYAML" | |
100 NSISdl::download http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.7.exe $TEMP\pyaml_setup.exe | |
101 Pop $R0 #Get the return value | |
102 StrCmp $R0 "success" +3 | |
103 MessageBox MB_OK "Failed to download PyYAML installer: $R0" | |
104 Quit | |
105 | |
106 DetailPrint "Installing PyYAML" | |
107 ExecWait "$TEMP\pyaml_setup.exe" | |
108 | |
109 DetailPrint "Deleting PyYAML installer" | |
110 Delete "$TEMP\PyYAML_setup.exe" | |
111 SectionEnd | |
112 | |
113 #----------- OPEN AL -------------- | |
114 Section "OpenAL (required)" OpenAL | |
115 SetDetailsPrint textonly | |
116 NSISdl::download http://connect.creativelabs.com/openal/Downloads/oalinst.zip $TEMP\oalinst.zip | |
117 | |
118 DetailPrint "Extracting OpenAL archive" | |
119 !insertmacro ZIPDLL_EXTRACT $TEMP\oalinst.zip $TEMP oalinst.exe | |
120 | |
121 DetailPrint "Installing OpenAL" | |
122 ExecWait "$TEMP\oalinst.exe" | |
123 | |
124 DetailPrint "Deleting OpenAL installer" | |
125 Delete "$TEMP\oalinst.exe" | |
126 Delete "$TEMP\oalinst.zip" | |
127 SectionEnd | |
128 | |
129 Section "FIFE (required)" FIFE | |
130 DetailPrint "Downloading FIFE installer" | |
131 Push "http://puzzle.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
132 Push "http://mesh.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
133 Push "http://aarnet.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
134 Push "http://cdnetworks-us-1.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
135 Push "http://ovh.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
136 Push "http://ignum.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
137 Push "http://tenet.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
138 Push "http://jaist.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
139 Push "http://garr.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
140 Push "http://cdnetworks-kr-2.dl.sourceforge.net/project/fife/active/packages/FIFE-0.3.2r2_installer_win32.exe" | |
141 Push 10 | |
142 Push "$TEMP\FIFE-0.3.2r2_installer_win32.exe" | |
143 Call DownloadFromRandomMirror | |
144 Pop $0 | |
145 | |
146 StrCmp $0 "cancel" 0 +3 | |
147 MessageBox MB_OK "Download canceled" | |
148 Goto End | |
149 StrCmp $0 "success" 0 +3 | |
150 DetailPrint "Installing FIFE" | |
151 ExecWait "$TEMP\FIFE-0.3.2r2_installer_win32.exe" | |
152 Goto End | |
153 MessageBox MB_OK "Error $0" | |
154 End: | |
155 DetailPrint "Deleting FIFE Installer" | |
156 Delete "$TEMP\FIFE-0.3.2r2_installer_win32.exe" | |
157 SectionEnd | |
158 | |
159 #--------- SECTION END ------------ | |
160 SectionGroupEnd | |
161 | |
162 SectionGroup PARPG PARPG | |
163 Section "PARPG Module" PARPG-module | |
164 SectionIn RO | |
165 DetailPrint "Installing PARPG python package" | |
166 SetOutPath "$PythonPath\lib\site-packages" | |
167 SetOverwrite try | |
168 FILE /r /x *svn* "${PARPG_DIR}\parpg" | |
169 SetAutoClose true | |
170 SectionEnd | |
171 #------------ Main. Packages PARPG code -------------- | |
172 Section "PARPG Datafiles" PARPG-data | |
173 SectionIn RO | |
174 SetOverwrite try | |
175 | |
176 # get all the core PARPG files | |
177 SetOutPath "$INSTDIR\dialogue" | |
178 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
179 FILE /r /x *svn* "${PARPG_DIR}\dialogue\" | |
180 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
181 SetOutPath "$INSTDIR\fonts" | |
182 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
183 FILE /r /x *svn* "${PARPG_DIR}\fonts\" | |
184 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
185 SetOutPath "$INSTDIR\gui" | |
186 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
187 FILE /r /x *svn* "${PARPG_DIR}\gui\" | |
188 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
189 SetOutPath "$INSTDIR\maps" | |
190 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
191 FILE /r /x *svn* "${PARPG_DIR}\maps\" | |
192 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
193 SetOutPath "$INSTDIR\music" | |
194 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
195 FILE /r /x *svn* "${PARPG_DIR}\music\" | |
196 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
197 SetOutPath "$INSTDIR\objects" | |
198 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
199 FILE /r /x *svn* "${PARPG_DIR}\objects\" | |
200 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
201 SetOutPath "$INSTDIR\quests" | |
202 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
203 FILE /r /x *svn* "${PARPG_DIR}\quests\" | |
204 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
205 SetOutPath "$INSTDIR\character_scripts" | |
206 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
207 FILE /r /x *svn* "${PARPG_DIR}\character_scripts\" | |
208 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
209 SetOutPath "$INSTDIR\license" | |
210 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
211 FILE /r /x *svn* "${PARPG_DIR}\license\" | |
212 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
213 | |
214 SetOutPath "$INSTDIR" | |
215 !insertmacro UNINSTALL.LOG_OPEN_INSTALL | |
216 FILE "${PARPG_DIR}\README" | |
217 FILE "${PARPG_DIR}\AUTHORS" | |
218 FILE "${PARPG_DIR}\run.py" | |
219 FILE "${PARPG_DIR}\system.cfg" | |
220 | |
221 RENAME "README" "README.txt" | |
222 RENAME "AUTHORS" "AUTHORS.txt" | |
223 RENAME "run.py" "${EXEC_SCRIPT_NAME}" | |
224 | |
225 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL | |
226 SetAutoClose true | |
227 SectionEnd | |
228 # Tools not included as they aren't ready for distribution | |
229 #Section -Tools | |
230 #SetOutPath "$INSTDIR\tools\map_editor" | |
231 #SetOverwrite try | |
232 #SectionEnd | |
233 | |
234 Section "-Additional" -AdditionalIcons | |
235 SectionIn RO | |
236 #avoid shortcuts headaches on vista by doing everything in the all users start menu | |
237 SetShellVarContext all | |
238 SetOutPath $INSTDIR | |
239 WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" | |
240 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" | |
241 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" | |
242 CreateShortcut '$SMPROGRAMS\${PRODUCT_NAME}\uninstall.lnk' '${UNINST_EXE}' | |
243 SetOutPath "$INSTDIR" #this makes the following shortcut run in the installed directory | |
244 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\PARPG.lnk" "$INSTDIR\${EXEC_SCRIPT_NAME}" | |
245 SectionEnd | |
246 | |
247 Section "-Post" -Post | |
248 SectionIn RO | |
249 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayName" "$(^Name)" | |
250 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "UninstallString" "${UNINST_EXE}" | |
251 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayIcon" "$INSTDIR\gui\icons\window_icon.ico" | |
252 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" | |
253 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" | |
254 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" | |
255 SectionEnd | |
256 SectionGroupEnd | |
257 | |
258 ##=========================================================================== | |
259 ## Settings | |
260 ##=========================================================================== | |
261 | |
262 !define PARPG_StartIndex ${PARPG} | |
263 !define PARPG_EndIndex ${-Post} | |
264 | |
265 !define EXT_StartIndex ${Externals} | |
266 !define EXT_EndIndex ${Fife} | |
267 | |
268 Function .OnInit | |
269 !insertmacro UNINSTALL.LOG_PREPARE_INSTALL | |
270 !insertmacro SetSectionFlag ${PARPG} ${SF_RO} | |
271 StrCpy $PythonPath "" | |
272 StrCpy $PythonVer "Custom" | |
273 InitPluginsDir | |
274 FunctionEnd | |
275 | |
276 ## If user goes back to this page from 1st Directory page | |
277 ## we need to put the sections back to how they were before | |
278 Var IfBack | |
279 Function SelectFilesCheck | |
280 StrCmp $IfBack 1 0 NoCheck | |
281 Call ResetFiles | |
282 NoCheck: | |
283 FunctionEnd | |
284 | |
285 Function IsExternalsSelected | |
286 Push $R0 | |
287 Push $R1 | |
288 | |
289 StrCpy $R0 ${EXT_StartIndex} # Group 2 start | |
290 | |
291 Loop: | |
292 IntOp $R0 $R0 + 1 | |
293 SectionGetFlags $R0 $R1 # Get section flags | |
294 IntOp $R1 $R1 & ${SF_SELECTED} | |
295 StrCmp $R1 ${SF_SELECTED} 0 +3 # If section is selected, done | |
296 StrCpy $R0 1 | |
297 Goto Done | |
298 StrCmp $R0 ${EXT_EndIndex} 0 Loop | |
299 | |
300 Done: | |
301 Pop $R1 | |
302 Exch $R0 | |
303 FunctionEnd | |
304 | |
305 ## Here we are selecting first sections to install | |
306 ## by unselecting all the others! | |
307 Function SelectFilesExternals | |
308 | |
309 # If user clicks Back now, we will know to reselect Group 2's sections for | |
310 # Components page | |
311 StrCpy $IfBack 1 | |
312 | |
313 # We need to save the state of the Group 2 Sections | |
314 # for the next InstFiles page | |
315 Push $R0 | |
316 Push $R1 | |
317 | |
318 StrCpy $R0 ${PARPG_StartIndex} # Group 2 start | |
319 | |
320 Loop: | |
321 IntOp $R0 $R0 + 1 | |
322 SectionGetFlags $R0 $R1 # Get section flags | |
323 WriteINIStr "$PLUGINSDIR\sections.ini" Sections $R0 $R1 # Save state | |
324 !insertmacro UnselectSection $R0 # Then unselect it | |
325 StrCmp $R0 ${PARPG_EndIndex} 0 Loop | |
326 | |
327 # Don't install prog 1? | |
328 Call IsExternalsSelected | |
329 Pop $R0 | |
330 StrCmp $R0 1 +4 | |
331 Pop $R1 | |
332 Pop $R0 | |
333 Abort | |
334 | |
335 Pop $R1 | |
336 Pop $R0 | |
337 FunctionEnd | |
338 | |
339 ## Here we need to unselect all Group 1 sections | |
340 ## and then re-select those in Group 2 (that the user had selected on | |
341 ## Components page) | |
342 Function SelectFilesPARPG | |
343 Push $R0 | |
344 Push $R1 | |
345 | |
346 StrCpy $R0 ${EXT_StartIndex} # Group 1 start | |
347 | |
348 Loop: | |
349 IntOp $R0 $R0 + 1 | |
350 !insertmacro UnselectSection $R0 # Unselect it | |
351 StrCmp $R0 ${EXT_EndIndex} 0 Loop | |
352 | |
353 Call ResetFiles | |
354 | |
355 Pop $R1 | |
356 Pop $R0 | |
357 FunctionEnd | |
358 | |
359 ## This will set all sections to how they were on the components page | |
360 ## originally | |
361 Function ResetFiles | |
362 Push $R0 | |
363 Push $R1 | |
364 | |
365 StrCpy $R0 ${PARPG_StartIndex} # Group 2 start | |
366 | |
367 Loop: | |
368 IntOp $R0 $R0 + 1 | |
369 ReadINIStr "$R1" "$PLUGINSDIR\sections.ini" Sections $R0 # Get sec flags | |
370 SectionSetFlags $R0 $R1 # Re-set flags for this sec | |
371 StrCmp $R0 ${PARPG_EndIndex} 0 Loop | |
372 | |
373 Pop $R1 | |
374 Pop $R0 | |
375 FunctionEnd | |
376 | |
377 ## Here we are deleting the temp INI file at the end of installation | |
378 Function DeleteSectionsINI | |
379 FlushINI "$PLUGINSDIR\Sections.ini" | |
380 Delete "$PLUGINSDIR\Sections.ini" | |
381 FunctionEnd | |
382 | |
383 Function .onInstSuccess | |
384 !insertmacro UNINSTALL.LOG_UPDATE_INSTALL | |
385 FunctionEnd | |
386 | |
387 Function un.onUninstSuccess | |
388 HideWindow | |
389 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." | |
390 FunctionEnd | |
391 | |
392 Function un.onInit | |
393 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 | |
394 Abort | |
395 FunctionEnd | |
396 | |
397 Section Uninstall | |
398 #avoid shortcuts headaches on vista by doing everything in the all users start menu | |
399 SetShellVarContext all | |
400 | |
401 # remove data files | |
402 !insertmacro UNINSTALL.NEW_UNINSTALL "$INSTDIR" | |
403 | |
404 Delete "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" | |
405 Delete "$SMPROGRAMS\${PRODUCT_NAME}\PARPG.lnk" | |
406 Delete "$SMPROGRAMS\${PRODUCT_NAME}\uninstall.lnk" | |
407 RmDir "$SMPROGRAMS\${PRODUCT_NAME}" | |
408 | |
409 Delete "$INSTDIR\*.log" | |
410 Delete "$INSTDIR\system.cfg" | |
411 Delete "$INSTDIR\${PRODUCT_NAME}.url" | |
412 | |
413 RMDir "$INSTDIR" | |
414 | |
415 # Remove shortcuts | |
416 RMDir /r "$SMPROGRAMS\PARPG" | |
417 | |
418 # Remove Registry keys | |
419 DeleteRegKey ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" | |
420 SetAutoClose true | |
421 SectionEnd | |
422 | |
423 | |
424 LangString DESC_PARPG ${LANG_ENGLISH} "PARPG - Techdemo 1 SVN r788" | |
425 LangString DESC_Python ${LANG_ENGLISH} "ActivePython 2.6.4.8 - Required to run PARPG. Requires an active internet connection to install." | |
426 LangString DESC_FIFE ${LANG_ENGLISH} "FIFE-0.3.2r2 - Required to run PARPG." | |
427 LangString DESC_PyYAML ${LANG_ENGLISH} "PyYAML 3.09 - Required Python Module. Requires an active internet connection to install." | |
428 LangString DESC_OpenAL ${LANG_ENGLISH} "OpenAL - Required for sound effects and music playback." | |
429 | |
430 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN | |
431 !insertmacro MUI_DESCRIPTION_TEXT ${PARPG} $(DESC_PARPG) | |
432 !insertmacro MUI_DESCRIPTION_TEXT ${Python} $(DESC_Python) | |
433 !insertmacro MUI_DESCRIPTION_TEXT ${FIFE} $(DESC_FIFE) | |
434 !insertmacro MUI_DESCRIPTION_TEXT ${PyYAML} $(DESC_PyYAML) | |
435 !insertmacro MUI_DESCRIPTION_TEXT ${OpenAL} $(DESC_OpenAL) | |
436 !insertmacro MUI_FUNCTION_DESCRIPTION_END |