mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-22 00:13:09 +08:00
feat(installer): add architecture compatibility check to NSIS installer (#8587)
- Implemented a function to check system and application architecture compatibility. - Added error handling to notify users of architecture mismatches during installation. - Enhanced the custom initialization macro to include architecture checks before proceeding with installation.
This commit is contained in:
parent
536aa68389
commit
57065a1831
@ -8,16 +8,93 @@
|
|||||||
; https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist
|
; https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist
|
||||||
|
|
||||||
!include LogicLib.nsh
|
!include LogicLib.nsh
|
||||||
|
!include x64.nsh
|
||||||
|
|
||||||
; https://github.com/electron-userland/electron-builder/issues/1122
|
; https://github.com/electron-userland/electron-builder/issues/1122
|
||||||
!ifndef BUILD_UNINSTALLER
|
!ifndef BUILD_UNINSTALLER
|
||||||
Function checkVCRedist
|
Function checkVCRedist
|
||||||
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
|
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
|
Function checkArchitectureCompatibility
|
||||||
|
; Initialize variables
|
||||||
|
StrCpy $0 "0" ; Default to incompatible
|
||||||
|
StrCpy $1 "" ; System architecture
|
||||||
|
StrCpy $3 "" ; App architecture
|
||||||
|
|
||||||
|
; Check system architecture using built-in NSIS functions
|
||||||
|
${If} ${RunningX64}
|
||||||
|
; Check if it's ARM64 by looking at processor architecture
|
||||||
|
ReadEnvStr $2 "PROCESSOR_ARCHITECTURE"
|
||||||
|
ReadEnvStr $4 "PROCESSOR_ARCHITEW6432"
|
||||||
|
|
||||||
|
${If} $2 == "ARM64"
|
||||||
|
${OrIf} $4 == "ARM64"
|
||||||
|
StrCpy $1 "arm64"
|
||||||
|
${Else}
|
||||||
|
StrCpy $1 "x64"
|
||||||
|
${EndIf}
|
||||||
|
${Else}
|
||||||
|
StrCpy $1 "x86"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Determine app architecture based on build variables
|
||||||
|
!ifdef APP_ARM64_NAME
|
||||||
|
!ifndef APP_64_NAME
|
||||||
|
StrCpy $3 "arm64" ; App is ARM64 only
|
||||||
|
!endif
|
||||||
|
!endif
|
||||||
|
!ifdef APP_64_NAME
|
||||||
|
!ifndef APP_ARM64_NAME
|
||||||
|
StrCpy $3 "x64" ; App is x64 only
|
||||||
|
!endif
|
||||||
|
!endif
|
||||||
|
!ifdef APP_64_NAME
|
||||||
|
!ifdef APP_ARM64_NAME
|
||||||
|
StrCpy $3 "universal" ; Both architectures available
|
||||||
|
!endif
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; If no architecture variables are defined, assume x64
|
||||||
|
${If} $3 == ""
|
||||||
|
StrCpy $3 "x64"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Compare system and app architectures
|
||||||
|
${If} $3 == "universal"
|
||||||
|
; Universal build, compatible with all architectures
|
||||||
|
StrCpy $0 "1"
|
||||||
|
${ElseIf} $1 == $3
|
||||||
|
; Architectures match
|
||||||
|
StrCpy $0 "1"
|
||||||
|
${Else}
|
||||||
|
; Architectures don't match
|
||||||
|
StrCpy $0 "0"
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
!macro customInit
|
!macro customInit
|
||||||
Push $0
|
Push $0
|
||||||
|
Push $1
|
||||||
|
Push $2
|
||||||
|
Push $3
|
||||||
|
Push $4
|
||||||
|
|
||||||
|
; Check architecture compatibility first
|
||||||
|
Call checkArchitectureCompatibility
|
||||||
|
${If} $0 != "1"
|
||||||
|
MessageBox MB_ICONEXCLAMATION "\
|
||||||
|
Architecture Mismatch$\r$\n$\r$\n\
|
||||||
|
This installer is not compatible with your system architecture.$\r$\n\
|
||||||
|
Your system: $1$\r$\n\
|
||||||
|
App architecture: $3$\r$\n$\r$\n\
|
||||||
|
Please download the correct version from:$\r$\n\
|
||||||
|
https://www.cherry-ai.com/"
|
||||||
|
ExecShell "open" "https://www.cherry-ai.com/"
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
Call checkVCRedist
|
Call checkVCRedist
|
||||||
${If} $0 != "1"
|
${If} $0 != "1"
|
||||||
MessageBox MB_YESNO "\
|
MessageBox MB_YESNO "\
|
||||||
@ -43,5 +120,9 @@
|
|||||||
Abort
|
Abort
|
||||||
${EndIf}
|
${EndIf}
|
||||||
ContinueInstall:
|
ContinueInstall:
|
||||||
|
Pop $4
|
||||||
|
Pop $3
|
||||||
|
Pop $2
|
||||||
|
Pop $1
|
||||||
Pop $0
|
Pop $0
|
||||||
!macroend
|
!macroend
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user