David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 1 | # NSIS Script for creating the Windows Vulkan RT installer. |
| 2 | # |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 3 | # Copyright (c) 2015-2016 The Khronos Group Inc. |
| 4 | # Copyright (c) 2015-2016 Valve Corporation |
| 5 | # Copyright (c) 2015-2016 LunarG, Inc. |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 6 | # |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | # of this software and/or associated documentation files (the "Materials"), to |
| 9 | # deal in the Materials without restriction, including without limitation the |
| 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 11 | # sell copies of the Materials, and to permit persons to whom the Materials are |
| 12 | # furnished to do so, subject to the following conditions: |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 13 | # |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 14 | # The above copyright notice(s) and this permission notice shall be included in |
| 15 | # all copies or substantial portions of the Materials. |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 16 | # |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 17 | # THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 20 | # |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 21 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 22 | # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 23 | # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 24 | # USE OR OTHER DEALINGS IN THE MATERIALS. |
| 25 | # |
| 26 | # Author: David Pinedo <david@LunarG.com> |
| 27 | # Author: Mark Young <mark@LunarG.com> |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 28 | # |
| 29 | |
| 30 | |
| 31 | # Version information |
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 32 | # Set VERSION_BUILDNO to: |
| 33 | # x.pre.z for prereleases |
| 34 | # x for releases |
| 35 | # |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 36 | !define PRODUCTNAME "VulkanRT" |
David Pinedo | f2defe3 | 2016-01-06 16:34:27 -0700 | [diff] [blame] | 37 | !define VERSION_ABI_MAJOR "1" |
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 38 | !define VERSION_API_MAJOR "1" |
| 39 | !define VERSION_MINOR "0" |
| 40 | !define VERSION_PATCH "1" |
Mark Young | d6897a3 | 2016-01-20 14:48:21 -0700 | [diff] [blame] | 41 | !define VERSION_BUILDNO "0.pre.1" |
David Pinedo | 5580597 | 2016-02-08 12:20:11 -0700 | [diff] [blame] | 42 | !define PUBLISHER "YourCompany, Inc." |
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 43 | #!define VERSION_BUILDNO "0" |
| 44 | !define PRODUCTVERSION "${VERSION_API_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILDNO}" |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 45 | |
David Pinedo | e8e5203 | 2016-01-06 09:59:58 -0700 | [diff] [blame] | 46 | # Includes |
| 47 | !include LogicLib.nsh |
| 48 | |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 49 | # This number is determined by doing an install, and then from Windows Explorer, |
| 50 | # doing a "Properties" on the install directory. Add to this the size of the |
| 51 | # files installed to C:\Windows\System32. And then add a little bit more. |
David Pinedo | 94e29b7 | 2016-01-04 16:38:15 -0700 | [diff] [blame] | 52 | # The units are 1K bytes. |
David Pinedo | 261d978 | 2016-02-03 13:38:40 -0700 | [diff] [blame] | 53 | !define ESTIMATEDSIZE "1700" |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 54 | |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 55 | # This is used for the error message if a problem occurs during install. |
| 56 | !define errorMessage1 "Installation of ${PRODUCTNAME} failed!$\r$\n" |
David Pinedo | e80978b | 2016-02-13 14:06:55 -0700 | [diff] [blame] | 57 | !define errorMessage1un "Uninstall of ${PRODUCTNAME} failed!$\r$\n" |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 58 | !define errorMessage2 "Uninstalling any installed items and exiting.$\r$\n" |
| 59 | |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 60 | # Set the icon |
David Pinedo | f79938f | 2016-02-02 16:10:39 -0700 | [diff] [blame] | 61 | !define ICOFILE "V.ico" |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 62 | Icon ${ICOFILE} |
| 63 | UninstallIcon ${ICOFILE} |
| 64 | WindowIcon off |
| 65 | |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 66 | # If /DUNINSTALLER was specified, Create the uinstaller |
| 67 | !ifdef UNINSTALLER |
| 68 | !echo "Creating RT uninstaller...." |
| 69 | OutFile "$%TEMP%\tempinstaller.exe" |
| 70 | SetCompress off |
| 71 | !else |
| 72 | !echo "Creating RT installer...." |
| 73 | |
| 74 | # Define name of installer |
| 75 | OutFile "VulkanRT-${PRODUCTVERSION}-Installer.exe" |
| 76 | SetCompressor /SOLID lzma |
| 77 | |
| 78 | !endif |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 79 | |
| 80 | # Define default installation directory |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 81 | InstallDir "$PROGRAMFILES\${PRODUCTNAME}\${PRODUCTVERSION}" |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 82 | |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 83 | # Version string used in file names |
David Pinedo | e8e5203 | 2016-01-06 09:59:58 -0700 | [diff] [blame] | 84 | Var FileVersion |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 85 | |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 86 | # Directory RT was installed to. |
| 87 | # The uninstaller can't just use $INSTDIR because it is set to the |
| 88 | # directory the uninstaller exe file is located in. |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 89 | !ifdef UNINSTALLER |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 90 | Var IDir |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 91 | !endif |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 92 | |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 93 | # Install count |
| 94 | Var IC |
| 95 | |
David Pinedo | a6d46a8 | 2016-02-12 12:23:57 -0700 | [diff] [blame] | 96 | # Error code from powershell script |
| 97 | Var PsErr |
| 98 | |
David Pinedo | e8e5203 | 2016-01-06 09:59:58 -0700 | [diff] [blame] | 99 | |
| 100 | ############################################# |
| 101 | # StrRep - string replace |
| 102 | |
| 103 | !define StrRep "!insertmacro StrRep" |
| 104 | !macro StrRep output string old new |
| 105 | Push `${string}` |
| 106 | Push `${old}` |
| 107 | Push `${new}` |
| 108 | !ifdef __UNINSTALL__ |
| 109 | Call un.StrRep |
| 110 | !else |
| 111 | Call StrRep |
| 112 | !endif |
| 113 | Pop ${output} |
| 114 | !macroend |
| 115 | |
| 116 | !macro Func_StrRep un |
| 117 | Function ${un}StrRep |
| 118 | Exch $R2 ;new |
| 119 | Exch 1 |
| 120 | Exch $R1 ;old |
| 121 | Exch 2 |
| 122 | Exch $R0 ;string |
| 123 | Push $R3 |
| 124 | Push $R4 |
| 125 | Push $R5 |
| 126 | Push $R6 |
| 127 | Push $R7 |
| 128 | Push $R8 |
| 129 | Push $R9 |
| 130 | |
| 131 | StrCpy $R3 0 |
| 132 | StrLen $R4 $R1 |
| 133 | StrLen $R6 $R0 |
| 134 | StrLen $R9 $R2 |
| 135 | loop: |
| 136 | StrCpy $R5 $R0 $R4 $R3 |
| 137 | StrCmp $R5 $R1 found |
| 138 | StrCmp $R3 $R6 done |
| 139 | IntOp $R3 $R3 + 1 ;move offset by 1 to check the next character |
| 140 | Goto loop |
| 141 | found: |
| 142 | StrCpy $R5 $R0 $R3 |
| 143 | IntOp $R8 $R3 + $R4 |
| 144 | StrCpy $R7 $R0 "" $R8 |
| 145 | StrCpy $R0 $R5$R2$R7 |
| 146 | StrLen $R6 $R0 |
| 147 | IntOp $R3 $R3 + $R9 ;move offset by length of the replacement string |
| 148 | Goto loop |
| 149 | done: |
| 150 | |
| 151 | Pop $R9 |
| 152 | Pop $R8 |
| 153 | Pop $R7 |
| 154 | Pop $R6 |
| 155 | Pop $R5 |
| 156 | Pop $R4 |
| 157 | Pop $R3 |
| 158 | Push $R0 |
| 159 | Push $R1 |
| 160 | Pop $R0 |
| 161 | Pop $R1 |
| 162 | Pop $R0 |
| 163 | Pop $R2 |
| 164 | Exch $R1 |
| 165 | FunctionEnd |
| 166 | !macroend |
| 167 | !insertmacro Func_StrRep "" |
| 168 | !insertmacro Func_StrRep "un." |
| 169 | |
| 170 | ############################################# |
| 171 | # x64 macros |
| 172 | |
| 173 | !define IsWow64 `"" IsWow64 ""` |
| 174 | !macro _IsWow64 _a _b _t _f |
| 175 | !insertmacro _LOGICLIB_TEMP |
| 176 | System::Call kernel32::GetCurrentProcess()p.s |
| 177 | System::Call kernel32::IsWow64Process(ps,*i0s) |
| 178 | Pop $_LOGICLIB_TEMP |
| 179 | !insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}` |
| 180 | !macroend |
| 181 | |
| 182 | !define RunningX64 `"" RunningX64 ""` |
| 183 | !macro _RunningX64 _a _b _t _f |
| 184 | !if ${NSIS_PTR_SIZE} > 4 |
| 185 | !insertmacro LogicLib_JumpToBranch `${_t}` `${_f}` |
| 186 | !else |
| 187 | !insertmacro _IsWow64 `${_a}` `${_b}` `${_t}` `${_f}` |
| 188 | !endif |
| 189 | !macroend |
| 190 | |
| 191 | !define DisableX64FSRedirection "!insertmacro DisableX64FSRedirection" |
| 192 | !macro DisableX64FSRedirection |
| 193 | System::Call kernel32::Wow64EnableWow64FsRedirection(i0) |
| 194 | !macroend |
| 195 | |
| 196 | !define EnableX64FSRedirection "!insertmacro EnableX64FSRedirection" |
| 197 | !macro EnableX64FSRedirection |
| 198 | System::Call kernel32::Wow64EnableWow64FsRedirection(i1) |
| 199 | !macroend |
| 200 | |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 201 | |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 202 | # Need admin to write to C:\Windows\System32 and install dir |
| 203 | RequestExecutionLevel admin |
| 204 | |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 205 | Function .onInit |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 206 | |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 207 | !ifdef UNINSTALLER |
| 208 | ; Write out the uinstaller and quit |
| 209 | WriteUninstaller "$%TEMP%\Uninstall${PRODUCTNAME}.exe" |
| 210 | Quit |
| 211 | !endif |
| 212 | |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 213 | FunctionEnd |
| 214 | |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 215 | AddBrandingImage left 150 |
| 216 | Caption "${PRODUCTNAME} ${PRODUCTVERSION} Setup" |
| 217 | Name "${PRODUCTNAME} ${PRODUCTVERSION}" |
David Pinedo | 41eb93f | 2016-01-29 12:20:49 -0700 | [diff] [blame] | 218 | LIcenseData "VULKANRT_LICENSE.rtf" |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 219 | Page custom brandimage "" ": Brand Image" |
David Pinedo | 41eb93f | 2016-01-29 12:20:49 -0700 | [diff] [blame] | 220 | Page license |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 221 | Page directory |
| 222 | Page instfiles |
| 223 | UninstallCaption "\${PRODUCTNAME} ${PRODUCTVERSION} Uninstall" |
| 224 | UninstallText "This wizard will uninstall ${PRODUCTNAME} ${PRODUCTVERSION} from your computer. Click Uninstall to start the uninstallation." |
| 225 | UninstPage custom un.brandimage "" ": Brand Image" |
| 226 | UninstPage uninstConfirm |
| 227 | UninstPage instFiles |
| 228 | |
David Pinedo | 3797633 | 2016-02-10 16:20:45 -0700 | [diff] [blame] | 229 | # File Properties |
| 230 | VIProductVersion "${PRODUCTVERSION}" |
| 231 | VIAddVersionKey "ProductName" "Vulkan Runtime" |
| 232 | VIAddVersionKey "FileVersion" "${PRODUCTVERSION}" |
| 233 | VIAddVersionKey "ProductVersion" "${PRODUCTVERSION}" |
| 234 | VIAddVersionKey "FileDescription" "Vulkan Runtime Installer" |
| 235 | VIAddVersionKey "LegalCopyright" "" |
| 236 | |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 237 | # Start default section |
| 238 | Section |
| 239 | |
David Pinedo | ef68bbe | 2016-03-29 13:46:12 -0600 | [diff] [blame] | 240 | # Turn on logging |
| 241 | LogSet on |
| 242 | |
| 243 | # Remove contents of temp dir |
| 244 | SetOutPath "$TEMP\VulkanRT" |
| 245 | RmDir /R "$TEMP\VulkanRT" |
| 246 | |
Mark Young | a8557b8 | 2016-01-15 16:01:46 -0700 | [diff] [blame] | 247 | # If running on a 64-bit OS machine, disable registry re-direct since we're running as a 32-bit executable. |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 248 | ${If} ${RunningX64} |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 249 | |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 250 | ${DisableX64FSRedirection} |
| 251 | SetRegView 64 |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 252 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 253 | ${Endif} |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 254 | |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 255 | # Create our temp directory, with minimal permissions |
| 256 | SetOutPath "$TEMP\VulkanRT" |
| 257 | AccessControl::DisableFileInheritance $TEMP\VulkanRT |
| 258 | AccessControl::SetFileOwner $TEMP\VulkanRT "Administrators" |
| 259 | AccessControl::ClearOnFile $TEMP\VulkanRT "Administrators" "FullAccess" |
| 260 | AccessControl::SetOnFile $TEMP\VulkanRT "SYSTEM" "FullAccess" |
| 261 | AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "ListDirectory" |
| 262 | AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "GenericExecute" |
| 263 | AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "GenericRead" |
| 264 | AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "ReadAttributes" |
| 265 | StrCpy $1 10 |
| 266 | Call CheckForError |
| 267 | |
| 268 | # Check the registry to see if we are already installed |
David Pinedo | 5580597 | 2016-02-08 12:20:11 -0700 | [diff] [blame] | 269 | ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir" |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 270 | |
| 271 | # If the registry entry isn't there, it will throw an error as well as return a blank value. So, clear the errors. |
| 272 | ${If} ${Errors} |
| 273 | |
| 274 | # Nothing else to do since there is no previous install |
| 275 | ClearErrors |
| 276 | |
| 277 | ${Else} |
| 278 | |
| 279 | # Use the previous install directory, so we don't have to keep tracking every possible runtime install. |
| 280 | strcmp $INSTDIR $0 notinstalled |
| 281 | |
| 282 | ${If} $0 != "" |
David Pinedo | 4ccea8a | 2016-02-11 13:49:09 -0700 | [diff] [blame] | 283 | MessageBox MB_OK "The Windows Vulkan Runtime is already installed to $0. It will be re-installed to the same folder." /SD IDOK |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 284 | Strcpy $INSTDIR $0 |
| 285 | ${Endif} |
| 286 | |
| 287 | notinstalled: |
| 288 | |
| 289 | ${EndIf} |
David Pinedo | 5580597 | 2016-02-08 12:20:11 -0700 | [diff] [blame] | 290 | |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 291 | SetOutPath "$INSTDIR" |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 292 | AccessControl::DisableFileInheritance $INSTDIR |
| 293 | AccessControl::SetFileOwner $INSTDIR "Administrators" |
| 294 | AccessControl::ClearOnFile $INSTDIR "Administrators" "FullAccess" |
| 295 | AccessControl::SetOnFile $INSTDIR "SYSTEM" "FullAccess" |
| 296 | AccessControl::GrantOnFile $INSTDIR "Everyone" "ListDirectory" |
| 297 | AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericExecute" |
| 298 | AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericRead" |
| 299 | AccessControl::GrantOnFile $INSTDIR "Everyone" "ReadAttributes" |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 300 | File ${ICOFILE} |
| 301 | File VULKANRT_LICENSE.RTF |
David Pinedo | 70d08eb | 2016-02-05 14:45:15 -0700 | [diff] [blame] | 302 | File LICENSE.txt |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 303 | File ConfigLayersAndVulkanDLL.ps1 |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 304 | StrCpy $1 15 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 305 | Call CheckForError |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 306 | |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 307 | # Add the signed uninstaller |
| 308 | !ifndef UNINSTALLER |
| 309 | SetOutPath $INSTDIR |
| 310 | File "Uninstall${PRODUCTNAME}.exe" |
| 311 | !endif |
| 312 | |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 313 | StrCpy $1 20 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 314 | Call CheckForError |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 315 | |
| 316 | # Reference count the number of times we have been installed. |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 317 | # The reference count is stored in the registry value InstallCount |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 318 | ReadRegDword $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" |
| 319 | IntOp $1 $1 + 1 |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 320 | StrCpy $IC $1 |
| 321 | |
| 322 | # We need to create a new folder for each install. Since we are using counted installs, |
| 323 | # an uninstall when the count is greater than one would result in the install |
| 324 | # count being decremented and nothing being removed. But Windows Add/Remove Programs |
| 325 | # generates a warning Window if the install dir for a package that is removed is not |
| 326 | # deleted. So we create a unique folder for each counted install. |
| 327 | # We fudge it a little and only create one folder, and rename it after each |
| 328 | # install/uninstall. |
| 329 | |
| 330 | # Create the install instance folder. We rename the install instance folder if it already exists. |
| 331 | # Then copy the uninstaller to it. |
| 332 | ${If} $IC > 2 |
| 333 | IntOp $1 $IC - 1 |
| 334 | Rename "$INSTDIR\Instance_$1" "$INSTDIR\Instance_$IC" |
| 335 | CopyFiles /SILENT "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$INSTDIR\Instance_$IC" |
| 336 | ${ElseIf} $IC = 2 |
| 337 | CreateDirectory "$INSTDIR\Instance_$IC" |
| 338 | CopyFiles /SILENT "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$INSTDIR\Instance_$IC" |
| 339 | ${EndIf} |
| 340 | |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 341 | |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 342 | # If the registry entry isn't there, it will throw an error as well as return a blank value. So, clear the errors. |
| 343 | ${If} ${Errors} |
| 344 | ClearErrors |
| 345 | ${EndIf} |
| 346 | |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 347 | # Modify registry for Programs and Features |
| 348 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayName" "Vulkan Run Time Libraries ${PRODUCTVERSION}" |
| 349 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "UninstallString" "$INSTDIR\Uninstall${PRODUCTNAME}.exe" |
David Pinedo | 5580597 | 2016-02-08 12:20:11 -0700 | [diff] [blame] | 350 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "Publisher" "${PUBLISHER}" |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 351 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayVersion" "${PRODUCTVERSION}" |
| 352 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "EstimatedSize" ${ESTIMATEDSIZE} |
| 353 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayIcon" "$\"$INSTDIR\${ICOFILE}$\"" |
David Pinedo | 5580597 | 2016-02-08 12:20:11 -0700 | [diff] [blame] | 354 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir" "$INSTDIR" |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 355 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" $IC |
| 356 | |
| 357 | ${If} $IC > 1 |
| 358 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayName" "Vulkan Run Time Libraries ${PRODUCTVERSION}" |
| 359 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "UninstallString" "$INSTDIR\Instance_$IC\Uninstall${PRODUCTNAME}.exe" |
| 360 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "Publisher" "${PUBLISHER}" |
| 361 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayVersion" "${PRODUCTVERSION}" |
| 362 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "EstimatedSize" ${ESTIMATEDSIZE} |
| 363 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayIcon" "$\"$INSTDIR\${ICOFILE}$\"" |
| 364 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "InstallDir" "$INSTDIR\Instance_$IC" |
| 365 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "InstallCount" $IC |
| 366 | ${EndIf} |
| 367 | |
| 368 | # Set SystemComponent to 1 for those instances that are not to be visible to Add/Remove Programs. |
| 369 | # Set SystemComponent to 0 for the instance that is to be visible to Add/Remove Programs. |
| 370 | ${If} $IC > 2 |
| 371 | IntOp $1 $IC - 1 |
| 372 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "SystemComponent" 0 |
| 373 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$1" "SystemComponent" 1 |
| 374 | ${ElseIf} $IC = 2 |
| 375 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "SystemComponent" 0 |
| 376 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "SystemComponent" 1 |
| 377 | ${Else} |
| 378 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "SystemComponent" 0 |
| 379 | ${EndIf} |
| 380 | |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 381 | StrCpy $1 25 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 382 | Call CheckForError |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 383 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 384 | # Set up version number for file names |
| 385 | ${StrRep} $0 ${VERSION_BUILDNO} "." "-" |
| 386 | StrCpy $FileVersion ${VERSION_ABI_MAJOR}-${VERSION_API_MAJOR}-${VERSION_MINOR}-${VERSION_PATCH}-$0 |
| 387 | |
David Pinedo | f2c7ed9 | 2016-03-29 16:29:00 -0600 | [diff] [blame^] | 388 | # Complete remove the Vulkan Start Menu. Prior version of the Vulkan RT |
| 389 | # created Start Menu items, we don't do that anymore. |
David Pinedo | cf29063 | 2016-03-03 12:36:24 -0700 | [diff] [blame] | 390 | SetShellVarContext all |
David Pinedo | f2c7ed9 | 2016-03-29 16:29:00 -0600 | [diff] [blame^] | 391 | RmDir /R "$SMPROGRAMS\Vulkan" |
David Pinedo | cf29063 | 2016-03-03 12:36:24 -0700 | [diff] [blame] | 392 | ClearErrors |
| 393 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 394 | # If running on a 64-bit OS machine |
| 395 | ${If} ${RunningX64} |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 396 | |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 397 | # 32-bit DLLs/EXEs destined for SysWOW64 |
| 398 | ########################################## |
| 399 | SetOutPath $WINDIR\SysWow64 |
| 400 | File /oname=vulkan-$FileVersion.dll ..\build32\loader\Release\vulkan-${VERSION_ABI_MAJOR}.dll |
| 401 | File /oname=vulkaninfo-$FileVersion.exe ..\build32\demos\Release\vulkaninfo.exe |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 402 | StrCpy $1 30 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 403 | Call CheckForError |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 404 | |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 405 | # 64-bit DLLs/EXEs |
| 406 | ########################################## |
| 407 | SetOutPath $WINDIR\System32 |
| 408 | File /oname=vulkan-$FileVersion.dll ..\build\loader\Release\vulkan-${VERSION_ABI_MAJOR}.dll |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 409 | StrCpy $1 35 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 410 | Call CheckForError |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 411 | |
| 412 | # vulkaninfo.exe |
| 413 | File /oname=vulkaninfo-$FileVersion.exe ..\build\demos\Release\vulkaninfo.exe |
| 414 | SetOutPath "$INSTDIR" |
| 415 | File ..\build\demos\Release\vulkaninfo.exe |
Mark Young | c60de9c | 2016-01-25 09:46:50 -0700 | [diff] [blame] | 416 | File /oname=vulkaninfo32.exe ..\build32\demos\Release\vulkaninfo.exe |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 417 | StrCpy $1 40 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 418 | Call CheckForError |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 419 | |
| 420 | # Run the ConfigLayersAndVulkanDLL.ps1 script to copy the most recent version of |
| 421 | # vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry |
| 422 | # entries to use layers from the corresponding SDK |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 423 | nsExec::ExecToStack 'powershell -NoLogo -NonInteractive -WindowStyle Hidden -inputformat none -ExecutionPolicy RemoteSigned -File ConfigLayersAndVulkanDLL.ps1 ${VERSION_ABI_MAJOR} 64' |
David Pinedo | a6d46a8 | 2016-02-12 12:23:57 -0700 | [diff] [blame] | 424 | pop $PsErr |
| 425 | ${If} $PsErr != 0 |
| 426 | SetErrors |
| 427 | ${EndIf} |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 428 | StrCpy $1 45 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 429 | Call CheckForError |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 430 | |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 431 | # Else, running on a 32-bit OS machine |
| 432 | ${Else} |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 433 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 434 | # 32-bit DLLs/EXEs destined for SysWOW64 |
| 435 | ########################################## |
| 436 | SetOutPath $WINDIR\System32 |
| 437 | File /oname=vulkan-$FileVersion.dll ..\build32\loader\Release\vulkan-${VERSION_ABI_MAJOR}.dll |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 438 | StrCpy $1 50 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 439 | Call CheckForError |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 440 | |
| 441 | # vulkaninfo.exe |
| 442 | File /oname=vulkaninfo-$FileVersion.exe ..\build32\demos\Release\vulkaninfo.exe |
| 443 | SetOutPath "$INSTDIR" |
| 444 | File ..\build32\demos\Release\vulkaninfo.exe |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 445 | StrCpy $1 55 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 446 | Call CheckForError |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 447 | |
| 448 | # Run the ConfigLayersAndVulkanDLL.ps1 script to copy the most recent version of |
| 449 | # vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry |
| 450 | # entries to use layers from the corresponding SDK |
| 451 | nsExec::ExecToStack 'powershell -NoLogo -NonInteractive -WindowStyle Hidden -inputformat none -ExecutionPolicy RemoteSigned -File ConfigLayersAndVulkanDLL.ps1 ${VERSION_ABI_MAJOR} 32' |
David Pinedo | a6d46a8 | 2016-02-12 12:23:57 -0700 | [diff] [blame] | 452 | pop $PsErr |
| 453 | ${If} $PsErr != 0 |
| 454 | SetErrors |
| 455 | ${EndIf} |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 456 | StrCpy $1 60 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 457 | Call CheckForError |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 458 | |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 459 | ${Endif} |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 460 | |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 461 | # We are done using ConfigLayersAndVulkanDLL.ps1, delete it. It will be re-installed |
| 462 | # by the uninstaller when it needs to be run again during uninstall. |
| 463 | Delete ConfigLayersAndVulkanDLL.ps1 |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 464 | |
| 465 | # Possibly install MSVC 2013 redistributables |
David Pinedo | 89845c4 | 2016-03-15 16:42:14 -0600 | [diff] [blame] | 466 | ClearErrors |
Mark Young | afc7c9b | 2016-02-12 13:56:56 -0700 | [diff] [blame] | 467 | ${If} ${RunningX64} |
Mark Young | afc7c9b | 2016-02-12 13:56:56 -0700 | [diff] [blame] | 468 | ReadRegDword $1 HKLM "SOFTWARE\WOW6432Node\Microsoft\DevDiv\vc\Servicing\12.0\RuntimeMinimum" "Install" |
David Pinedo | 89845c4 | 2016-03-15 16:42:14 -0600 | [diff] [blame] | 469 | ${If} ${Errors} |
| 470 | StrCpy $1 0 |
| 471 | ClearErrors |
| 472 | ${Endif} |
Mark Young | afc7c9b | 2016-02-12 13:56:56 -0700 | [diff] [blame] | 473 | ${Else} |
David Pinedo | 89845c4 | 2016-03-15 16:42:14 -0600 | [diff] [blame] | 474 | StrCpy $1 1 |
Mark Young | afc7c9b | 2016-02-12 13:56:56 -0700 | [diff] [blame] | 475 | ${Endif} |
David Pinedo | 89845c4 | 2016-03-15 16:42:14 -0600 | [diff] [blame] | 476 | ReadRegDword $2 HKLM "SOFTWARE\Microsoft\DevDiv\vc\Servicing\12.0\RuntimeMinimum" "Install" |
| 477 | ${If} ${Errors} |
| 478 | StrCpy $2 0 |
| 479 | ClearErrors |
| 480 | ${Endif} |
| 481 | IntOp $3 $1 + $2 |
| 482 | ${If} $3 <= 1 |
| 483 | # If either x86 or x64 redistributables are not present, install redistributables. |
| 484 | # We install both resdistributables because we have found that the x86 redist |
| 485 | # will uninstall the x64 redist if the x64 redistrib is an old version. Amazing, isn't it? |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 486 | SetOutPath "$TEMP\VulkanRT" |
David Pinedo | 89845c4 | 2016-03-15 16:42:14 -0600 | [diff] [blame] | 487 | ${If} ${RunningX64} |
| 488 | File vcredist_x64.exe |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 489 | ExecWait '"$TEMP\VulkanRT\vcredist_x64.exe" /quiet /norestart' |
David Pinedo | 89845c4 | 2016-03-15 16:42:14 -0600 | [diff] [blame] | 490 | ${Endif} |
| 491 | File vcredist_x86.exe |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 492 | ExecWait '"$TEMP\VulkanRT\vcredist_x86.exe" /quiet /norestart' |
David Pinedo | 89845c4 | 2016-03-15 16:42:14 -0600 | [diff] [blame] | 493 | ${Endif} |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 494 | StrCpy $1 65 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 495 | Call CheckForError |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 496 | |
David Pinedo | ef68bbe | 2016-03-29 13:46:12 -0600 | [diff] [blame] | 497 | # Finish logging and move log file to TEMP dir |
| 498 | LogSet off |
| 499 | Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\Install.log" |
| 500 | |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 501 | SectionEnd |
| 502 | |
| 503 | # Uninstaller section start |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 504 | !ifdef UNINSTALLER |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 505 | Section "uninstall" |
| 506 | |
David Pinedo | ef68bbe | 2016-03-29 13:46:12 -0600 | [diff] [blame] | 507 | # Turn on logging |
| 508 | LogSet on |
| 509 | |
| 510 | # Remove contents of temp dir |
| 511 | SetOutPath "$TEMP\VulkanRT" |
| 512 | RmDir /R "$TEMP\VulkanRT" |
| 513 | |
Mark Young | a8557b8 | 2016-01-15 16:01:46 -0700 | [diff] [blame] | 514 | # If running on a 64-bit OS machine, disable registry re-direct since we're running as a 32-bit executable. |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 515 | ${If} ${RunningX64} |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 516 | |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 517 | ${DisableX64FSRedirection} |
| 518 | SetRegView 64 |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 519 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 520 | ${Endif} |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 521 | |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 522 | # Look up the install dir and remove files from that directory. |
| 523 | # We do this so that the uninstaller can be run from any directory. |
| 524 | ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir" |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 525 | StrCpy $IDir $0 |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 526 | |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 527 | StrCpy $1 70 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 528 | Call un.CheckForError |
| 529 | |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 530 | SetOutPath "$IDir" |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 531 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 532 | # Set up version number for file names |
| 533 | ${StrRep} $0 ${VERSION_BUILDNO} "." "-" |
| 534 | StrCpy $FileVersion ${VERSION_ABI_MAJOR}-${VERSION_API_MAJOR}-${VERSION_MINOR}-${VERSION_PATCH}-$0 |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 535 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 536 | # Decrement the number of times we have been installed. |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 537 | ReadRegDword $IC HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" |
| 538 | IntOp $1 $IC - 1 |
David Pinedo | b4d7f6a | 2016-01-27 14:15:25 -0700 | [diff] [blame] | 539 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" $1 |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 540 | |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 541 | # Rename the install dir for this instance if is not the last uninstall |
| 542 | ${If} $IC > 2 |
| 543 | IntOp $1 $IC - 1 |
| 544 | Rename "$IDir\Instance_$IC" "$IDir\Instance_$1" |
| 545 | ${ElseIf} $IC = 2 |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 546 | Delete /REBOOTOK "$IDir\Instance_$IC\Uninstall${PRODUCTNAME}.exe" |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 547 | Rmdir /REBOOTOK "$IDir\Instance_$IC" |
| 548 | ${Endif} |
| 549 | |
| 550 | # Modify registry for Programs and Features |
David Pinedo | cf29063 | 2016-03-03 12:36:24 -0700 | [diff] [blame] | 551 | |
| 552 | ${If} $IC > 1 |
| 553 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" |
| 554 | ${EndIf} |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 555 | ${If} $IC > 2 |
| 556 | IntOp $IC $IC - 1 |
| 557 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "SystemComponent" 0 |
| 558 | ${ElseIf} $IC = 2 |
| 559 | WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "SystemComponent" 0 |
| 560 | ${Else} |
| 561 | # Last uninstall |
| 562 | IntOp $IC $IC - 1 |
| 563 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" |
| 564 | ${EndIf} |
| 565 | |
David Pinedo | d133b78 | 2016-03-16 14:41:56 -0600 | [diff] [blame] | 566 | |
| 567 | # Install the ConfigLayersAndVulkanDLL.ps1 so we can run it. |
| 568 | # It will be deleted later when we remove the install directory. |
| 569 | File ConfigLayersAndVulkanDLL.ps1 |
| 570 | |
| 571 | # If running on a 64-bit OS machine |
| 572 | ${If} ${RunningX64} |
| 573 | |
| 574 | # Delete vulkaninfo.exe in C:\Windows\System32 and C:\Windows\SysWOW64 |
| 575 | Delete /REBOOTOK $WINDIR\SysWow64\vulkaninfo.exe |
| 576 | Delete /REBOOTOK "$WINDIR\SysWow64\vulkaninfo-$FileVersion.exe" |
| 577 | Delete /REBOOTOK $WINDIR\System32\vulkaninfo.exe |
| 578 | Delete /REBOOTOK "$WINDIR\System32\vulkaninfo-$FileVersion.exe" |
| 579 | |
| 580 | # Delete vullkan dll files: vulkan-<majorabi>.dll and vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll |
| 581 | Delete /REBOOTOK $WINDIR\SysWow64\vulkan-${VERSION_ABI_MAJOR}.dll |
| 582 | Delete /REBOOTOK $WINDIR\SysWow64\vulkan-$FileVersion.dll |
| 583 | Delete /REBOOTOK $WINDIR\System32\vulkan-${VERSION_ABI_MAJOR}.dll |
| 584 | Delete /REBOOTOK $WINDIR\System32\vulkan-$FileVersion.dll |
| 585 | |
| 586 | # Run the ConfigLayersAndVulkanDLL.ps1 script to: |
| 587 | # Copy the most recent version of vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll |
| 588 | # Copy the most recent version of vulkaninfo-<abimajor>-*.exe to vulkaninfo.exe |
| 589 | # Set up layer registry entries to use layers from the corresponding SDK |
| 590 | nsExec::ExecToStack 'powershell -NoLogo -NonInteractive -WindowStyle Hidden -inputformat none -ExecutionPolicy RemoteSigned -File "$IDir\ConfigLayersAndVulkanDLL.ps1" ${VERSION_ABI_MAJOR} 64' |
| 591 | |
| 592 | # Else, running on a 32-bit OS machine |
| 593 | ${Else} |
| 594 | |
| 595 | # Delete vulkaninfo.exe in C:\Windows\System32 |
| 596 | Delete /REBOOTOK $WINDIR\System32\vulkaninfo.exe |
| 597 | Delete /REBOOTOK "$WINDIR\System32\vulkaninfo-$FileVersion.exe" |
| 598 | |
| 599 | # Delete vullkan dll files: vulkan-<majorabi>.dll and vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll |
| 600 | Delete /REBOOTOK $WINDIR\System32\vulkan-${VERSION_ABI_MAJOR}.dll |
| 601 | Delete /REBOOTOK $WINDIR\System32\vulkan-$FileVersion.dll |
| 602 | |
| 603 | # Run the ConfigLayersAndVulkanDLL.ps1 script to: |
| 604 | # Copy the most recent version of vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll |
| 605 | # Copy the most recent version of vulkaninfo-<abimajor>-*.exe to vulkaninfo.exe |
| 606 | # Set up layer registry entries to use layers from the corresponding SDK |
| 607 | nsExec::ExecToStack 'powershell -NoLogo -NonInteractive -WindowStyle Hidden -inputformat none -ExecutionPolicy RemoteSigned -File "$IDir\ConfigLayersAndVulkanDLL.ps1" ${VERSION_ABI_MAJOR} 32' |
| 608 | |
| 609 | ${EndIf} |
| 610 | |
| 611 | # If Ref Count is zero, uninstall everything |
David Pinedo | 9d09277 | 2016-02-09 14:44:05 -0700 | [diff] [blame] | 612 | ${If} $IC <= 0 |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 613 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 614 | # Remove files in install dir |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 615 | Delete /REBOOTOK "$IDir\VULKANRT_LICENSE.rtf" |
| 616 | Delete /REBOOTOK "$IDir\LICENSE.txt" |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 617 | Delete /REBOOTOK "$IDir\Uninstall${PRODUCTNAME}.exe" |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 618 | Delete /REBOOTOK "$IDir\V.ico" |
| 619 | Delete /REBOOTOK "$IDir\ConfigLayersAndVulkanDLL.ps1" |
| 620 | Delete /REBOOTOK "$IDir\vulkaninfo.exe" |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 621 | |
Mark Young | f7c705b | 2016-01-26 13:36:28 -0700 | [diff] [blame] | 622 | # If running on a 64-bit OS machine |
| 623 | ${If} ${RunningX64} |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 624 | Delete /REBOOTOK "$IDir\vulkaninfo32.exe" |
Mark Young | f7c705b | 2016-01-26 13:36:28 -0700 | [diff] [blame] | 625 | ${EndIf} |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 626 | |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 627 | StrCpy $1 75 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 628 | Call un.CheckForError |
| 629 | |
David Pinedo | 32eb2ec | 2016-02-09 09:15:34 -0700 | [diff] [blame] | 630 | # Need to do a SetOutPath to something outside of install dir, |
| 631 | # or the uninstall will think install dir is busy |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 632 | SetOutPath "$TEMP" |
| 633 | |
| 634 | # Remove install directories |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 635 | StrCpy $0 "$IDir" |
| 636 | Call un.DeleteDirIfEmpty |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 637 | StrCpy $0 "$PROGRAMFILES\${PRODUCTNAME}" |
| 638 | Call un.DeleteDirIfEmpty |
David Pinedo | cf29063 | 2016-03-03 12:36:24 -0700 | [diff] [blame] | 639 | ClearErrors |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 640 | |
| 641 | # If any of the remove commands failed, request a reboot |
Mark Young | 0368c7d | 2016-02-02 10:56:42 -0700 | [diff] [blame] | 642 | IfRebootFlag 0 noreboot |
| 643 | MessageBox MB_YESNO "A reboot is required to finish the uninstall. Do you wish to reboot now?" /SD IDNO IDNO returnerror |
| 644 | Reboot |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 645 | |
Mark Young | 0368c7d | 2016-02-02 10:56:42 -0700 | [diff] [blame] | 646 | returnerror: |
David Pinedo | 1e368f7 | 2016-02-04 17:04:44 -0700 | [diff] [blame] | 647 | |
Mark Young | 0368c7d | 2016-02-02 10:56:42 -0700 | [diff] [blame] | 648 | # Set an error message to output because we should reboot but didn't (whether because silent uninstall or user choice) |
| 649 | SetErrorLevel 3 # ERROR_TOO_MANY_OPEN_FILES |
| 650 | |
Mark Young | 4b8b548 | 2016-01-15 15:09:39 -0700 | [diff] [blame] | 651 | noreboot: |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 652 | |
Mark Young | dd9eca7 | 2016-01-15 14:11:32 -0700 | [diff] [blame] | 653 | ${Endif} |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 654 | |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 655 | StrCpy $1 80 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 656 | Call un.CheckForError |
| 657 | |
David Pinedo | ef68bbe | 2016-03-29 13:46:12 -0600 | [diff] [blame] | 658 | # Finish logging and move log file to TEMP dir |
| 659 | LogSet off |
| 660 | Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\Uninstall.log" |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 661 | |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 662 | SectionEnd |
David Pinedo | 5925ba0 | 2016-03-03 21:25:45 -0700 | [diff] [blame] | 663 | !endif |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 664 | |
| 665 | Function brandimage |
| 666 | SetOutPath "$TEMP" |
David Pinedo | f79938f | 2016-02-02 16:10:39 -0700 | [diff] [blame] | 667 | SetFileAttributes V.bmp temporary |
| 668 | File V.bmp |
| 669 | SetBrandingImage "$TEMP/V.bmp" |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 670 | Functionend |
| 671 | |
| 672 | |
| 673 | Function un.brandimage |
| 674 | SetOutPath "$TEMP" |
David Pinedo | f79938f | 2016-02-02 16:10:39 -0700 | [diff] [blame] | 675 | SetFileAttributes V.bmp temporary |
| 676 | File V.bmp |
| 677 | SetBrandingImage "$TEMP/V.bmp" |
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 678 | Functionend |
| 679 | |
| 680 | Function un.DeleteDirIfEmpty |
| 681 | FindFirst $R0 $R1 "$0\*.*" |
| 682 | strcmp $R1 "." 0 NoDelete |
| 683 | FindNext $R0 $R1 |
| 684 | strcmp $R1 ".." 0 NoDelete |
| 685 | ClearErrors |
| 686 | FindNext $R0 $R1 |
| 687 | IfErrors 0 NoDelete |
| 688 | FindClose $R0 |
| 689 | Sleep 1000 |
| 690 | RMDir "$0" |
| 691 | NoDelete: |
| 692 | FindClose $R0 |
| 693 | FunctionEnd |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 694 | |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 695 | # Check for errors during install. If we hit an error, stop, uninstall what we've put in so far, and quit. |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 696 | # NOTE: We return a non-zero error code as well. |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 697 | Function CheckForError |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 698 | ${If} ${Errors} |
| 699 | # IHV's using this install may want no message box. |
David Pinedo | a6d46a8 | 2016-02-12 12:23:57 -0700 | [diff] [blame] | 700 | MessageBox MB_OK|MB_ICONSTOP "${errorMessage1}${errorMessage2}Errorcode: $1$\r$\n" /SD IDOK |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 701 | |
David Pinedo | ef68bbe | 2016-03-29 13:46:12 -0600 | [diff] [blame] | 702 | # Finish logging and move log file to TEMP dir |
| 703 | LogSet off |
| 704 | Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\install.log" |
| 705 | |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 706 | # Copy the uninstaller to a temp folder of our own creation so we can completely |
| 707 | # delete the old contents. |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 708 | SetOutPath "$TEMP\VulkanRT" |
| 709 | CopyFiles "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$TEMP\VulkanRT" |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 710 | |
| 711 | # No uninstall using the version in the temporary folder. |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 712 | ExecWait '"$TEMP\VulkanRT\Uninstall${PRODUCTNAME}.exe" /S _?=$INSTDIR' |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 713 | |
| 714 | # Delete the copy of the uninstaller we ran |
David Pinedo | 7f44f4f | 2016-03-18 13:15:27 -0600 | [diff] [blame] | 715 | Delete /REBOOTOK "$TEMP\VulkanRT\Uninstall${PRODUCTNAME}.exe" |
| 716 | RmDir /R /REBOOTOK "$TEMP\VulkanRT" |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 717 | |
| 718 | # Set an error message to output |
David Pinedo | a6d46a8 | 2016-02-12 12:23:57 -0700 | [diff] [blame] | 719 | SetErrorLevel $1 |
Mark Young | f1bdefc | 2016-01-29 16:09:29 -0700 | [diff] [blame] | 720 | |
| 721 | Quit |
| 722 | ${EndIf} |
| 723 | FunctionEnd |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 724 | |
| 725 | # Check for errors during uninstall. If we hit an error, don't attempt |
| 726 | # to do anything. Just set a non-zero return code and quit. |
| 727 | Function un.CheckForError |
| 728 | ${If} ${Errors} |
| 729 | # IHV's using this install may want no message box. |
David Pinedo | e80978b | 2016-02-13 14:06:55 -0700 | [diff] [blame] | 730 | MessageBox MB_OK|MB_ICONSTOP "${errorMessage1un}${errorMessage2}Errorcode: $1$\r$\n" /SD IDOK |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 731 | |
| 732 | # Set an error message to output |
David Pinedo | a6d46a8 | 2016-02-12 12:23:57 -0700 | [diff] [blame] | 733 | SetErrorLevel $1 |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 734 | |
David Pinedo | ef68bbe | 2016-03-29 13:46:12 -0600 | [diff] [blame] | 735 | # Finish logging and move log file to TEMP dir |
| 736 | LogSet off |
| 737 | Delete "$TEMP\VulkanRT\Uninstall.log" |
| 738 | Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\Uninstall.log" |
| 739 | |
David Pinedo | 6ab257c | 2016-02-10 11:03:29 -0700 | [diff] [blame] | 740 | Quit |
| 741 | ${EndIf} |
| 742 | FunctionEnd |