[host] Windows: multiple fixes to the installer

This commit is contained in:
Geoffrey McRae 2020-08-12 21:50:48 +10:00
parent 7dba6b9b08
commit 15d1a74291
5 changed files with 96 additions and 86 deletions

View File

@ -1 +1 @@
B2-rc3-21-g380b5df9f9+1 B2-rc3-30-g7dba6b9b08+1

View File

@ -44,11 +44,13 @@ cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-mingw64.cmake ..
make make
``` ```
## Building the installer ## Building the Windows installer
Install NSIS compiler Install NSIS compiler
Build the host program, see above sections. Build the host program, see above sections.
Build installer with `makensis c-host/installer/installer.nsi` Build installer with `makensis platform/Windows/installer.nsi`
The resulting installer will be at
`platform/Windows/looking-glass-host-setup.exe`
## Where is the log? ## Where is the log?

View File

@ -34,3 +34,9 @@ target_include_directories(platform_Windows
PRIVATE PRIVATE
src src
) )
# these are for the nsis installer generator
configure_file("${PROJECT_SOURCE_DIR}/installer.nsi" "${PROJECT_BINARY_DIR}/installer.nsi" COPYONLY)
configure_file("${PROJECT_TOP}/resources/icon.ico" "${PROJECT_BINARY_DIR}/icon.ico" COPYONLY)
configure_file("${PROJECT_TOP}/VERSION" "${PROJECT_BINARY_DIR}/VERSION" COPYONLY)
configure_file("${PROJECT_TOP}/LICENSE" "${PROJECT_BINARY_DIR}/LICENSE.txt" COPYONLY)

View File

@ -25,21 +25,21 @@ Place, Suite 330, Boston, MA 02111-1307 USA
!include "Sections.nsh" !include "Sections.nsh"
;Settings ;Settings
Name "Looking Glass Host" Name "Looking Glass (host)"
OutFile "..\build\looking-glass-host-setup.exe" OutFile "looking-glass-host-setup.exe"
Unicode true Unicode true
RequestExecutionLevel admin RequestExecutionLevel admin
ShowInstDetails "show" ShowInstDetails "show"
ShowUninstDetails "show" ShowUninstDetails "show"
InstallDir "$PROGRAMFILES64\Looking Glass" InstallDir "$PROGRAMFILES64\Looking Glass (host)"
!define MUI_ICON "..\..\resources\icon.ico" !define MUI_ICON "icon.ico"
!define MUI_UNICON "..\..\resources\icon.ico" !define MUI_UNICON "icon.ico"
!define MUI_LICENSEPAGE_BUTTON "Agree" !define MUI_LICENSEPAGE_BUTTON "Agree"
!define /file VERSION "..\..\VERSION" !define /file VERSION "VERSION"
;Install and uninstall pages ;Install and uninstall pages
!insertmacro MUI_PAGE_LICENSE "..\..\LICENSE" !insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
@ -49,94 +49,96 @@ InstallDir "$PROGRAMFILES64\Looking Glass"
Function ShowHelpMessage Function ShowHelpMessage
!define line1 "Command line options:$\r$\n$\r$\n" !define line1 "Command line options:$\r$\n$\r$\n"
!define line2 "/S - silent install (must be uppercase)$\r$\n" !define line2 "/S - silent install (must be uppercase)$\r$\n"
!define line3 "/D=path\to\install\folder - Change install directory$\r$\n" !define line3 "/D=path\to\install\folder - Change install directory$\r$\n"
!define line4 " (Must be uppercase, the last option given and no quotes)$\r$\n$\r$\n" !define line4 " (Must be uppercase, the last option given and no quotes)$\r$\n$\r$\n"
!define line5 "/startmenu - create start menu shortcut$\r$\n" !define line5 "/startmenu - create start menu shortcut$\r$\n"
!define line6 "/desktop - create desktop shortcut$\r$\n" !define line6 "/desktop - create desktop shortcut$\r$\n"
!define line7 "/noservice - do not create a service to auto start and elevate the host" !define line7 "/noservice - do not create a service to auto start and elevate the host"
MessageBox MB_OK "${line1}${line2}${line3}${line4}${line5}${line6}${line7}" MessageBox MB_OK "${line1}${line2}${line3}${line4}${line5}${line6}${line7}"
Abort Abort
FunctionEnd FunctionEnd
Function .onInit Function .onInit
var /GLOBAL cmdLineParams var /GLOBAL cmdLineParams
Push $R0 Push $R0
${GetParameters} $cmdLineParams ${GetParameters} $cmdLineParams
ClearErrors ClearErrors
${GetOptions} $cmdLineParams '/?' $R0 ${GetOptions} $cmdLineParams '/?' $R0
IfErrors +2 0 IfErrors +2 0
Call ShowHelpMessage Call ShowHelpMessage
${GetOptions} $cmdLineParams '/H' $R0 ${GetOptions} $cmdLineParams '/H' $R0
IfErrors +2 0 IfErrors +2 0
Call ShowHelpMessage Call ShowHelpMessage
Pop $R0 Pop $R0
Var /GLOBAL option_startMenu Var /GLOBAL option_startMenu
Var /GLOBAL option_desktop Var /GLOBAL option_desktop
Var /GlOBAL option_noservice Var /GlOBAL option_noservice
StrCpy $option_startMenu 0 StrCpy $option_startMenu 0
StrCpy $option_desktop 0 StrCpy $option_desktop 0
StrCpy $option_noservice 0 StrCpy $option_noservice 0
Push $R0 Push $R0
${GetOptions} $cmdLineParams '/startmenu' $R0
IfErrors +2 0
StrCpy $option_startMenu 1
${GetOptions} $cmdLineParams '/desktop' $R0
IfErrors +2 0
StrCpy $option_desktop 1
${GetOptions} $cmdLineParams '/noservice' $R0 ${GetOptions} $cmdLineParams '/startmenu' $R0
IfErrors +2 0 IfErrors +2 0
StrCpy $option_noservice 1 StrCpy $option_startMenu 1
Pop $R0 ${GetOptions} $cmdLineParams '/desktop' $R0
IfErrors +2 0
StrCpy $option_desktop 1
${GetOptions} $cmdLineParams '/noservice' $R0
IfErrors +2 0
StrCpy $option_noservice 1
Pop $R0
FunctionEnd FunctionEnd
;Install ;Install
Section "-Install" Section1 Section "-Install" Section1
nsExec::Exec 'net.exe STOP "Looking Glass (host)"'
SetOutPath $INSTDIR SetOutPath $INSTDIR
File ..\build\looking-glass-host.exe File ..\..\looking-glass-host.exe
File /oname=LICENSE.txt ..\..\LICENSE File LICENSE.txt
WriteUninstaller $INSTDIR\uninstaller.exe WriteUninstaller $INSTDIR\uninstaller.exe
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0 IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"EstimatedSize" "$0" "EstimatedSize" "$0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"DisplayName" "Looking-Glass" "DisplayName" "Looking Glass"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"UninstallString" "$\"$INSTDIR\uninstaller.exe$\"" "UninstallString" "$\"$INSTDIR\uninstaller.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"QuietUninstallString" "$\"$INSTDIR\uninstaller.exe$\" /S" "QuietUninstallString" "$\"$INSTDIR\uninstaller.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"InstallLocation" "$INSTDIR" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"Publisher" "Geoffrey McRae" "Publisher" "Geoffrey McRae"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"DisplayIcon" "$\"$INSTDIR\looking-glass-host.exe$\"" "DisplayIcon" "$\"$INSTDIR\looking-glass-host.exe$\""
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"NoRepair" "1" "NoRepair" "1"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"NoModify" "1" "NoModify" "1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)" \
"DisplayVersion" ${VERSION} "DisplayVersion" ${VERSION}
SectionEnd SectionEnd
Section "Looking-Glass Service" Section2 Section "Looking Glass (host) Service" Section2
${If} $option_noservice == 0 ${If} $option_noservice == 0
nsExec::Exec '"$INSTDIR\looking-glass-host.exe" UninstallService' nsExec::Exec '"$INSTDIR\looking-glass-host.exe" UninstallService'
@ -157,11 +159,11 @@ Section "-Hidden Start Menu" Section5
SetShellVarContext all SetShellVarContext all
${If} $option_startMenu == 1 ${If} $option_startMenu == 1
CreateShortCut $SMPROGRAMS\Looking Glass (host).lnk $INSTDIR\looking-glass-host.exe CreateShortCut "$SMPROGRAMS\Looking Glass (host).lnk" $INSTDIR\looking-glass-host.exe
${EndIf} ${EndIf}
${If} $option_desktop == 1 ${If} $option_desktop == 1
CreateShortCut $DESKTOP\Looking Glass (host).lnk $INSTDIR\looking-glass-host.exe CreateShortCut "$DESKTOP\Looking Glass (host).lnk" $INSTDIR\looking-glass-host.exe
${EndIf} ${EndIf}
SectionEnd SectionEnd
@ -169,22 +171,22 @@ SectionEnd
Section "Uninstall" Section6 Section "Uninstall" Section6
SetShellVarContext all SetShellVarContext all
nsExec::Exec 'net.exe STOP "Looking Glass (host)"'
nsExec::Exec '"$INSTDIR\looking-glass-host.exe" UninstallService' nsExec::Exec '"$INSTDIR\looking-glass-host.exe" UninstallService'
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host)"
Delete $SMPROGRAMS\Looking-Glass-Host.lnk Delete "$SMPROGRAMS\Looking Glass (host).lnk"
Delete $DESKTOP\Looking-Glass-Host.lnk Delete "$DESKTOP\Looking Glass (host).lnk"
Delete $INSTDIR\uninstaller.exe Delete "$INSTDIR\uninstaller.exe"
Delete $INSTDIR\looking-glass-host.exe Delete "$INSTDIR\looking-glass-host.exe"
Delete $INSTDIR\LICENSE.txt Delete "$INSTDIR\LICENSE.txt"
RMDir $INSTDIR RMDir $INSTDIR
SectionEnd SectionEnd
;Description text for selection of install items ;Description text for selection of install items
LangString DESC_Section1 ${LANG_ENGLISH} "Install Files into $INSTDIR" LangString DESC_Section1 ${LANG_ENGLISH} "Install Files into $INSTDIR"
LangString DESC_Section2 ${LANG_ENGLISH} "Create service to automatically start Looking-Glass." LangString DESC_Section2 ${LANG_ENGLISH} "Install service to automatically start Looking Glass (host)."
LangString DESC_Section3 ${LANG_ENGLISH} "Create desktop shortcut icon." LangString DESC_Section3 ${LANG_ENGLISH} "Create desktop shortcut icon."
LangString DESC_Section4 ${LANG_ENGLISH} "Create start menu shortcut." LangString DESC_Section4 ${LANG_ENGLISH} "Create start menu shortcut."

View File

@ -34,7 +34,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <userenv.h> #include <userenv.h>
#include <wtsapi32.h> #include <wtsapi32.h>
#define SVCNAME "Looking Glass Host" #define SVCNAME "Looking Glass (host)"
#define SVC_ERROR ((DWORD)0xC0020001L) #define SVC_ERROR ((DWORD)0xC0020001L)
struct Service struct Service