mirror of
https://github.com/H-uru/korman.git
synced 2025-07-14 02:27:36 -04:00
Fetch the Blender install from MSI registry
Somewhere around Blender 2.75, the SCONS build system was removed and CMake reigned supreme. The installer was of course changed to a Windows Installer generated by CPack. Unfortunately for us, the registry keys changed. Windows Installer's registry stuff sucks, but this is the easiest way for us to get at it.
This commit is contained in:
@ -4,10 +4,7 @@
|
|||||||
!include MUI2.nsh
|
!include MUI2.nsh
|
||||||
!include WinVer.nsh
|
!include WinVer.nsh
|
||||||
!include x64.nsh
|
!include x64.nsh
|
||||||
!include StrFunc.nsh
|
!include RegGuid.nsh
|
||||||
|
|
||||||
; Enable StrStr
|
|
||||||
${StrStr}
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; Installer Settings ;
|
; Installer Settings ;
|
||||||
@ -43,7 +40,12 @@ VIProductVersion "0.0.0.0"
|
|||||||
;;;;;;;;;;;;;
|
;;;;;;;;;;;;;
|
||||||
; Variables ;
|
; Variables ;
|
||||||
;;;;;;;;;;;;;
|
;;;;;;;;;;;;;
|
||||||
|
!define BlenderUpgradeCode "B767E4FD-7DE7-4094-B051-3AE62E13A17A"
|
||||||
|
!define UninstallRegKey "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||||
|
!define UpgradeRegKey "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes"
|
||||||
|
|
||||||
Var BlenderDir
|
Var BlenderDir
|
||||||
|
Var BlenderDirScanned
|
||||||
Var BlenderVer
|
Var BlenderVer
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;
|
||||||
@ -98,41 +100,52 @@ FunctionEnd
|
|||||||
; Tries to find the Blender directory in the registry.
|
; Tries to find the Blender directory in the registry.
|
||||||
Function FindBlenderDir
|
Function FindBlenderDir
|
||||||
; To prevent overwriting user data, we will only do this once
|
; To prevent overwriting user data, we will only do this once
|
||||||
StrCmp $BlenderDir "" 0 done
|
StrCmp $BlenderDirScanned "" 0 done
|
||||||
|
StrCpy $BlenderDirScanned "true"
|
||||||
|
|
||||||
; Try to grab the Blender directory from the default registry...
|
StrCpy $1 ""
|
||||||
ReadRegStr $BlenderDir HKLM "Software\BlenderFoundation" "Install_Dir"
|
find_product_code:
|
||||||
ReadRegStr $BlenderVer HKLM "Software\BlenderFoundation" "ShortVersion"
|
; Blender's CPack-generated MSI package has spewed mess into hidden registry keys.
|
||||||
|
; We know what the upgrade guid is, so we will use that to find the install directory
|
||||||
|
; and the Blender version.
|
||||||
|
${MangleGuidForRegistry} ${BlenderUpgradeCode} $0
|
||||||
|
EnumRegValue $0 HKLM "${UpgradeRegKey}\$0" 0
|
||||||
|
|
||||||
; Bad news, old chap, certain x86 Blender versions will write their registry keys to the
|
; If we are on a 64-bit system, we might not have found the product code guid in the 32-bit registry
|
||||||
; x64 registry. Dang! It looks like we will have to try to hack around that. But only if
|
; ergo, we will need to change over to that registry
|
||||||
; we got nothing...
|
|
||||||
${If} ${RunningX64}
|
${If} ${RunningX64}
|
||||||
StrCmp $BlenderDir "" try_again winning
|
IfErrors 0 find_uninstall_info
|
||||||
|
StrCmp $1 "" 0 done
|
||||||
|
StrCpy $1 "DEADBEEF"
|
||||||
|
|
||||||
try_again:
|
ClearErrors
|
||||||
SetRegView 64
|
SetRegView 64
|
||||||
ReadRegStr $BlenderDir HKLM "Software\BlenderFoundation" "Install_Dir"
|
Goto find_product_code
|
||||||
ReadRegStr $BlenderVer HKLM "Software\BlenderFoundation" "ShortVersion"
|
${Else}
|
||||||
SetRegView 32
|
Goto done
|
||||||
|
|
||||||
StrCmp $BlenderDir "" total_phailure
|
|
||||||
|
|
||||||
; Before we suggest this, let's make sure it's not Program Files (x64) version unleashed(TM)
|
|
||||||
StrCpy $0 "$PROGRAMFILES64\" ; Otherwise, it would match ALL Program Files directories...
|
|
||||||
${StrStr} $1 $BlenderDir $0
|
|
||||||
StrCmp $1 "" winning total_phailure
|
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
winning:
|
find_uninstall_info:
|
||||||
StrCpy $INSTDIR "$BlenderDir\$BlenderVer"
|
; Read the Blender directory and the versions from the uninstall record
|
||||||
Goto done
|
${UnmangleGuidFromRegistry} $0 $1
|
||||||
|
StrCpy $0 "${UninstallRegKey}\{$1}"
|
||||||
|
ReadRegStr $BlenderDir HKLM $0 "InstallLocation"
|
||||||
|
IfErrors done
|
||||||
|
ReadRegDWORD $1 HKLM $0 "VersionMajor"
|
||||||
|
ReadRegDWORD $2 HKLM $0 "VersionMinor"
|
||||||
|
StrCpy $BlenderVer "$1.$2"
|
||||||
|
|
||||||
total_phailure:
|
; Test our detected schtuff for validity
|
||||||
StrCpy $INSTDIR ""
|
; NOTE: Windows Installer puts a trailing slash on the end of directories!
|
||||||
Goto done
|
StrCpy $3 "$BlenderDir$BlenderVer"
|
||||||
|
IfFileExists "$3\*.*" 0 done
|
||||||
|
StrCpy $INSTDIR $3
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
ClearErrors
|
||||||
|
${If} ${RunningX64}
|
||||||
|
SetRegView 32
|
||||||
|
${EndIf}
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
;;;;;;;;;
|
;;;;;;;;;
|
||||||
|
91
installer/RegGuid.nsh
Normal file
91
installer/RegGuid.nsh
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
!macro StrAppendChar src_str src_idx dst_str
|
||||||
|
Push $R0
|
||||||
|
StrCpy $R0 ${src_str} 1 ${src_idx}
|
||||||
|
StrCpy ${dst_str} ${dst_str}$R0
|
||||||
|
Pop $R0
|
||||||
|
!macroend
|
||||||
|
!define StrAppendChar `!insertmacro StrAppendChar`
|
||||||
|
|
||||||
|
; Takes a Guid string and returns the mangled form found in Windows Installer registry values
|
||||||
|
; Input MUST contain dashes but no brackets enclosing the guid
|
||||||
|
!macro MangleGuidForRegistry src dst
|
||||||
|
StrCpy ${dst} ""
|
||||||
|
${StrAppendChar} ${src} 7 ${dst}
|
||||||
|
${StrAppendChar} ${src} 6 ${dst}
|
||||||
|
${StrAppendChar} ${src} 5 ${dst}
|
||||||
|
${StrAppendChar} ${src} 4 ${dst}
|
||||||
|
${StrAppendChar} ${src} 3 ${dst}
|
||||||
|
${StrAppendChar} ${src} 2 ${dst}
|
||||||
|
${StrAppendChar} ${src} 1 ${dst}
|
||||||
|
${StrAppendChar} ${src} 0 ${dst}
|
||||||
|
; Dash
|
||||||
|
${StrAppendChar} ${src} 12 ${dst}
|
||||||
|
${StrAppendChar} ${src} 11 ${dst}
|
||||||
|
${StrAppendChar} ${src} 10 ${dst}
|
||||||
|
${StrAppendChar} ${src} 9 ${dst}
|
||||||
|
; Dash
|
||||||
|
${StrAppendChar} ${src} 17 ${dst}
|
||||||
|
${StrAppendChar} ${src} 16 ${dst}
|
||||||
|
${StrAppendChar} ${src} 15 ${dst}
|
||||||
|
${StrAppendChar} ${src} 14 ${dst}
|
||||||
|
; Dash
|
||||||
|
${StrAppendChar} ${src} 20 ${dst}
|
||||||
|
${StrAppendChar} ${src} 19 ${dst}
|
||||||
|
${StrAppendChar} ${src} 22 ${dst}
|
||||||
|
${StrAppendChar} ${src} 21 ${dst}
|
||||||
|
; Dash
|
||||||
|
${StrAppendChar} ${src} 25 ${dst}
|
||||||
|
${StrAppendChar} ${src} 24 ${dst}
|
||||||
|
${StrAppendChar} ${src} 27 ${dst}
|
||||||
|
${StrAppendChar} ${src} 26 ${dst}
|
||||||
|
${StrAppendChar} ${src} 29 ${dst}
|
||||||
|
${StrAppendChar} ${src} 28 ${dst}
|
||||||
|
${StrAppendChar} ${src} 31 ${dst}
|
||||||
|
${StrAppendChar} ${src} 30 ${dst}
|
||||||
|
${StrAppendChar} ${src} 33 ${dst}
|
||||||
|
${StrAppendChar} ${src} 32 ${dst}
|
||||||
|
${StrAppendChar} ${src} 35 ${dst}
|
||||||
|
${StrAppendChar} ${src} 34 ${dst}
|
||||||
|
!macroend
|
||||||
|
!define MangleGuidForRegistry `!insertmacro MangleGuidForRegistry`
|
||||||
|
|
||||||
|
!macro UnmangleGuidFromRegistry src dst
|
||||||
|
StrCpy ${dst} ""
|
||||||
|
${StrAppendChar} ${src} 7 ${dst}
|
||||||
|
${StrAppendChar} ${src} 6 ${dst}
|
||||||
|
${StrAppendChar} ${src} 5 ${dst}
|
||||||
|
${StrAppendChar} ${src} 4 ${dst}
|
||||||
|
${StrAppendChar} ${src} 3 ${dst}
|
||||||
|
${StrAppendChar} ${src} 2 ${dst}
|
||||||
|
${StrAppendChar} ${src} 1 ${dst}
|
||||||
|
${StrAppendChar} ${src} 0 ${dst}
|
||||||
|
${StrAppendChar} "-" 0 ${dst}
|
||||||
|
${StrAppendChar} ${src} 11 ${dst}
|
||||||
|
${StrAppendChar} ${src} 10 ${dst}
|
||||||
|
${StrAppendChar} ${src} 9 ${dst}
|
||||||
|
${StrAppendChar} ${src} 8 ${dst}
|
||||||
|
${StrAppendChar} "-" 0 ${dst}
|
||||||
|
${StrAppendChar} ${src} 15 ${dst}
|
||||||
|
${StrAppendChar} ${src} 14 ${dst}
|
||||||
|
${StrAppendChar} ${src} 13 ${dst}
|
||||||
|
${StrAppendChar} ${src} 12 ${dst}
|
||||||
|
${StrAppendChar} "-" 0 ${dst}
|
||||||
|
${StrAppendChar} ${src} 17 ${dst}
|
||||||
|
${StrAppendChar} ${src} 16 ${dst}
|
||||||
|
${StrAppendChar} ${src} 19 ${dst}
|
||||||
|
${StrAppendChar} ${src} 18 ${dst}
|
||||||
|
${StrAppendChar} "-" 0 ${dst}
|
||||||
|
${StrAppendChar} ${src} 21 ${dst}
|
||||||
|
${StrAppendChar} ${src} 20 ${dst}
|
||||||
|
${StrAppendChar} ${src} 23 ${dst}
|
||||||
|
${StrAppendChar} ${src} 22 ${dst}
|
||||||
|
${StrAppendChar} ${src} 25 ${dst}
|
||||||
|
${StrAppendChar} ${src} 24 ${dst}
|
||||||
|
${StrAppendChar} ${src} 27 ${dst}
|
||||||
|
${StrAppendChar} ${src} 26 ${dst}
|
||||||
|
${StrAppendChar} ${src} 29 ${dst}
|
||||||
|
${StrAppendChar} ${src} 28 ${dst}
|
||||||
|
${StrAppendChar} ${src} 31 ${dst}
|
||||||
|
${StrAppendChar} ${src} 30 ${dst}
|
||||||
|
!macroend
|
||||||
|
!define UnmangleGuidFromRegistry `!insertmacro UnmangleGuidFromRegistry`
|
Reference in New Issue
Block a user