check OS arch and version in installer (#340)
This commit is contained in:
parent
54599d7c30
commit
acd9030374
|
@ -207,6 +207,7 @@ cd "${PACKAGE_DIR}"
|
|||
cp "${SOURCE_DIR}/platform/windows/qt.conf" .
|
||||
|
||||
cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" .
|
||||
cp "${SOURCE_DIR}/platform/windows/installer-scripts/utils.nsh" .
|
||||
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda.nsi" .
|
||||
popd
|
||||
|
||||
|
@ -225,6 +226,8 @@ nsis_flags=(
|
|||
-DFINALNAME="${SETUP_NAME}"
|
||||
-DMINGW32_COMPILER_NAME="${MINGW32_COMPILER_NAME}"
|
||||
-DMINGW64_COMPILER_NAME="${MINGW64_COMPILER_NAME}"
|
||||
-DREQUIRED_WINDOWS_BUILD=7600
|
||||
-DREQUIRED_WINDOWS_NAME="Windows 7"
|
||||
)
|
||||
if [[ ${COMPILER_MINGW32} -eq 1 ]]; then
|
||||
nsis_flags+=(-DHAVE_MINGW32)
|
||||
|
|
|
@ -24,6 +24,11 @@ LangString SectionMenuLaunchName 1033 "Create Start Menu shortcuts"
|
|||
LangString SectionDesktopLaunchName 1033 "Create Desktop shortcut"
|
||||
LangString SectionConfigName 1033 "Remove old configuration files"
|
||||
|
||||
LangString ErrorArchMismatch 1033 "Architecture mismatch. This package is for ${ARCH}, but the operating system is $osArch."
|
||||
LangString ErrorWindowsBuildRequired 1033 "Unsupported operating system. ${REQUIRED_WINDOWS_NAME} (${REQUIRED_WINDOWS_BUILD}) or later is required."
|
||||
|
||||
LangString WarningArchMismatch 1033 "Note: installing Red Panda C++ for ${ARCH} on $osArch OS. You may want to install native build instead."
|
||||
|
||||
/* Simplified Chinese 2052 */
|
||||
LangString MessageAppName 2052 "小熊猫C++"
|
||||
LangString MessageSectionMain 2052 "小熊猫C++ IDE (集成开发环境)"
|
||||
|
@ -49,3 +54,8 @@ LangString SectionShortcutsName 2052 "快捷方式"
|
|||
LangString SectionMenuLaunchName 2052 "创建开始菜单程序项"
|
||||
LangString SectionDesktopLaunchName 2052 "创建桌面快捷方式"
|
||||
LangString SectionConfigName 2052 "删除原有配置文件"
|
||||
|
||||
LangString ErrorArchMismatch 2052 "架构不匹配。此软件包适用于 ${ARCH},但操作系统是 $osArch。"
|
||||
LangString ErrorWindowsBuildRequired 2052 "不支持的操作系统。需要 ${REQUIRED_WINDOWS_NAME} (${REQUIRED_WINDOWS_BUILD}) 或更高版本。"
|
||||
|
||||
LangString WarningArchMismatch 2052 "注意:在 $osArch 操作系统上安装小熊猫 C++ ${ARCH} 版本。你可能想要安装本机版本。"
|
||||
|
|
|
@ -4,8 +4,13 @@ SetFont "Segoe UI" 11
|
|||
Unicode True
|
||||
!define DISPLAY_NAME "Red Panda C++ ${APP_VERSION} (${ARCH})"
|
||||
|
||||
!include "LogicLib.nsh"
|
||||
!include "MUI2.nsh"
|
||||
!include "WinVer.nsh"
|
||||
!include "x64.nsh"
|
||||
|
||||
!include "lang.nsh"
|
||||
!include "utils.nsh"
|
||||
|
||||
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
|
||||
|
||||
|
@ -288,6 +293,7 @@ SectionEnd
|
|||
|
||||
Function .onInit
|
||||
!insertmacro MUI_LANGDLL_DISPLAY
|
||||
!insertmacro DetectOsArch
|
||||
|
||||
IfFileExists "C:\Dev-Cpp\devcpp.exe" 0 +2
|
||||
SectionSetFlags ${SectionConfig} ${SF_SELECTED} # Remove old Dev-Cpp config files
|
||||
|
@ -303,7 +309,13 @@ Function .onInit
|
|||
!endif
|
||||
FunctionEnd
|
||||
|
||||
Function .onSelChange
|
||||
!insertmacro SectionAction_CheckMingw64
|
||||
FunctionEnd
|
||||
|
||||
Function myGuiInit
|
||||
!insertmacro CheckOsArch
|
||||
!insertmacro CheckOsBuild
|
||||
|
||||
; uninstall existing
|
||||
SetRegView 32
|
||||
|
@ -316,6 +328,8 @@ Function myGuiInit
|
|||
!else
|
||||
SetRegView 64
|
||||
!endif
|
||||
|
||||
!insertmacro SectionAction_CheckMingw64
|
||||
FunctionEnd
|
||||
|
||||
;backup file association
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
Var /GLOBAL osArch
|
||||
Var /GLOBAL sectionDepFlag
|
||||
Var /GLOBAL sectionDepTemp
|
||||
|
||||
!macro DetectOsArch
|
||||
${If} ${IsNativeIA32}
|
||||
StrCpy $osArch "x86"
|
||||
${ElseIf} ${IsNativeAMD64}
|
||||
StrCpy $osArch "x64"
|
||||
${ElseIf} ${IsNativeARM64}
|
||||
StrCpy $osArch "arm64"
|
||||
${Else}
|
||||
StrCpy $osArch "unknown"
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
!macro CheckOsArch
|
||||
; x64 cannot be installed on arm64 prior to Windows 11
|
||||
!if "${ARCH}" == "x64"
|
||||
${If} $osArch == "arm64"
|
||||
${AndIfNot} ${AtLeastBuild} 22000
|
||||
${OrIf} $osArch == "x86"
|
||||
MessageBox MB_OK|MB_ICONSTOP "$(ErrorArchMismatch)"
|
||||
Abort
|
||||
${EndIf}
|
||||
!endif
|
||||
|
||||
!if "${ARCH}" == "arm64"
|
||||
${If} $osArch != "arm64"
|
||||
MessageBox MB_OK|MB_ICONSTOP "$(ErrorArchMismatch)"
|
||||
Abort
|
||||
${EndIf}
|
||||
!endif
|
||||
|
||||
; warning if not matching
|
||||
${If} $osArch != "${ARCH}"
|
||||
MessageBox MB_OK|MB_ICONEXCLAMATION "$(WarningArchMismatch)"
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
!macro CheckOsBuild
|
||||
${IfNot} ${AtLeastBuild} ${REQUIRED_WINDOWS_BUILD}
|
||||
MessageBox MB_OK|MB_ICONSTOP "$(ErrorWindowsBuildRequired)"
|
||||
Abort
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
!macro DisableSection section
|
||||
SectionGetFlags ${section} $sectionDepFlag
|
||||
|
||||
; unset SF_SELECTED
|
||||
IntOp $sectionDepTemp ${SF_SELECTED} ~
|
||||
IntOp $sectionDepFlag $sectionDepFlag & $sectionDepTemp
|
||||
|
||||
; set SF_RO
|
||||
IntOp $sectionDepFlag $sectionDepFlag | ${SF_RO}
|
||||
|
||||
SectionSetFlags ${section} $sectionDepFlag
|
||||
!macroend
|
||||
|
||||
!macro SectionAction_CheckMingw64
|
||||
!ifdef HAVE_MINGW64
|
||||
${If} $osArch == "arm64"
|
||||
${AndIfNot} ${AtLeastBuild} 22000
|
||||
${OrIf} $osArch == "x86"
|
||||
!insertmacro DisableSection ${SectionMingw64}
|
||||
${EndIf}
|
||||
!endif
|
||||
!macroend
|
Loading…
Reference in New Issue