source: trunk/setup.nsi @ 822

Revision 822, 12.0 KB checked in by aspidites, 9 years ago (diff)

Patch by Aspidites:

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