OSDN Git Service

Alignment tweak in settings
[radegast/radegast.git] / Radegast / radegast.nsi
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
2 ;; Includes\r
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
4 !include "LogicLib.nsh"\r
5 !include WordFunc.nsh\r
6 !include "FileFunc.nsh"\r
7 !insertmacro VersionCompare\r
8 \r
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
10 ;; Compiler flags\r
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
12 SetOverwrite on                         ; overwrite files\r
13 SetCompress auto                        ; compress iff saves space\r
14 SetCompressor /solid lzma       ; compress whole installer as one block\r
15 SetDatablockOptimize off        ; only saves us 0.1%, not worth it\r
16 XPStyle on                  ; add an XP manifest to the installer\r
17 RequestExecutionLevel admin     ; on Vista we must be admin because we write to Program Files\r
18 \r
19 LangString LanguageCode ${LANG_ENGLISH}  "en"\r
20 !define DOTNET_URL "http://download.microsoft.com/download/0/6/1/061F001C-8752-4600-A198-53214C69B51F/dotnetfx35setup.exe"\r
21 !define MSI31_URL "http://download.microsoft.com/download/1/4/7/147ded26-931c-4daf-9095-ec7baf996f46/WindowsInstaller-KB893803-v2-x86.exe"\r
22 \r
23 !define APPNAME "Radegast"\r
24 !define VERSION "2.19"\r
25 !define MAINEXEC "${APPNAME}.exe"\r
26 !define DOTNET_VERSION "3.5"\r
27 !define VOICEPACK "RadegastVoicepack-1.0.exe"\r
28 !define UNINST_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"\r
29 \r
30 ; The name of the installer\r
31 Name "${APPNAME}"\r
32 \r
33 ; The file to write\r
34 OutFile "..\${APPNAME}-${VERSION}-installer.exe"\r
35 \r
36 ; The default installation directory\r
37 InstallDir "$PROGRAMFILES\${APPNAME}"\r
38 \r
39 ; Registry key to check for directory (so if you install again, it will \r
40 ; overwrite the old one automatically)\r
41 InstallDirRegKey HKLM "Software\${APPNAME}" "Install_Dir"\r
42 \r
43 ;--------------------------------\r
44 \r
45 LicenseText "Please review the license terms before installing Radegast"\r
46 LicenseData "license.txt"\r
47 \r
48 ; Pages\r
49 Page license\r
50 Page components\r
51 Page directory\r
52 Page instfiles\r
53 \r
54 UninstPage uninstConfirm\r
55 UninstPage instfiles\r
56 \r
57 ;--------------------------------\r
58 ; Check MSI and .NET\r
59 Section ".NET check"\r
60   ; Comment out below if not mandatory\r
61   ; SectionIn RO\r
62 \r
63   ; Set output path to the installation directory.\r
64   SetOutPath $TEMP\r
65   ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" "SP"\r
66   ${If} $0 < "1"\r
67         goto CheckMSI\r
68   ${EndIf}\r
69   goto NewDotNET\r
70 \r
71   CheckMSI:\r
72   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
73   ;                               MSI                                          ;\r
74   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
75   GetDLLVersion "$SYSDIR\msi.dll" $R0 $R1\r
76   IntOp $R2 $R0 / 0x00010000 ; $R2 now contains major version\r
77   IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version\r
78   IntOp $R4 $R1 / 0x00010000 ; $R4 now contains release\r
79   IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build\r
80   StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"\r
81   DetailPrint "MSI version $0"\r
82  \r
83   ${If} $R2 < '3'\r
84     goto AskMSI\r
85   ${ElseIf} $R2 == '3'\r
86     DetailPrint "MSI3.x"\r
87         ${If} $R3 < '1'\r
88           goto AskMSI\r
89     ${EndIf}\r
90   ${Else}\r
91     DetailPrint "MSI3.1 already installed"\r
92     goto DownloadDotNET\r
93   ${EndIf}\r
94 \r
95   AskMSI:\r
96     SetOutPath "$TEMP"\r
97     SetOverwrite on\r
98  \r
99     MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \\r
100     "Your MSI version: $0.$\nRequired Version: 3.1 or greater.$\nDownload MSI version from www.microsoft.com?" \\r
101     /SD IDYES IDYES DownloadMSI IDNO DownloadDotNET\r
102     goto GiveUpDotNET ;IDCANCEL\r
103  \r
104   DownloadMSI:\r
105     DetailPrint "Beginning download of MSI3.1."\r
106     NSISDL::download ${MSI31_URL} "$TEMP\WindowsInstaller-KB893803-v2-x86.exe"\r
107     DetailPrint "Completed download."\r
108     Pop $0\r
109     ${If} $0 == "cancel"\r
110       MessageBox MB_YESNO|MB_ICONEXCLAMATION \\r
111       "Download cancelled.  Continue Installation?" \\r
112       IDYES DownloadDotNET IDNO GiveUpDotNET\r
113     ${ElseIf} $0 != "success"\r
114       MessageBox MB_YESNO|MB_ICONEXCLAMATION \\r
115       "Download failed:$\n$0$\n$\nContinue Installation?" \\r
116       IDYES DownloadDotNET IDNO GiveUpDotNET\r
117     ${EndIf}\r
118     DetailPrint "Pausing installation while downloaded MSI3.1 installer runs."\r
119     ExecWait '$TEMP\WindowsInstaller-KB893803-v2-x86.exe /quiet /norestart' $0\r
120     DetailPrint "Completed MSI3.1 install/update. Exit code = '$0'. Removing MSI3.1 installer."\r
121     Delete "$TEMP\WindowsInstaller-KB893803-v2-x86.exe"\r
122     DetailPrint "MSI3.1 installer removed."\r
123     goto DownloadDotNET\r
124 \r
125   DownloadDotNET:\r
126     DetailPrint "Beginning download of .NET 3.5SP1."\r
127     NSISdl::download /TIMEOUT=30000 ${DOTNET_URL} "$TEMP\dotnetfx35.exe" /END\r
128     Pop $0\r
129     DetailPrint "Result: $0"\r
130     StrCmp $0 "success" InstallDotNet\r
131     StrCmp $0 "cancel" GiveUpDotNET\r
132     NSISdl::download /TIMEOUT=30000 /NOPROXY ${DOTNET_URL} "$TEMP\dotnetfx35.exe" /END\r
133     Pop $0\r
134     DetailPrint "Result: $0"\r
135     StrCmp $0 "success" InstallDotNet\r
136  \r
137     MessageBox MB_ICONSTOP "Download failed: $0"\r
138     goto NewDotNET\r
139 \r
140    GiveUpDotNET:\r
141      DetailPrint "Installation cancelled by user."\r
142          goto NewDotNET\r
143 \r
144   InstallDotNet:\r
145     DetailPrint "Completed download."\r
146     Pop $0\r
147     ${If} $0 == "cancel"\r
148       MessageBox MB_YESNO|MB_ICONEXCLAMATION \\r
149       "Download cancelled.  Continue Installation?" \\r
150       IDYES NewDotNET IDNO GiveUpDotNET\r
151     ${EndIf}\r
152     DetailPrint "Pausing installation while downloaded .NET Framework installer runs."\r
153         MessageBox MB_OKCANCEL "Setup will now install .NET Framework$\nThis will take a while." \\r
154           IDOK +1 IDCANCEL GiveUpDotNET\r
155     ExecWait '$TEMP\dotnetfx35.exe /q /norestart /c:"install /q"'\r
156     DetailPrint "Completed .NET Framework install/update. Removing .NET Framework installer."\r
157     Delete "$TEMP\dotnetfx35.exe"\r
158     DetailPrint ".NET Framework installer removed."\r
159         goto NewDotNET\r
160 \r
161   NewDotNET:\r
162     DetailPrint ".NET Framework check complete."\r
163 \r
164 SectionEnd\r
165 \r
166 \r
167 ;--------------------------------\r
168 ; The stuff to install\r
169 ; Main Section\r
170 ;--------------------------------\r
171 Section "${APPNAME} core (required)"\r
172 \r
173   SectionIn RO\r
174 \r
175   ; Set output path to the installation directory.\r
176   SetOutPath $INSTDIR\r
177 \r
178   ; Put file there\r
179   File /r /x *.nsi /x *.bak /x *.mdb /x *.application /x *vshost*.* /x *installer*.* /x *.so /x *.dylib *.*\r
180   ; File Radegast.exe\r
181 \r
182   ; Write the installation path into the registry\r
183   WriteRegStr HKLM "SOFTWARE\${APPNAME}" "Install_Dir" "$INSTDIR"\r
184   \r
185   ; Write the uninstall keys for Windows\r
186   WriteRegStr HKLM ${UNINST_REG} "DisplayName" "${APPNAME} ${VERSION}"\r
187   WriteRegStr HKLM ${UNINST_REG} "UninstallString" '"$INSTDIR\uninstall.exe"'\r
188   WriteRegStr HKLM ${UNINST_REG} "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S'\r
189   WriteRegStr HKLM ${UNINST_REG} "Publisher" "Radegast Development Team"\r
190   WriteRegStr HKLM ${UNINST_REG} "DisplayVersion" "${VERSION}"\r
191   WriteRegStr HKLM ${UNINST_REG} "DisplayIcon" "$INSTDIR\${MAINEXEC}"\r
192   ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2\r
193   IntFmt $0 "0x%08X" $0\r
194   WriteRegDWORD HKLM "${UNINST_REG}" "EstimatedSize" "$0"\r
195   WriteRegDWORD HKLM ${UNINST_REG} "NoModify" 1\r
196   WriteRegDWORD HKLM ${UNINST_REG} "NoRepair" 1\r
197   WriteUninstaller "uninstall.exe"\r
198   \r
199 SectionEnd\r
200 \r
201 ;--------------------------------\r
202 ; Voice pack download and install\r
203 Section /o "${APPNAME} Voice Pack (extra download)"\r
204   AddSize 6662\r
205   IfFileExists "$INSTDIR\SLVoice.exe" voice_download_exists\r
206   NSISdl::download /TIMEOUT=30000  "http://radegast.googlecode.com/files/${VOICEPACK}" "$INSTDIR\${VOICEPACK}"\r
207   Pop $R0\r
208   StrCmp $R0 "success" voice_download_success voice_download_failed\r
209   \r
210   voice_download_success:\r
211         ExecWait '"$INSTDIR\${VOICEPACK}" /D=$INSTDIR' $0\r
212     Delete "$INSTDIR\${VOICEPACK}"\r
213     goto voice_download_end\r
214 \r
215   voice_download_failed:\r
216     MessageBox MB_OK "Download failed: $R0. Skipping installation of voice."\r
217         goto voice_download_end\r
218   \r
219   voice_download_exists:\r
220     DetailPrint  "Voice pack already present, skipping the install"\r
221         goto voice_download_end\r
222 \r
223   voice_download_end:\r
224 SectionEnd\r
225 \r
226 ;--------------------------------\r
227 ; Start menu\r
228 Section "Start Menu Shortcuts"\r
229 \r
230   CreateDirectory "$SMPROGRAMS\${APPNAME}"\r
231   CreateShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0\r
232   CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\${MAINEXEC}" "" "$INSTDIR\${MAINEXEC}" 0\r
233   \r
234 SectionEnd\r
235 \r
236 ;--------------------------------\r
237 ; Desktop shortcut\r
238 Section "Desktop shortcut"\r
239 \r
240   CreateShortCut "$DESKTOP\${APPNAME}.lnk" "$INSTDIR\${MAINEXEC}" "" "$INSTDIR\${MAINEXEC}" 0\r
241 \r
242 SectionEnd\r
243 \r
244 ;--------------------------------\r
245 ; Uninstaller\r
246 \r
247 Section "Uninstall"\r
248   IfFileExists "$INSTDIR\uninstall_voice.exe" +1 +2\r
249   ExecWait '"$INSTDIR\uninstall_voice.exe" /S' $0\r
250   \r
251   ; Remove registry keys\r
252   DeleteRegKey HKLM ${UNINST_REG}\r
253   DeleteRegKey HKLM "SOFTWARE\${APPNAME}"\r
254 \r
255   ; Remove files and uninstaller\r
256   Delete $INSTDIR\*.*\r
257   Delete $INSTDIR\aiml\*.*\r
258   RMDir $INSTDIR\aiml\r
259   Delete $INSTDIR\aiml_config\*.*\r
260   RMDir $INSTDIR\aiml_config\r
261   Delete $INSTDIR\character\*.*\r
262   RMDir $INSTDIR\character\r
263   Delete $INSTDIR\openmetaverse_data\static_assets\*.*\r
264   RMDir $INSTDIR\openmetaverse_data\static_assets\r
265   RMDir $INSTDIR\openmetaverse_data\r
266   Delete $INSTDIR\openmetaverse_data\*.*\r
267   RMDir $INSTDIR\openmetaverse_data\r
268   Delete $INSTDIR\shader_data\*.*\r
269   RMDir $INSTDIR\shader_data\r
270   \r
271   ; Remove shortcuts, if any\r
272   Delete "$DESKTOP\${APPNAME}.lnk"\r
273   Delete "$SMPROGRAMS\${APPNAME}\*.*"\r
274 \r
275   ; Remove directories used\r
276   RMDir "$SMPROGRAMS\${APPNAME}"\r
277   RMDir "$INSTDIR"\r
278 \r
279 SectionEnd\r