Skip to content

Commit

Permalink
Fixed Java downlaod then drifted away
Browse files Browse the repository at this point in the history
Fixed Java Download
Added Java Version check (Version needs to match Installer)
Changed Temp-Directory for easier CleanUp
If WebView2 is found, it is not ReadOnly anymore so User can select to Run the Installer of WebView2 anyway.
unlogisch04 committed Apr 1, 2024
1 parent abc7e94 commit b8229df
Showing 1 changed file with 75 additions and 41 deletions.
116 changes: 75 additions & 41 deletions windows/web/slimevr_web_installer.nsi
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ Unicode True
!include FileFunc.nsh ; For GetTime function
!include .\plugins\NsProcess\NsProcess.nsh ; For Check on SteamVR
#!include WinMessages.nsh
!include TextFunc.nsh ; For ConfigRead
!include MUI2.nsh
!include .\steamdetect.nsh

@@ -15,6 +16,13 @@ Unicode True
!define MUI_HEADERIMAGE_BITMAP "logo.bmp"
!define MUI_HEADERIMAGE_BITMAP_STRETCH "NoStretchNoCrop"
!define MUI_HEADERIMAGE_RIGHT
!define SLIMETEMP "$TEMP\SlimeVRInstaller"

# Define the Java Version Strings and to Check (JRE\relase -> JAVA_RUNTIME_VERSION=)
!define JREVersion "17.0.10+7"
!define JREDownloadURL "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.10%2B7/OpenJDK17U-jre_x64_windows_hotspot_17.0.10_7.zip"
!define JREDownloadedFileZip "OpenJDK17U-jre_x64_windows_hotspot_17.0.10_7.zip"
Var JREneedInstall

Var /GLOBAL SteamVRResult
Var /GLOBAL SteamVRLabelID
@@ -86,15 +94,7 @@ FunctionEnd

# Clean up on exit
Function cleanTemp
Delete "$TEMP\slimevr-openvr-driver-win64.zip"
Delete "$TEMP\SlimeVR-win64.zip"
Delete "$TEMP\OpenJDK17U-jre_x64_windows_hotspot_17.0.4.1_1.zip"
Delete "$TEMP\SlimeVR-Feeder-App-win64.zip"
RMDir /r "$TEMP\slimevr-openvr-driver-win64"
RMDir /r "$TEMP\SlimeVR"
RMDir /r "$TEMP\OpenJDK17U-jre_x64_windows_hotspot_17.0.4.1_1"
RMDir /r "$TEMP\slimevr_usb_drivers_inst"
RMDir /r "$TEMP\SlimeVR-Feeder-App-win64"
RMDir /r "${SLIMETEMP}"
FunctionEnd

Function .onInstFailed
@@ -281,6 +281,23 @@ Function installerActionPre
${EndIf}
FunctionEnd

# Provides a easy function to determit if the JRE is the desired Version or not
Function JREdetect
IfFileExists "$INSTDIR\jre\release" 0 SEC_JRE_JAVAVERSIONELSE
${ConfigRead} "$INSTDIR\jre\release" "JAVA_RUNTIME_VERSION=" $R0
; DetailPrint "Java JRE: $INSTDIR\jre\release JAVA_RUNTIME_VERSION=$R0"
${If} $R0 == "$\"${JREVersion}$\""
StrCpy $JREneedInstall "False"
${Else}
StrCpy $JREneedInstall "True"
${EndIf}
Goto SEC_JRE_JAVAVERSIONDONE
SEC_JRE_JAVAVERSIONELSE:
StrCpy $JREneedInstall "True"
; DetailPrint "Java JRE: $INSTDIR\jre\release File Not Found"
SEC_JRE_JAVAVERSIONDONE:
FunctionEnd

# GetTime function macro to get datetime
!insertmacro GetTime

@@ -370,14 +387,14 @@ Section "SlimeVR Server" SEC_SERVER
SetOutPath $INSTDIR

DetailPrint "Downloading SlimeVR Server..."
NScurl::http GET "https://github.com/SlimeVR/SlimeVR-Server/releases/latest/download/SlimeVR-win64.zip" "$TEMP\SlimeVR-win64.zip" /CANCEL /RESUME /END
NScurl::http GET "https://github.com/SlimeVR/SlimeVR-Server/releases/latest/download/SlimeVR-win64.zip" "${SLIMETEMP}\SlimeVR-win64.zip" /CANCEL /RESUME /END
Pop $0 ; Status text ("OK" for success)
${If} $0 != "OK"
Abort "Failed to download SlimeVR Server. Reason: $0."
${EndIf}
DetailPrint "Downloaded!"

nsisunz::Unzip "$TEMP\SlimeVR-win64.zip" "$TEMP\SlimeVR\"
nsisunz::Unzip "${SLIMETEMP}\SlimeVR-win64.zip" "${SLIMETEMP}\SlimeVR\"
Pop $0
DetailPrint "Unzipping finished with $0."

@@ -386,7 +403,7 @@ Section "SlimeVR Server" SEC_SERVER
${EndIf}

DetailPrint "Copying SlimeVR Server to installation folder..."
CopyFiles /SILENT "$TEMP\SlimeVR\SlimeVR\*" $INSTDIR
CopyFiles /SILENT "${SLIMETEMP}\SlimeVR\SlimeVR\*" $INSTDIR

IfFileExists "$INSTDIR\slimevr-ui.exe" found not_found
found:
@@ -406,10 +423,10 @@ Section "Webview2" SEC_WEBVIEW

# Read Only protects it from Installing when it is not needed
DetailPrint "Downloading webview2!"
NScurl::http GET "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" /CANCEL /RESUME /END
NScurl::http GET "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "${SLIMETEMP}\MicrosoftEdgeWebView2RuntimeInstaller.exe" /CANCEL /RESUME /END

DetailPrint "Installing webview2!"
nsExec::ExecToLog '"$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" /silent /install' $0
nsExec::ExecToLog '"${SLIMETEMP}\MicrosoftEdgeWebView2RuntimeInstaller.exe" /silent /install' $0
Pop $0
DetailPrint "Installing finished with $0."
${If} $0 != 0
@@ -421,42 +438,50 @@ SectionEnd
Section "Java JRE" SEC_JRE
SectionIn RO

Var /GLOBAL DownloadedJreFile
DetailPrint "Downloading Java JRE 17..."
NScurl::http GET "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.10%2B7/OpenJDK17U-jre_x64_windows_hotspot_17.0.10_7.zip" "$TEMP\OpenJDK17U-jre_x64_windows_hotspot_17.0.4.1_1.zip" /CANCEL /RESUME /END
StrCpy $DownloadedJreFile "OpenJDK17U-jre_x64_windows_hotspot_17.0.10_7"
DetailPrint "Downloading Java JRE ${JREVersion}..."
NScurl::http GET "${JREDownloadURL}" "${SLIMETEMP}\${JREDownloadedFileZip}" /CANCEL /RESUME /END

Pop $0 ; Status text ("OK" for success)
${If} $0 != "OK"
Abort "Failed to download Java JRE 17. Reason: $0."
Abort "Failed to download Java JRE ${JREVersion}. Reason: $0."
${EndIf}
DetailPrint "Downloaded!"

# Make sure to delete all files on a update from jre, so if there is a new version no old files are left.
${If} $SELECTED_INSTALLER_ACTION == "update"
DetailPrint "Removing Java JRE 17..."
# Make sure to delete all files on a update from jre, so if there is a new version no old files are left.
IfFileExists "$INSTDIR\jre" 0 SEC_JRE_DIRNOTFOUND
DetailPrint "Removing old Java JRE..."
RMdir /r "$INSTDIR\jre"
${EndIf}
CreateDirectory "$INSTDIR\jre"
SEC_JRE_DIRNOTFOUND:

DetailPrint "Unzipping Java JRE 17 to installation folder...."
nsisunz::Unzip "$TEMP\$DownloadedJreFile.zip" "$TEMP\$DownloadedJreFile\"
DetailPrint "Unzipping Java JRE ${JREVersion} to installation folder...."
nsisunz::Unzip "${SLIMETEMP}\${JREDownloadedFileZip}" "${SLIMETEMP}\OpenJDK\"
Pop $0
DetailPrint "Unzipping finished with $0."
CopyFiles /SILENT "$TEMP\$DownloadedJreFile\jdk-17.0.10+7-jre\*" "$INSTDIR\jre"

FindFirst $0 $1 "${SLIMETEMP}\OpenJDK\jdk-17.*-jre"
loop:
StrCmp $1 "" done
CopyFiles /SILENT "${SLIMETEMP}\OpenJDK\$1\*" "$INSTDIR\jre"
FindNext $0 $1
Goto loop
done:
FindClose $0
SectionEnd

Section "SteamVR Driver" SEC_VRDRIVER
SetOutPath $INSTDIR

DetailPrint "Downloading SteamVR Driver..."
NScurl::http GET "https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-win64.zip" "$TEMP\slimevr-openvr-driver-win64.zip" /CANCEL /RESUME /END
NScurl::http GET "https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-win64.zip" "${SLIMETEMP}\slimevr-openvr-driver-win64.zip" /CANCEL /RESUME /END
Pop $0 ; Status text ("OK" for success)
${If} $0 != "OK"
Abort "Failed to download SteamVR Driver. Reason: $0."
${EndIf}
DetailPrint "Downloaded!"

DetailPrint "Unpacking downloaded files..."
nsisunz::Unzip "$TEMP\slimevr-openvr-driver-win64.zip" "$TEMP\slimevr-openvr-driver-win64\"
nsisunz::Unzip "${SLIMETEMP}\slimevr-openvr-driver-win64.zip" "${SLIMETEMP}\slimevr-openvr-driver-win64\"
Pop $0
DetailPrint "Unzipping finished with $0."

@@ -466,7 +491,7 @@ Section "SteamVR Driver" SEC_VRDRIVER
DetailPrint "Copying SteamVR Driver to SteamVR..."
# If powershell is present - rely on automatic detection.
${DisableX64FSRedirection}
nsExec::ExecToLog '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -File "$INSTDIR\steamvr.ps1" -SteamPath "$STEAMDIR" -DriverPath "$TEMP\slimevr-openvr-driver-win64\slimevr"' $0
nsExec::ExecToLog '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -File "$INSTDIR\steamvr.ps1" -SteamPath "$STEAMDIR" -DriverPath "${SLIMETEMP}\slimevr-openvr-driver-win64\slimevr"' $0
${EnableX64FSRedirection}
Pop $0
${If} $0 != 0
@@ -475,28 +500,28 @@ Section "SteamVR Driver" SEC_VRDRIVER
${If} $0 == "error"
Abort "Failed to copy SlimeVR Driver."
${Endif}
CopyFiles /SILENT "$TEMP\slimevr-openvr-driver-win64\slimevr" "$0\drivers\slimevr"
CopyFiles /SILENT "${SLIMETEMP}\slimevr-openvr-driver-win64\slimevr" "$0\drivers\slimevr"
${EndIf}
SectionEnd

Section "SlimeVR Feeder App" SEC_FEEDER_APP
SetOutPath $INSTDIR

DetailPrint "Downloading SlimeVR Feeder App..."
NScurl::http GET "https://github.com/SlimeVR/SlimeVR-Feeder-App/releases/latest/download/SlimeVR-Feeder-App-win64.zip" "$TEMP\SlimeVR-Feeder-App-win64.zip" /CANCEL /RESUME /END
NScurl::http GET "https://github.com/SlimeVR/SlimeVR-Feeder-App/releases/latest/download/SlimeVR-Feeder-App-win64.zip" "${SLIMETEMP}\SlimeVR-Feeder-App-win64.zip" /CANCEL /RESUME /END
Pop $0 ; Status text ("OK" for success)
${If} $0 != "OK"
Abort "Failed to download SlimeVR Feeder App. Reason: $0."
${EndIf}
DetailPrint "Downloaded!"

DetailPrint "Unpacking downloaded files..."
nsisunz::Unzip "$TEMP\SlimeVR-Feeder-App-win64.zip" "$TEMP"
nsisunz::Unzip "${SLIMETEMP}\SlimeVR-Feeder-App-win64.zip" "${SLIMETEMP}"
Pop $0
DetailPrint "Unzipping finished with $0."

DetailPrint "Copying SlimeVR Feeder App..."
CopyFiles /SILENT "$TEMP\SlimeVR-Feeder-App-win64\*" "$INSTDIR\Feeder-App"
CopyFiles /SILENT "${SLIMETEMP}\SlimeVR-Feeder-App-win64\*" "$INSTDIR\Feeder-App"

DetailPrint "Installing SlimeVR Feeder App driver..."
nsExec::ExecToLog '"$INSTDIR\Feeder-App\SlimeVR-Feeder-App.exe" --install'
@@ -506,11 +531,11 @@ SectionGroup /e "USB drivers" SEC_USBDRIVERS

Section "CP210x driver" SEC_CP210X
# CP210X drivers (NodeMCU v2)
SetOutPath "$TEMP\slimevr_usb_drivers_inst\CP201x"
SetOutPath "${SLIMETEMP}\slimevr_usb_drivers_inst\CP201x"
DetailPrint "Installing CP210x driver..."
File /r "CP201x\*"
${DisableX64FSRedirection}
nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "$TEMP\slimevr_usb_drivers_inst\CP201x\silabser.inf"' $0
nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "${SLIMETEMP}\slimevr_usb_drivers_inst\CP201x\silabser.inf"' $0
${EnableX64FSRedirection}
Pop $0
${If} $0 == 0
@@ -526,11 +551,11 @@ SectionGroup /e "USB drivers" SEC_USBDRIVERS

Section "CH340 driver" SEC_CH340
# CH340 drivers (NodeMCU v3)
SetOutPath "$TEMP\slimevr_usb_drivers_inst\CH341SER"
SetOutPath "${SLIMETEMP}\slimevr_usb_drivers_inst\CH341SER"
DetailPrint "Installing CH340 driver..."
File /r "CH341SER\*"
${DisableX64FSRedirection}
nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "$TEMP\slimevr_usb_drivers_inst\CH341SER\CH341SER.INF"' $0
nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "${SLIMETEMP}\slimevr_usb_drivers_inst\CH341SER\CH341SER.INF"' $0
${EnableX64FSRedirection}
Pop $0
${If} $0 == 0
@@ -546,11 +571,11 @@ SectionGroup /e "USB drivers" SEC_USBDRIVERS

Section /o "CH9102x driver" SEC_CH9102X
# CH343 drivers (NodeMCU v2.1, some NodeMCU v3?)
SetOutPath "$TEMP\slimevr_usb_drivers_inst\CH343SER"
SetOutPath "${SLIMETEMP}\slimevr_usb_drivers_inst\CH343SER"
DetailPrint "Installing CH910x driver..."
File /r "CH343SER\*"
${DisableX64FSRedirection}
nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "$TEMP\slimevr_usb_drivers_inst\CH343SER\CH343SER.INF"' $0
nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "${SLIMETEMP}\slimevr_usb_drivers_inst\CH343SER\CH343SER.INF"' $0
${EnableX64FSRedirection}
Pop $0
${If} $0 == 0
@@ -612,10 +637,10 @@ Section
SectionEnd

Function componentsPre
Call JREdetect
${If} $SELECTED_INSTALLER_ACTION == "update"
SectionSetFlags ${SEC_FIREWALL} 0
SectionSetFlags ${SEC_REGISTERAPP} 0
SectionSetFlags ${SEC_JRE} ${SF_SELECTED}
SectionSetFlags ${SEC_WEBVIEW} ${SF_SELECTED}
SectionSetFlags ${SEC_USBDRIVERS} ${SF_SECGRP}
SectionSetFlags ${SEC_SERVER} ${SF_SELECTED}
@@ -629,6 +654,15 @@ Function componentsPre
SectionSetFlags ${SEC_FEEDER_APP} ${SF_SELECTED}
${EndIf}

# Select JRE Mandatory if not found or outdated on Repair Preselect it
${If} $JREneedInstall == "True"
SectionSetFlags ${SEC_JRE} ${SF_SELECTED}|${SF_RO}
${ElseIf} $SELECTED_INSTALLER_ACTION == "repair"
SectionSetFlags ${SEC_JRE} ${SF_SELECTED}
${Else}
SectionSetFlags ${SEC_JRE} ${SF_USELECTED}
${EndIf}

# Detect WebView2
# https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#detect-if-a-suitable-webview2-runtime-is-already-installed
# Trying to solve #41 Installer doesn't always install WebView2
@@ -659,7 +693,7 @@ Function componentsPre
${AndIf} $1 == ""
SectionSetFlags ${SEC_WEBVIEW} ${SF_SELECTED}|${SF_RO}
${Else}
SectionSetFlags ${SEC_WEBVIEW} ${SF_USELECTED}|${SF_RO}
SectionSetFlags ${SEC_WEBVIEW} ${SF_USELECTED}
${EndIf}

FunctionEnd

0 comments on commit b8229df

Please sign in to comment.