source: trunk/setup.nsi @ 823

Revision 823, 12.6 KB checked in by beliar, 9 years ago (diff)

Patch by Beliar

setup.nsi:

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