NSIS: misc fixes [wip] (#3300)

NSIS: misc fixes
This commit is contained in:
ctrlaltca 2018-06-25 18:34:58 +02:00 committed by GitHub
parent 87eb132af1
commit dc727cb620
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 11 deletions

View file

@ -1,5 +1,6 @@
version: 2.6.0-branch-{branch}-build-{build}
#BUILD!!!
# Skipping commits affecting specific files (GitHub only).
# More details here: https://www.appveyor.com/docs/appveyor-yml and https://www.appveyor.com/docs/how-to/filtering-commits
skip_commits:

View file

@ -210,6 +210,11 @@ if(UNIX)
endif()
elseif(WIN32)
set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR})
if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
set(TRICE_IS_64_BIT 1)
else()
set(TRICE_IS_64_BIT 0)
endif()
# Configure file with custom definitions for NSIS.
configure_file(

View file

@ -1 +1,2 @@
!define NSIS_SOURCE_PATH "@PROJECT_SOURCE_DIR@"
!define NSIS_IS_64_BIT @TRICE_IS_64_BIT@

View file

@ -3,9 +3,6 @@ Name "@CPACK_PACKAGE_NAME@"
BrandingText "@CPACK_PACKAGE_FILE_NAME@"
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
!define UNINSTKEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice"
!define DEFAULTNORMALDESTINATON "$ProgramFiles\Cockatrice"
!define DEFAULTPORTABLEDESTINATON "$Desktop\CockatricePortable"
!define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
RequestExecutionlevel highest
@ -18,6 +15,7 @@ Var PortableMode
!include LogicLib.nsh
!include FileFunc.nsh
!include MUI2.nsh
!include x64.nsh
!define MUI_ABORTWARNING
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\cmake\leftimage.bmp"
@ -46,8 +44,19 @@ Page Custom PortableModePageCreate PortableModePageLeave
!insertmacro MUI_LANGUAGE English
Function .onInit
StrCpy $NormalDestDir "${DEFAULTNORMALDESTINATON}"
StrCpy $PortableDestDir "${DEFAULTPORTABLEDESTINATON}"
${If} ${NSIS_IS_64_BIT} == 1
${IfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONEXCLAMATION "This version of Cockatrice requires a 64-bit Windows system."
Abort
${EndIf}
StrCpy $NormalDestDir "$ProgramFiles64\Cockatrice"
SetRegView 64
${Else}
StrCpy $NormalDestDir "$ProgramFiles\Cockatrice"
${EndIf}
StrCpy $PortableDestDir "$Desktop\CockatricePortable"
${GetParameters} $9
@ -83,6 +92,13 @@ Call SetModeDestinationFromInstdir
FunctionEnd
Function un.onInit
${If} ${NSIS_IS_64_BIT} == 1
SetRegView 64
${EndIf}
FunctionEnd
Function RequireAdmin
UserInfo::GetAccountType
@ -190,21 +206,29 @@ ${If} $PortableMode = 0
WriteUninstaller "$INSTDIR\uninstall.exe"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayName" "Cockatrice"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayIcon" "$INSTDIR\cockatrice.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayName" "Cockatrice"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayVersion" "@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "EstimatedSize" "$0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "InstallLocation" "$INSTDIR"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "NoModify" "1"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "NoRepair" "1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "Publisher" "Cockatrice team"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "VersionMajor" "@CPACK_PACKAGE_VERSION_MAJOR@"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "VersionMinor" "@CPACK_PACKAGE_VERSION_MINOR@"
IfFileExists "$INSTDIR\vc_redist.x86.exe" VcRedist86Exists PastVcRedist86Check
VcRedist86Exists:
ExecWait '"$INSTDIR\vc_redist.x86.exe" /passive /norestart'
Delete "$INSTDIR\vc_redist.x86.exe"
PastVcRedist86Check:
IfFileExists "$INSTDIR\vc_redist.x64.exe" VcRedist64Exists PastVcRedist64Check
VcRedist64Exists:
ExecWait '"$INSTDIR\vc_redist.x64.exe" /passive /norestart'
Delete "$INSTDIR\vc_redist.x64.exe"
PastVcRedist64Check:
${Else}