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