mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 14:36:15 -05:00
128 lines
4.2 KiB
NSIS
128 lines
4.2 KiB
NSIS
Unicode true
|
|
RequestExecutionLevel admin
|
|
!include "MUI2.nsh"
|
|
!include "x64.nsh"
|
|
!include "FileFunc.nsh"
|
|
|
|
!ifndef PAYLOAD_DIR
|
|
!error "PAYLOAD_DIR is required"
|
|
!endif
|
|
!ifndef OUTPUT_FILE
|
|
!error "OUTPUT_FILE is required"
|
|
!endif
|
|
!ifndef PRODUCT_VERSION
|
|
!error "PRODUCT_VERSION is required"
|
|
!endif
|
|
!ifndef TARGET_ARCH
|
|
!define TARGET_ARCH "x64"
|
|
!endif
|
|
!ifndef BUILD_VERSION
|
|
!define BUILD_VERSION "${PRODUCT_VERSION}.0"
|
|
!endif
|
|
!ifndef DISPLAY_VERSION
|
|
!define DISPLAY_VERSION "${PRODUCT_VERSION}"
|
|
!endif
|
|
!ifdef SIGN_SCRIPT
|
|
!uninstfinalize 'pwsh -NoLogo -NoProfile -NonInteractive -File "${SIGN_SCRIPT}" -Files "%1"' = 0
|
|
!finalize 'pwsh -NoLogo -NoProfile -NonInteractive -File "${SIGN_SCRIPT}" -Files "%1"' = 0
|
|
!endif
|
|
|
|
Name "GP Connect"
|
|
OutFile "${OUTPUT_FILE}"
|
|
InstallDir "$PROGRAMFILES64\GP Connect"
|
|
VIProductVersion "${BUILD_VERSION}"
|
|
VIAddVersionKey "ProductName" "GP Connect"
|
|
VIAddVersionKey "FileDescription" "GP Connect Installer"
|
|
VIAddVersionKey "ProductVersion" "${DISPLAY_VERSION}"
|
|
VIAddVersionKey "FileVersion" "${BUILD_VERSION}"
|
|
VIAddVersionKey "LegalCopyright" "GP Connect contributors"
|
|
ShowInstDetails show
|
|
ShowUninstDetails show
|
|
Var InstallAction
|
|
!define MUI_ICON "${__FILEDIR__}\..\..\apps\gpauth\icons\windows\icon.ico"
|
|
!define MUI_UNICON "${MUI_ICON}"
|
|
!define MUI_WELCOMEFINISHPAGE_BITMAP "${__FILEDIR__}\sidebar.bmp"
|
|
!define MUI_ABORTWARNING
|
|
!define MUI_FINISHPAGE_TITLE "GP Connect is ready"
|
|
!define MUI_FINISHPAGE_TEXT "Open GP Connect from the Start menu."
|
|
!define MUI_WELCOMEPAGE_TITLE "$InstallAction GP Connect"
|
|
!define MUI_WELCOMEPAGE_TEXT "$InstallAction GP Connect for all users on this computer.$\r$\n$\r$\nClick $InstallAction to continue."
|
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE ConfirmInstall
|
|
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowInstallAction
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
!insertmacro MUI_PAGE_FINISH
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
!insertmacro MUI_LANGUAGE "English"
|
|
|
|
Function .onInit
|
|
!if "${TARGET_ARCH}" == "arm64"
|
|
${IfNot} ${IsNativeARM64}
|
|
MessageBox MB_OK|MB_ICONSTOP "This GP Connect installer requires Windows 11 on ARM64." /SD IDOK
|
|
SetErrorLevel 1
|
|
Abort
|
|
${EndIf}
|
|
!else if "${TARGET_ARCH}" == "x64"
|
|
${IfNot} ${IsNativeAMD64}
|
|
MessageBox MB_OK|MB_ICONSTOP "This GP Connect installer requires x64 Windows." /SD IDOK
|
|
SetErrorLevel 1
|
|
Abort
|
|
${EndIf}
|
|
!else
|
|
!error "Unsupported TARGET_ARCH"
|
|
!endif
|
|
SetRegView 64
|
|
StrCpy $InstallAction "Install"
|
|
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPConnect" "DisplayVersion"
|
|
${If} $0 != ""
|
|
StrCpy $InstallAction "Update"
|
|
${EndIf}
|
|
FunctionEnd
|
|
|
|
Function ConfirmInstall
|
|
${GetParameters} $0
|
|
ClearErrors
|
|
${GetOptions} $0 "/UPDATE" $1
|
|
${IfNot} ${Errors}
|
|
Abort
|
|
${EndIf}
|
|
FunctionEnd
|
|
|
|
Function ShowInstallAction
|
|
GetDlgItem $0 $HWNDPARENT 1
|
|
SendMessage $0 ${WM_SETTEXT} 0 "STR:$InstallAction"
|
|
FunctionEnd
|
|
|
|
Section "Install"
|
|
InitPluginsDir
|
|
SetOutPath "$PLUGINSDIR\payload"
|
|
File /r "${PAYLOAD_DIR}\*"
|
|
WriteUninstaller "$PLUGINSDIR\payload\uninstall.exe"
|
|
SetOutPath "$PLUGINSDIR"
|
|
File "${__FILEDIR__}\machine-install.ps1"
|
|
DetailPrint "Preparing GP Connect and waiting for open windows to close..."
|
|
nsExec::ExecToLog '"$WINDIR\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$PLUGINSDIR\machine-install.ps1" -Action Install -SourceDirectory "$PLUGINSDIR\payload" -Version "${PRODUCT_VERSION}" -ConsumeSource'
|
|
Pop $0
|
|
${If} $0 != 0
|
|
MessageBox MB_OK|MB_ICONSTOP "GP Connect could not be installed. See the details below and try again." /SD IDOK
|
|
SetErrorLevel 1
|
|
Abort
|
|
${EndIf}
|
|
SectionEnd
|
|
|
|
Section "Uninstall"
|
|
SetRegView 64
|
|
InitPluginsDir
|
|
SetOutPath "$PLUGINSDIR"
|
|
File "${__FILEDIR__}\machine-install.ps1"
|
|
DetailPrint "Waiting for GP Connect and sign-in windows to close..."
|
|
nsExec::ExecToLog '"$WINDIR\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$PLUGINSDIR\machine-install.ps1" -Action Uninstall'
|
|
Pop $0
|
|
${If} $0 != 0
|
|
MessageBox MB_OK|MB_ICONSTOP "GP Connect could not be removed. See the details below and try again." /SD IDOK
|
|
SetErrorLevel 1
|
|
Abort
|
|
${EndIf}
|
|
SectionEnd
|