1 ;Application for Windows install script
2 ;Copyright (C) 2005-2013 Team XBMC
5 ;--------------------------------
9 !include "nsDialogs.nsh"
10 !include "LogicLib.nsh"
14 ;--------------------------------
19 OutFile "${APP_NAME}Setup-${app_revision}-${app_branch}-${TARGET_ARCHITECTURE}.exe"
21 ;Default installation folder
23 InstallDir "$PROGRAMFILES64\${APP_NAME}"
25 InstallDir "$PROGRAMFILES\${APP_NAME}"
28 ;Get installation folder from registry if available
29 InstallDirRegKey HKCU "Software\${APP_NAME}" ""
31 ;Request application privileges for Windows Vista
32 RequestExecutionLevel admin
34 InstProgressFlags smooth
36 ; Installer file properties
37 VIProductVersion
${VERSION_NUMBER}
38 VIAddVersionKey
"ProductName" "${APP_NAME}"
39 VIAddVersionKey
"Comments" "This application and its source code are freely distributable."
40 VIAddVersionKey
"LegalCopyright" "The trademark is owned by ${COMPANY_NAME}"
41 VIAddVersionKey
"CompanyName" "${COMPANY_NAME}"
42 VIAddVersionKey
"FileDescription" "${APP_NAME} ${VERSION_NUMBER} Setup"
43 VIAddVersionKey
"FileVersion" "${VERSION_NUMBER}"
44 VIAddVersionKey
"ProductVersion" "${VERSION_NUMBER}"
45 VIAddVersionKey
"LegalTrademarks" "${APP_NAME}"
46 ;VIAddVersionKey "OriginalFilename" "${APP_NAME}Setup-${app_revision}-${app_branch}.exe"
48 ;--------------------------------
53 Var VSRedistSetupError
54 Var /GLOBAL CleanDestDir
56 ;--------------------------------
59 !define MUI_HEADERIMAGE
60 !define MUI_ICON
"..\..\tools\windows\packaging\media\application.ico"
61 !define MUI_UNICON
"..\..\tools\windows\packaging\media\application.ico"
62 !define MUI_HEADERIMAGE_BITMAP
"..\..\tools\windows\packaging\media\installer\header.bmp"
63 !define MUI_HEADERIMAGE_UNBITMAP
"..\..\tools\windows\packaging\media\installer\header.bmp"
64 !define MUI_WELCOMEFINISHPAGE_BITMAP
"..\..\tools\windows\packaging\media\installer\welcome-left.bmp"
65 !define MUI_UNWELCOMEFINISHPAGE_BITMAP
"..\..\tools\windows\packaging\media\installer\welcome-left.bmp"
66 !define MUI_COMPONENTSPAGE_SMALLDESC
67 !define MUI_FINISHPAGE_LINK
"Please visit ${WEBSITE} for more information."
68 !define MUI_FINISHPAGE_LINK_LOCATION
"${WEBSITE}"
69 !define MUI_FINISHPAGE_RUN
"$INSTDIR\${APP_NAME}.exe"
70 !define MUI_FINISHPAGE_RUN_NOTCHECKED
71 !define MUI_ABORTWARNING
72 ;--------------------------------
75 !insertmacro MUI_PAGE_WELCOME
76 !insertmacro MUI_PAGE_LICENSE
"..\..\LICENSE.md"
77 !insertmacro MUI_PAGE_COMPONENTS
78 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CallbackDirLeave
79 !insertmacro MUI_PAGE_DIRECTORY
81 ;Start Menu Folder Page Configuration
82 !define MUI_STARTMENUPAGE_REGISTRY_ROOT
"HKCU"
83 !define MUI_STARTMENUPAGE_REGISTRY_KEY
"Software\${APP_NAME}"
84 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME
"Start Menu Folder"
85 !insertmacro MUI_PAGE_STARTMENU Application
$StartMenuFolder
87 !insertmacro MUI_PAGE_INSTFILES
88 !insertmacro MUI_PAGE_FINISH
90 !insertmacro MUI_UNPAGE_WELCOME
91 !insertmacro MUI_UNPAGE_CONFIRM
92 UninstPage custom un
.UnPageProfile un
.UnPageProfileLeave
93 !insertmacro MUI_UNPAGE_INSTFILES
94 !insertmacro MUI_UNPAGE_FINISH
96 ;--------------------------------
99 !insertmacro MUI_LANGUAGE
"English"
101 ;--------------------------------
104 Function CallbackDirLeave
105 ;deinstall kodi if it is already there in destination folder
106 Call HandleKodiInDestDir
109 Function HandleOldKodiInstallation
110 Var /GLOBAL INSTDIR_KODI
111 ReadRegStr $INSTDIR_KODI HKCU "Software\${APP_NAME}" ""
113 ;if former Kodi installation was detected in a different directory then the destination dir
114 ;ask for uninstallation
115 ;only ask about the other installation if user didn't already
116 ;decide to not overwrite the installation in his originally selected destination dir
117 ${IfNot} $CleanDestDir ==
"0"
118 ${AndIfNot} $INSTDIR_KODI ==
""
119 ${AndIfNot} $INSTDIR_KODI ==
$INSTDIR
120 MessageBox MB_YESNO|
MB_ICONQUESTION "A previous ${APP_NAME} installation in a different folder was detected. Would you like to uninstall it?$\nYour current settings and library data will be kept intact." IDYES true
IDNO false
122 DetailPrint "Uninstalling $INSTDIR_KODI"
124 ExecWait '"$INSTDIR_KODI\uninstall.exe" /S _?=$INSTDIR_KODI'
126 ;this also removes the uninstall.exe which doesn't remove it self...
127 Delete "$INSTDIR_KODI\uninstall.exe"
128 ;if the directory is now empty we can safely remove it (rmdir won't remove non-empty dirs!)
129 RmDir
"$INSTDIR_KODI"
134 Function HandleKodiInDestDir
135 ;if former Kodi installation was detected in the destination directory - uninstall it first
136 ${IfNot} $INSTDIR ==
""
137 ${AndIf} ${FileExists} "$INSTDIR\uninstall.exe"
138 MessageBox MB_YESNO|
MB_ICONQUESTION "A previous installation was detected in the selected destination folder. Do you really want to overwrite it?$\nYour settings and library data will be kept intact." IDYES true
IDNO false
140 StrCpy $CleanDestDir "1"
143 StrCpy $CleanDestDir "0"
146 MessageBox MB_OK|MB_ICONINFORMATION
"All binary add-ons (e.g. pvr, visualizations, inputstream, etc) that were previously included by default in the installer have been moved to the Kodi repository. You will have to install the ones you previously used from the repository.$\nYour add-on settings are kept intact and will be used again after installing the add-on."
150 Function DeinstallKodiInDestDir
151 ${If} $CleanDestDir ==
"1"
152 DetailPrint "Uninstalling former ${APP_NAME} Installation in $INSTDIR"
154 ExecWait '"$INSTDIR\uninstall.exe" /S _?=$INSTDIR'
156 ;this also removes the uninstall.exe which doesn't remove it self...
157 Delete "$INSTDIR\uninstall.exe"
161 ;--------------------------------
165 InstType "Normal" ; 2.
166 InstType "Minimal" ; 3.
168 ;--------------------------------
171 Section "${APP_NAME}" SecAPP
172 SetShellVarContext all
174 SectionIn 1 2 3 #section is in install type Normal/Full/Minimal
176 ;deinstall kodi in destination dir if $CleanDestDir == "1" - meaning user has confirmed it
177 Call DeinstallKodiInDestDir
180 SetOutPath "$INSTDIR"
181 File "${app_root}\application\*.*"
182 SetOutPath "$INSTDIR\addons"
183 File /r
"${app_root}\application\addons\*.*"
184 File /nonfatal
/r
"${app_root}\addons\peripheral.*"
185 SetOutPath "$INSTDIR\media"
186 File /r
"${app_root}\application\media\*.*"
187 SetOutPath "$INSTDIR\system"
188 File /r
"${app_root}\application\system\*.*"
189 SetOutPath "$INSTDIR\userdata"
190 File /r
"${app_root}\application\userdata\*.*"
192 ;Store installation folder
193 WriteRegStr HKCU "Software\${APP_NAME}" "" $INSTDIR
196 WriteUninstaller "$INSTDIR\Uninstall.exe"
198 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
200 SetOutPath "$INSTDIR"
202 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
203 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" \
204 "" "$INSTDIR\${APP_NAME}.exe" 0 SW_SHOWNORMAL \
205 "" "Start ${APP_NAME}."
206 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\Uninstall.exe" \
207 "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \
208 "" "Uninstall ${APP_NAME}."
210 WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Visit ${APP_NAME} Online.url" "InternetShortcut" "URL" "${WEBSITE}"
211 !insertmacro MUI_STARTMENU_WRITE_END
213 ;add entry to add/remove programs
214 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
215 "DisplayName" "${APP_NAME}"
216 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
217 "UninstallString" "$INSTDIR\uninstall.exe"
218 WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
220 WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
222 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
223 "InstallLocation" "$INSTDIR"
224 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
225 "DisplayIcon" "$INSTDIR\${APP_NAME}.exe,0"
226 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
227 "Publisher" "${COMPANY_NAME}"
228 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
229 "HelpLink" "${WEBSITE}"
230 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
231 "URLInfoAbout" "${WEBSITE}"
232 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
233 "DisplayVersion" "${VERSION_NUMBER}"
237 ;*-addons.nsi are generated by genNsisIncludes.bat
238 !include /nonfatal
"audiodecoder-addons.nsi"
239 !include /nonfatal
"audioencoder-addons.nsi"
240 !include /nonfatal
"game-addons.nsi"
241 !include /nonfatal
"imagedecoder-addons.nsi"
242 !include /nonfatal
"inputstream-addons.nsi"
243 !include /nonfatal
"pvr-addons.nsi"
244 !include /nonfatal
"screensaver-addons.nsi"
245 !include /nonfatal
"vfs-addons.nsi"
246 !include /nonfatal
"visualization-addons.nsi"
248 ;--------------------------------
252 LangString DESC_SecAPP
${LANG_ENGLISH} "${APP_NAME} ${VERSION_NUMBER}"
254 ;Assign language strings to sections
255 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
256 !insertmacro MUI_DESCRIPTION_TEXT
${SecAPP} $(DESC_SecAPP
)
257 !insertmacro MUI_FUNCTION_DESCRIPTION_END
259 ;--------------------------------
262 Var UnPageProfileDialog
263 Var UnPageProfileCheckbox
264 Var UnPageProfileCheckbox_State
265 Var UnPageProfileEditBox
267 Function un
.UnPageProfile
268 !insertmacro MUI_HEADER_TEXT
"Uninstall ${APP_NAME}" "Remove ${APP_NAME}'s profile folder from your computer."
269 nsDialogs::Create
/NOUNLOAD
1018
270 Pop $UnPageProfileDialog
272 ${If} $UnPageProfileDialog == error
276 ${NSD_CreateLabel} 0 0 100% 12u "Do you want to delete the profile folder which contains your ${APP_NAME} settings and library data?"
279 ${NSD_CreateText} 0 13u 100% 12u "$APPDATA\${APP_NAME}\"
280 Pop $UnPageProfileEditBox
281 SendMessage $UnPageProfileEditBox ${EM_SETREADONLY} 1 0
283 ${NSD_CreateLabel} 0 30u 100% 24u "Leave the option box below unchecked to keep the profile folder which contains ${APP_NAME}'s settings and library data for later use. If you are sure you want to delete the profile folder you may check the option box.$\nWARNING: Deletion of the profile folder cannot be undone and you will lose all settings and library data."
286 ${NSD_CreateCheckbox} 0 71u 100% 8u "Yes, I am sure and grant permission to also delete the profile folder."
287 Pop $UnPageProfileCheckbox
292 Function un
.UnPageProfileLeave
293 ${NSD_GetState} $UnPageProfileCheckbox $UnPageProfileCheckbox_State
298 SetShellVarContext all
300 ;ADD YOUR OWN FILES HERE...
301 RMDir /r
"$INSTDIR\addons"
302 RMDir /r
"$INSTDIR\language"
303 RMDir /r
"$INSTDIR\media"
304 RMDir /r
"$INSTDIR\system"
305 RMDir /r
"$INSTDIR\userdata"
306 Delete "$INSTDIR\*.*"
308 ;Un-install User Data if option is checked, otherwise skip
309 ${If} $UnPageProfileCheckbox_State ==
${BST_CHECKED}
310 SetShellVarContext current
311 RMDir /r
"$APPDATA\${APP_NAME}\"
312 SetShellVarContext all
313 RMDir /r
"$INSTDIR\portable_data\"
317 !insertmacro MUI_STARTMENU_GETFOLDER Application
$StartMenuFolder
318 Delete "$SMPROGRAMS\$StartMenuFolder\${APP_NAME}.lnk"
319 Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall ${APP_NAME}.lnk"
320 Delete "$SMPROGRAMS\$StartMenuFolder\Visit ${APP_NAME} Online.url"
321 RMDir "$SMPROGRAMS\$StartMenuFolder"
322 DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
323 DeleteRegKey /ifempty
HKCU "Software\${APP_NAME}"
327 ;--------------------------------
328 ;vs redist installer Section
329 SectionGroup
"Microsoft Visual C++ packages" SEC_VCREDIST
331 Section "Visual C++ 2015-2022 Redistributable Package (${TARGET_ARCHITECTURE})" SEC_VCREDIST1
332 DetailPrint "Running Visual C++ 2015-2022 Redistributable setup..."
333 SectionIn 1 2 #section is in install type Full
334 SetOutPath "$TEMP\vcredist"
335 File "${app_root}\..\..\BuildDependencies\downloads\vcredist\2015-2022\vcredist_${TARGET_ARCHITECTURE}.exe"
336 ExecWait '"$TEMP\vcredist\vcredist_${TARGET_ARCHITECTURE}.exe" /install /quiet /norestart' $VSRedistSetupError
337 RMDir /r
"$TEMP\vcredist"
338 DetailPrint "Finished Visual C++ 2015-2022 Redistributable setup"
339 SetOutPath "$INSTDIR"
347 ${IfNot} ${RunningX64}
348 MessageBox MB_OK|
MB_ICONSTOP 'This is the 64-bit ${APP_NAME} installer.$\nPlease download the 32-bit version from ${WEBSITE}.$\n$\nClick Ok to quit Setup.'
353 MessageBox MB_YESNO|
MB_ICONEXCLAMATION|MB_DEFBUTTON2
'There is a specific 64-bit ${APP_NAME} version available for download. Please consider installing the 64-bit version instead.$\nFor details visit ${WEBSITE}.$\nProceed with 32-bit installation anyway?' /SD
IDYES IDYES noprob
359 ; Windows 8.1 is minimum requirement
360 ${IfNot} ${AtLeastWin8
.1
}
361 MessageBox MB_OK|
MB_ICONSTOP|
MB_TOPMOST|
MB_SETFOREGROUND "Windows 8.1 or above required."
365 StrCpy $CleanDestDir "-1"