[win32] installer: remove language checkbox and just install all languages
[vuplus_xbmc] / project / Win32BuildSetup / XBMC for Windows.nsi
1 ;XBMC for Windows install script
2 ;Copyright (C) 2005-2013 Team XBMC
3 ;http://xbmc.org
4
5 ;Script by chadoe
6
7 ;--------------------------------
8 ;Include Modern UI
9
10   !include "MUI2.nsh"
11   !include "nsDialogs.nsh"
12   !include "LogicLib.nsh"
13   !include "WinVer.nsh"
14   
15 ;--------------------------------
16 ;define global used name
17   !define APP_NAME "XBMC"
18
19 ;--------------------------------
20 ;General
21
22   ;Name and file
23   Name "${APP_NAME}"
24   OutFile "${APP_NAME}Setup-${xbmc_revision}-${xbmc_branch}.exe"
25
26   XPStyle on
27   
28   ;Default installation folder
29   InstallDir "$PROGRAMFILES\${APP_NAME}"
30
31   ;Get installation folder from registry if available
32   InstallDirRegKey HKCU "Software\${APP_NAME}" ""
33
34   ;Request application privileges for Windows Vista
35   RequestExecutionLevel admin
36
37 ;--------------------------------
38 ;Variables
39
40   Var StartMenuFolder
41   Var PageProfileState
42   Var DirectXSetupError
43   Var VSRedistSetupError
44   
45 ;--------------------------------
46 ;Interface Settings
47
48   !define MUI_HEADERIMAGE
49   !define MUI_ICON "..\..\xbmc\win32\xbmc.ico"
50   ;!define MUI_HEADERIMAGE_BITMAP "xbmc-banner.bmp"
51   ;!define MUI_HEADERIMAGE_RIGHT
52   !define MUI_WELCOMEFINISHPAGE_BITMAP "xbmc-left.bmp"
53   !define MUI_COMPONENTSPAGE_SMALLDESC
54   ;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\webapps\ROOT\RELEASE-NOTES.txt"
55   !define MUI_FINISHPAGE_LINK "Please visit http://xbmc.org for more information."
56   !define MUI_FINISHPAGE_LINK_LOCATION "http://xbmc.org"
57   !define MUI_FINISHPAGE_RUN "$INSTDIR\${APP_NAME}.exe"
58   !define MUI_FINISHPAGE_RUN_NOTCHECKED
59   !define MUI_ABORTWARNING  
60 ;--------------------------------
61 ;Pages
62
63   !insertmacro MUI_PAGE_WELCOME
64   !insertmacro MUI_PAGE_LICENSE "..\..\LICENSE.GPL"
65   !insertmacro MUI_PAGE_COMPONENTS
66   !insertmacro MUI_PAGE_DIRECTORY
67   
68   ;Start Menu Folder Page Configuration
69   !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 
70   !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${APP_NAME}" 
71   !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
72   !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder  
73
74   !insertmacro MUI_PAGE_INSTFILES
75   !insertmacro MUI_PAGE_FINISH
76
77   !insertmacro MUI_UNPAGE_WELCOME
78   !insertmacro MUI_UNPAGE_CONFIRM
79   UninstPage custom un.UnPageProfile un.UnPageProfileLeave
80   !insertmacro MUI_UNPAGE_INSTFILES
81   !insertmacro MUI_UNPAGE_FINISH
82
83 ;--------------------------------
84 ;Languages
85
86   !insertmacro MUI_LANGUAGE "English"
87
88 ;--------------------------------
89 ;Install levels
90
91 InstType "Full"    ; 1.
92 InstType "Normal"  ; 2.
93 InstType "Minimal" ; 3.
94
95 ;--------------------------------
96 ;Installer Sections
97
98 Section "XBMC" SecXBMC
99   SetShellVarContext current
100   SectionIn RO
101   SectionIn 1 2 3 #section is in install type Normal/Full/Minimal
102   ;ADD YOUR OWN FILES HERE...
103   SetOutPath "$INSTDIR"
104   File "${xbmc_root}\Xbmc\XBMC.exe"
105   File "${xbmc_root}\Xbmc\copying.txt"
106   File "${xbmc_root}\Xbmc\LICENSE.GPL"
107   File "${xbmc_root}\Xbmc\*.dll"
108   SetOutPath "$INSTDIR\language"
109   File /r /x *.so "${xbmc_root}\Xbmc\language\*.*"
110   SetOutPath "$INSTDIR\media"
111   File /r /x *.so "${xbmc_root}\Xbmc\media\*.*"
112   SetOutPath "$INSTDIR\sounds"
113   File /r /x *.so "${xbmc_root}\Xbmc\sounds\*.*"
114   SetOutPath "$INSTDIR\system"
115   
116   ; delete system/python if its there
117   IfFileExists $INSTDIR\system\python 0 +2
118     RMDir /r $INSTDIR\system\python
119   
120   File /r /x *.so /x mplayer /x *_d.* /x tcl85g.dll /x tclpip85g.dll /x tk85g.dll "${xbmc_root}\Xbmc\system\*.*"
121   
122   ; delete  msvc?90.dll's in INSTDIR, we use the vcredist installer later
123   Delete "$INSTDIR\msvcr90.dll"
124   Delete "$INSTDIR\msvcp90.dll"
125   
126   ;Turn off overwrite to prevent files in xbmc\userdata\ from being overwritten
127   SetOverwrite off
128   
129   SetOutPath "$INSTDIR\userdata"
130   File /r /x *.so  "${xbmc_root}\Xbmc\userdata\*.*"
131   
132   ;Turn on overwrite for rest of install
133   SetOverwrite on
134   RMDir /r $INSTDIR\addons
135   SetOutPath "$INSTDIR\addons"
136   File /r /x skin.touched ${xbmc_root}\Xbmc\addons\*.*
137   ;SetOutPath "$INSTDIR\web"
138   ;File /r "${xbmc_root}\Xbmc\web\*.*"
139
140   ;Store installation folder
141   WriteRegStr HKCU "Software\${APP_NAME}" "" $INSTDIR
142
143   ;Create uninstaller
144   WriteUninstaller "$INSTDIR\Uninstall.exe"
145   
146   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
147   ;Create shortcuts
148   SetOutPath "$INSTDIR"
149   
150   ; delete old windowed link
151   Delete "$SMPROGRAMS\$StartMenuFolder\XBMC (Windowed).lnk"
152   
153   CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
154   CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" \
155     "" "$INSTDIR\${APP_NAME}.exe" 0 SW_SHOWNORMAL \
156     "" "Start ${APP_NAME}."
157   CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\Uninstall.exe" \
158     "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \
159     "" "Uninstall ${APP_NAME}."
160   
161   WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Visit ${APP_NAME} Online.url" "InternetShortcut" "URL" "http://xbmc.org"
162   !insertmacro MUI_STARTMENU_WRITE_END  
163   
164   ;add entry to add/remove programs
165   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
166                  "DisplayName" "${APP_NAME}"
167   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
168                  "UninstallString" "$INSTDIR\uninstall.exe"
169   WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
170                  "NoModify" 1
171   WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
172                  "NoRepair" 1
173   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
174                  "InstallLocation" "$INSTDIR"
175   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
176                  "DisplayIcon" "$INSTDIR\${APP_NAME}.exe,0"
177   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
178                  "Publisher" "Team XBMC"
179   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
180                  "HelpLink" "http://xbmc.org/support"
181   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
182                  "URLInfoAbout" "http://xbmc.org"
183                  
184 SectionEnd
185
186 SectionGroup "Skins" SecSkins
187 Section "Confluence" SecSkinConfluence
188   SectionIn 1 2 3 #section is in install type Full/Normal/Minimal
189   SectionIn RO
190   SetOutPath "$INSTDIR\addons\skin.confluence\"
191   File /r "${xbmc_root}\Xbmc\addons\skin.confluence\*.*"
192 SectionEnd
193 ;skins.nsi is generated by genNsisIncludes.bat
194 !include /nonfatal "skins.nsi"
195 SectionGroupEnd
196
197 ;SectionGroup "Scripts" SecScripts
198 ;scripts.nsi is generated by genNsisIncludes.bat
199 !include /nonfatal "scripts.nsi"
200 ;SectionGroupEnd
201
202 ;SectionGroup "Plugins" SecPlugins
203 ;plugins.nsi is generated by genNsisIncludes.bat
204 !include /nonfatal "plugins.nsi"
205 ;SectionGroupEnd
206
207 SectionGroup "PVR Addons" SecPvrAddons
208 ;xbmc-pvr-addons.nsi is generated by genNsisIncludes.bat
209 !include /nonfatal "xbmc-pvr-addons.nsi"
210 SectionGroupEnd
211
212 ;--------------------------------
213 ;Descriptions
214
215   ;Language strings
216   LangString DESC_SecXBMC ${LANG_ENGLISH} "${APP_NAME}"
217
218   ;Assign language strings to sections
219   !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
220   !insertmacro MUI_DESCRIPTION_TEXT ${SecXBMC} $(DESC_SecXBMC)
221   !insertmacro MUI_FUNCTION_DESCRIPTION_END
222
223 ;--------------------------------
224 ;Uninstaller Section
225
226 Var UnPageProfileDialog
227 Var UnPageProfileCheckbox
228 Var UnPageProfileCheckbox_State
229 Var UnPageProfileEditBox
230
231 Function un.UnPageProfile
232     !insertmacro MUI_HEADER_TEXT "Uninstall ${APP_NAME}" "Remove ${APP_NAME}'s profile folder from your computer."
233   nsDialogs::Create /NOUNLOAD 1018
234   Pop $UnPageProfileDialog
235
236   ${If} $UnPageProfileDialog == error
237     Abort
238   ${EndIf}
239
240   ${NSD_CreateLabel} 0 0 100% 12u "Do you want to delete the profile folder?"
241   Pop $0
242
243   ${NSD_CreateText} 0 13u 100% 12u "$APPDATA\${APP_NAME}\"
244   Pop $UnPageProfileEditBox
245     SendMessage $UnPageProfileEditBox ${EM_SETREADONLY} 1 0
246
247   ${NSD_CreateLabel} 0 46u 100% 24u "Leave unchecked to keep the profile folder for later use or check to delete the profile folder."
248   Pop $0
249
250   ${NSD_CreateCheckbox} 0 71u 100% 8u "Yes, also delete the profile folder."
251   Pop $UnPageProfileCheckbox
252   
253
254   nsDialogs::Show
255 FunctionEnd
256
257 Function un.UnPageProfileLeave
258 ${NSD_GetState} $UnPageProfileCheckbox $UnPageProfileCheckbox_State
259 FunctionEnd
260
261 Section "Uninstall"
262
263   SetShellVarContext current
264
265   ;ADD YOUR OWN FILES HERE...
266   Delete "$INSTDIR\${APP_NAME}.exe"
267   Delete "$INSTDIR\copying.txt"
268   Delete "$INSTDIR\known_issues.txt"
269   Delete "$INSTDIR\LICENSE.GPL"
270   Delete "$INSTDIR\glew32.dll"
271   Delete "$INSTDIR\SDL.dll"
272   Delete "$INSTDIR\zlib1.dll"
273   Delete "$INSTDIR\xbmc.log"
274   Delete "$INSTDIR\xbmc.old.log"
275   Delete "$INSTDIR\python26.dll"
276   Delete "$INSTDIR\libcdio-*.dll"
277   Delete "$INSTDIR\libiconv-2.dll"
278   RMDir /r "$INSTDIR\language"
279   RMDir /r "$INSTDIR\media"
280   RMDir /r "$INSTDIR\plugins"
281   RMDir /r "$INSTDIR\scripts"
282   RMDir /r "$INSTDIR\skin"
283   RMDir /r "$INSTDIR\sounds"
284   RMDir /r "$INSTDIR\system"
285   RMDir /r "$INSTDIR\visualisations"
286   RMDir /r "$INSTDIR\addons"
287   RMDir /r "$INSTDIR\web"
288   RMDir /r "$INSTDIR\cache"
289
290   Delete "$INSTDIR\Uninstall.exe"
291   
292 ;Uninstall User Data if option is checked, otherwise skip
293   ${If} $UnPageProfileCheckbox_State == ${BST_CHECKED}
294     RMDir /r "$INSTDIR\userdata"  
295     RMDir "$INSTDIR"
296     RMDir /r "$APPDATA\${APP_NAME}\"
297   ${Else}
298 ;Even if userdata is kept in %appdata%\xbmc\userdata, the $INSTDIR\userdata should be cleaned up on uninstall if not used
299 ;If guisettings.xml exists in the XBMC\userdata directory, do not delete XBMC\userdata directory
300 ;If that file does not exists, then delete that folder and $INSTDIR
301     IfFileExists $INSTDIR\userdata\guisettings.xml +3
302       RMDir /r "$INSTDIR\userdata"  
303       RMDir "$INSTDIR"
304   ${EndIf}
305
306   
307   !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
308   Delete "$SMPROGRAMS\$StartMenuFolder\${APP_NAME}.lnk"
309   Delete "$SMPROGRAMS\$StartMenuFolder\XBMC (Portable).lnk"
310   Delete "$SMPROGRAMS\$StartMenuFolder\XBMC (Windowed).lnk"
311   Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall ${APP_NAME}.lnk"
312   Delete "$SMPROGRAMS\$StartMenuFolder\Visit ${APP_NAME} Online.url"
313   RMDir "$SMPROGRAMS\$StartMenuFolder"  
314   DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
315
316   DeleteRegKey /ifempty HKCU "Software\${APP_NAME}"
317
318 SectionEnd
319
320 ;--------------------------------
321 ;vs redist installer Section
322
323 Section "Microsoft Visual C++ 2008/2010 Redistributable Package (x86)" SEC_VCREDIST
324
325   SectionIn 1 2 #section is in install type Full/Normal and when not installed
326   
327   DetailPrint "Running VS Redist Setup..."
328
329   ;vc90 for python
330   SetOutPath "$TEMP\vc2008"
331   File "${xbmc_root}\..\dependencies\vcredist\2008\vcredist_x86.exe"
332   ExecWait '"$TEMP\vc2008\vcredist_x86.exe" /q' $VSRedistSetupError
333   RMDir /r "$TEMP\vc2008"
334   
335   ;vc100
336   SetOutPath "$TEMP\vc2010"
337   File "${xbmc_root}\..\dependencies\vcredist\2010\vcredist_x86.exe"
338   DetailPrint "Running VS Redist Setup..."
339   ExecWait '"$TEMP\vc2010\vcredist_x86.exe" /q' $VSRedistSetupError
340   RMDir /r "$TEMP\vc2010"
341  
342   DetailPrint "Finished VS Redist Setup"
343   SetOutPath "$INSTDIR"
344 SectionEnd
345
346 ;--------------------------------
347 ;DirectX webinstaller Section
348
349 !if "${xbmc_target}" == "dx"
350 !define DXVERSIONDLL "$SYSDIR\D3DX9_43.dll"
351
352 Section "DirectX Install" SEC_DIRECTX
353  
354   SectionIn 1 2 #section is in install type Full/Normal and when not installed
355
356   DetailPrint "Running DirectX Setup..."
357
358   SetOutPath "$TEMP\dxsetup"
359   File "${xbmc_root}\..\dependencies\dxsetup\dsetup32.dll"
360   File "${xbmc_root}\..\dependencies\dxsetup\DSETUP.dll"
361   File "${xbmc_root}\..\dependencies\dxsetup\dxdllreg_x86.cab"
362   File "${xbmc_root}\..\dependencies\dxsetup\DXSETUP.exe"
363   File "${xbmc_root}\..\dependencies\dxsetup\dxupdate.cab"
364   File "${xbmc_root}\..\dependencies\dxsetup\Jun2010_D3DCompiler_43_x86.cab"
365   File "${xbmc_root}\..\dependencies\dxsetup\Jun2010_d3dx9_43_x86.cab"
366   ExecWait '"$TEMP\dxsetup\dxsetup.exe" /silent' $DirectXSetupError
367   RMDir /r "$TEMP\dxsetup"
368   SetOutPath "$INSTDIR"
369
370   DetailPrint "Finished DirectX Setup"
371   
372 SectionEnd
373
374 Section "-Check DirectX installation" SEC_DIRECTXCHECK
375
376   IfFileExists ${DXVERSIONDLL} +2 0
377     MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "DirectX9 wasn't installed properly.$\nPlease download the DirectX End-User Runtime from Microsoft and install it again."
378
379 SectionEnd
380
381 Function .onInit
382   ${IfNot} ${AtLeastWinVista}
383     MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Windows Vista or above required.$\nThis program can not be run on Windows XP"
384     Quit
385   ${EndIf}
386   # set section 'SEC_DIRECTX' as selected and read-only if required dx version not found
387   IfFileExists ${DXVERSIONDLL} +3 0
388   IntOp $0 ${SF_SELECTED} | ${SF_RO}
389   SectionSetFlags ${SEC_DIRECTX} $0
390 FunctionEnd
391 !endif