[NSIS 1/7] nsis: Add support for building an oVirt installer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christophe Fergeau <cfergeau@xxxxxxxxxx>

oVirt wants to reuse the SPICE Guest Tools code as a basis for building
an installer for the oVirt Guest Tools. This commit renames the install
script to win-guest-tools.nsis and add conditionals to build either an
installer for SPICE Guest Tools or oVirt Guest Tools.

Change-Id: I62e41f3b3bcc5d1975523614897928543c44ba1a
Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>
---
 README                 |   4 +-
 spice-guest-tools.nsis | 394 -----------------------------------------------
 win-guest-tools.nsis   | 406 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 408 insertions(+), 396 deletions(-)
 delete mode 100644 spice-guest-tools.nsis
 create mode 100644 win-guest-tools.nsis

diff --git a/README b/README
index 856d36a..17365c2 100644
--- a/README
+++ b/README
@@ -8,7 +8,7 @@ started up/picked up correctly by Windows.
 
 This script needs to have the various binaries/drivers it will install
 available, they are not included in this archive. The various 'File'
-directives in spice-guest-tools.nsis should give you an idea of the
+directives in win-guest-tools.nsis should give you an idea of the
 directory tree the script expects. There are some rough notes about this
 in INSTALL as well.
 
@@ -20,4 +20,4 @@ from http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin . The dll it ships m
 NSIS plugin path, for example /usr/share/nsis/Plugins/ on my Fedora machine.
 
 Once this is installed, all that is needed is to run makensis
-./spice-guest-tools.nsi from your Linux box, and magic will happen!
+./win-guest-tools.nsi from your Linux box, and magic will happen!
diff --git a/spice-guest-tools.nsis b/spice-guest-tools.nsis
deleted file mode 100644
index c7444a4..0000000
--- a/spice-guest-tools.nsis
+++ /dev/null
@@ -1,394 +0,0 @@
-#!Nsis Installer Command Script
-# @configure_input@
-# To build an installer from the script you would normally do:
-#
-#   makensis spice-guest-tools.nsis
-#
-# which will generate the output file 'spice-guest-tools-$VERSION.exe' which is a Windows
-# installer containing your program.
-#
-#
-#
-# Copyright (c) 2012-2015 Red Hat, Inc
-# Copyright (c) 2014 Lev Veyde <lveyde@xxxxxxxxx>
-# Copyright (c) 2012 Grant Williamson <grant.williamson@xxxxxxxxx>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-# 
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-SetCompressor /SOLID lzma
-
-!include "driver.nsh"
-!include "FileFunc.nsh"
-!include "WinVer.nsh"
-!include "x64.nsh"
-
-!define FILENAME "spice-guest-tools"
-!define NAME "SPICE Guest Tools"
-!define PUBLISHER "The SPICE Project"
-!define REGKEYNAME "SpiceGuestTools"
-!define URL "http://spice-space.org";
-!define VERSION "0.103"
-Name "${NAME}"
-Caption "${NAME} Installer"
-OutFile "${FILENAME}-${VERSION}.exe"
-InstallDir "$PROGRAMFILES\${NAME}"
-BrandingText " "
-
-# SilentInstall silent
-ShowInstDetails nevershow
-# ShowUninstDetails hide
-
-!include "MUI2.nsh"
-!insertmacro MUI_PAGE_WELCOME
-!insertmacro MUI_PAGE_LICENSE win-driver-license.txt
-!insertmacro MUI_PAGE_INSTFILES
-!insertmacro MUI_PAGE_FINISH
-
-!insertmacro MUI_UNPAGE_WELCOME
-!insertmacro MUI_UNPAGE_INSTFILES
-!insertmacro MUI_UNPAGE_FINISH
-
-!insertmacro MUI_LANGUAGE "English"
-
-XPStyle on
-RequestExecutionLevel admin
-
-ComponentText "Select which optional components you want to install."
-
-DirText "Please select the installation folder."
-
-Section "spice-guest-tools"
-  SectionIn RO
-
-  Call StopServices
-
-  SetOutPath "$INSTDIR"
-  File "version.txt"
-
-  SetOutPath "$INSTDIR\32"
-  File "bin/vdagent_x86/vdagent.exe"
-  File "bin/vdagent_x86/vdservice.exe"
-  SetOutPath "$INSTDIR\64"
-  File "bin/vdagent_x64/vdagent.exe"
-  File "bin/vdagent_x64/vdservice.exe"
-
-  SetOutPath "$INSTDIR\drivers"
-  File /r drivers/virtio/
-  File /r drivers/qxl/
-
-  Push "vioserial"
-  Push "vioser"
-  Push "PCI\VEN_1AF4&DEV_1003&SUBSYS_00031AF4"
-  Call InstallDriver
-
-  Call InstallQemuGuestAgent
-
-  ${if} ${AtLeastWin8}
-    Push "qxldod"
-    Push "qxldod"
-  ${else}
-    Push "qxl"
-    Push "qxl"
-  ${endif}
-  Push "PCI\VEN_1b36&DEV_0100&SUBSYS_11001af4"
-  Call InstallDriver
-
-  Push "Balloon"
-  Push "balloon"
-  Push "PCI\VEN_1AF4&DEV_1002&SUBSYS_00051AF4&REV_00"
-  Call InstallBalloonDriver
-
-  Push "viostor"
-  Push "viostor"
-  Push "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00"
-  Call InstallDriver
-
-  ${If}  ${IsWinVista}
-  ${OrIf} ${IsWin2008}
-  ${OrIf} ${IsWin7}
-  ${OrIf} ${IsWin2008R2}
-  ${OrIf} ${IsWin8}
-  ${OrIf} ${IsWin2012}
-  ${OrIf} ${IsWin8.1}
-  ${OrIf} ${IsWin2012R2}
-    Push "vioscsi"
-    Push "vioscsi"
-    Push "PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00"
-    Call InstallDriver
-  ${EndIf}
-
-  Push "."
-  Push "qemupciserial"
-  Push "PCI\VEN_1B36&DEV_0002"
-  Call InstallDriver
-
-  Push "."
-  Push "qemupciserial"
-  Push "PCI\VEN_1B36&DEV_0003"
-  Call InstallDriver
-
-  Push "."
-  Push "qemupciserial"
-  Push "PCI\VEN_1B36&DEV_0003"
-  Call InstallDriver
-
-  Push "NetKVM"
-  Push "netkvm"
-  Push "PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00"
-  Call InstallDriver
-
-  Call InstallVdAgentService
-
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "DisplayName" "${NAME}"
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "DisplayVersion" "${VERSION}"
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "Publisher" "${PUBLISHER}"
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "URLInfoAbout" "${URL}"
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "UninstallString" "$\"$INSTDIR\Uninstall ${FILENAME}$\""
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "QuietUninstallString" "$\"$INSTDIR\Uninstall ${FILENAME}$\" /S"
-  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "NoModify" "1"
-  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "NoRepair" "1"
-  ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
-  IntFmt $0 "0x%08X" $0
-  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
-                 "EstimatedSize" "$0"
-SectionEnd
-
-Section "Uninstall"
-  Call un.StopServices
-  Call un.UninstallQemuGuestAgent
-
-  SetOutPath "$TEMP"
-
-  Delete /rebootok "$INSTDIR\version.txt"
-  Delete /rebootok "$INSTDIR\Uninstall ${FILENAME}.exe"
-  Delete /rebootok "$INSTDIR\32\vdagent.exe"
-  Delete /rebootok "$INSTDIR\32\vdservice.exe"
-  RMDir /rebootok "$INSTDIR\32"
-  Delete /rebootok "$INSTDIR\64\vdagent.exe"
-  Delete /rebootok "$INSTDIR\64\vdservice.exe"
-  RMDir /rebootok "$INSTDIR\64"
-  RMDir /rebootok /r "$INSTDIR\drivers"
-  RMDir /rebootok "$INSTDIR"
-
-  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}"
-SectionEnd
-
-Section -post
-  WriteUninstaller "$INSTDIR\Uninstall ${FILENAME}.exe"
-SectionEnd
-
-Function .onInit
-   ${if} ${RunningX64}
-     ${if} ${IsWinXP}
-       MessageBox MB_ICONEXCLAMATION "Windows XP 64 bit is an unsupported Windows version"
-       Abort ; causes installer to quit.
-     ${endif}
-   ${endif}
-   ${if} ${AtMostWin2000}
-       MessageBox MB_ICONEXCLAMATION "Drivers only available for Windows XP or newer"
-       Abort ; causes installer to quit.
-   ${endif}
-FunctionEnd
-
-Function GetDriverSubdir
-   Pop $0
-   ${If} ${IsWinXP}
-      StrCpy $0 "$0\xp"
-   ${ElseIf} ${IsWinVista}
-      StrCpy $0 "$0\vista"
-   ${ElseIf} ${IsWin2003}
-      StrCpy $0 "$0\2k3"
-   ${ElseIf} ${IsWin7}
-      StrCpy $0 "$0\w7"
-   ${ElseIf} ${IsWin2008}
-      StrCpy $0 "$0\w2k8"
-   ${ElseIf} ${IsWin2008R2}
-      StrCpy $0 "$0\w2k8R2"
-   ${ElseIf} ${IsWin8}
-      StrCpy $0 "$0\w8"
-   ${ElseIf} ${IsWin2012}
-      StrCpy $0 "$0\w2k12"
-   ${ElseIf} ${IsWin8.1}
-      StrCpy $0 "$0\w8.1"
-   ${ElseIf} ${IsWin2012R2}
-      StrCpy $0 "$0\w2k12r2"
-   ${Else}
-      MessageBox MB_ICONEXCLAMATION "Unsupported Windows version"
-      Abort ; causes installer to quit.
-   ${EndIf}
-
-   ${If} ${RunningX64}
-      StrCpy $0 "$0\amd64"
-   ${Else}
-      StrCpy $0 "$0\x86"
-   ${EndIf}
-
-   Push $0
-FunctionEnd
-
-Function InstallBalloonDriver
-  Call InstallDriver
-
-  Call InstallBalloonService
-
-FunctionEnd
-
-Function InstallDriver
-  Pop $R0 ; HID
-  Pop $R1 ; driver name
-  Pop $R2 ; driver path
-  Push $R2
-  Call GetDriverSubdir
-  Pop $0
-  StrCpy $1 $R1
-  Push $1
-  StrCpy $2 "$INSTDIR\drivers\$0"
-  Push $2
-  StrCpy $3 "$2\$R1.inf"
-  Push $3
-  Push $R0
-  DetailPrint "Installing $R1.inf"
-  Call InstallUpgradeDriver
-FunctionEnd
-
-!macro StopServices un
-Function ${un}StopService
-  pop $R0
-
-  SimpleSC::ServiceIsRunning $R0
-  pop $0
-  pop $1
-  ${if} $0 != 0
-    # error
-    Return
-  ${endif}
-  ${if} $1 == 0
-    # service not running
-    Return
-  ${endif}
-
-  DetailPrint "Stopping $R0"
-  SimpleSC::StopService $R0 1 30
-  pop $0
-  ${if} $0 != 0
-    DetailPrint "Failed to stop $R0: $0"
-    Return
-  ${endif}
-  DetailPrint "$R0 stopped"
-FunctionEnd
-
-Function ${un}StopServices
-  push "vdservice"
-  Call ${un}StopService
-
-  push "BalloonService"
-  Call ${un}StopService
-
-
-FunctionEnd
-!macroend
-
-!insertmacro StopServices ""
-!insertmacro StopServices "un."
-
-Function InstallService
-  pop $R0 #service name
-  pop $R1 #service path
-  pop $R2 #service pretty name
-
-  SimpleSC::ExistsService $R0
-  Pop $0
-  ${if} $0 == 0
-    DetailPrint "$R2 service already installed"
-    goto InstallService
-  ${endif}
-
-  DetailPrint "Installing $R2 service"
-  SimpleSC::InstallService $R0 $R2 16 2 $R1 "" "" ""
-  Pop $0
-  ${if} $0 != 0
-    DetailPrint "Failed to install $R2 service: $0"
-    Return
-  ${endif}
-  DetailPrint "$R2 service installed"
-
-InstallService:
-  DetailPrint "Starting $R2 service"
-  SimpleSC::StartService $R0 "" 30
-  Pop $0
-  ${if} $0 != 0
-    DetailPrint "Failed to start $R2 service: $0"
-    Return
-  ${endif}
-  DetailPrint "$R2 service started"
-FunctionEnd
-
-Function InstallQemuGuestAgent
-  ${if} ${RunningX64}
-    StrCpy $0 "$INSTDIR\guest-agent\qemu-ga-x64.msi"
-  ${else}
-    StrCpy $0 "$INSTDIR\guest-agent\qemu-ga-x86.msi"
-  ${endif}
-  ExecWait '"msiexec.exe" /qn /i "$0"'
-FunctionEnd
-
-Function un.UninstallQemuGuestAgent
-  ${if} ${RunningX64}
-    StrCpy $0 "$INSTDIR\guest-agent\qemu-ga-x64.msi"
-  ${else}
-    StrCpy $0 "$INSTDIR\guest-agent\qemu-ga-x86.msi"
-  ${endif}
-  ExecWait '"msiexec.exe" /qn /x "$0"'
-FunctionEnd
-
-Function InstallVdAgentService
-  ${if} ${RunningX64}
-    StrCpy $0 "$INSTDIR\64\vdservice.exe"
-  ${else}
-    StrCpy $0 "$INSTDIR\32\vdservice.exe"
-  ${endif}
-
-  push "SPICE VDAgent"
-  push $0
-  push "vdservice"
-  Call InstallService
-
-FunctionEnd
-
-Function InstallBalloonService
-  Push "Balloon"
-  Call GetDriverSubdir
-  Pop $0
-  StrCpy $0 "$INSTDIR\drivers\$0\blnsvr.exe"
-
-  Push "Balloon Service"
-  Push $0
-  Push "BalloonService"
-  Call InstallService
-
-FunctionEnd
diff --git a/win-guest-tools.nsis b/win-guest-tools.nsis
new file mode 100644
index 0000000..08e2b58
--- /dev/null
+++ b/win-guest-tools.nsis
@@ -0,0 +1,406 @@
+#!Nsis Installer Command Script
+# @configure_input@
+# To build an installer from the script you would normally do:
+#
+#   makensis -D{SPICE,OVIRT} win-guest-tools.nsis
+#
+# which will generate the output file 'spice-guest-tools-$VERSION.exe' or
+# 'ovirt-guest-tools-setup.exe' which are Windows
+# installers containing your program.
+#
+#
+#
+# Copyright (c) 2012-2015 Red Hat, Inc
+# Copyright (c) 2014 Lev Veyde <lveyde@xxxxxxxxx>
+# Copyright (c) 2012 Grant Williamson <grant.williamson@xxxxxxxxx>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+SetCompressor /SOLID lzma
+
+!include "driver.nsh"
+!include "FileFunc.nsh"
+!include "WinVer.nsh"
+!include "x64.nsh"
+
+!ifdef SPICE
+!define FILENAME "spice-guest-tools"
+!define NAME "SPICE Guest Tools"
+!define PUBLISHER "The SPICE Project"
+!define REGKEYNAME "SpiceGuestTools"
+!define URL "http://spice-space.org";
+!else ifdef OVIRT
+!define FILENAME "ovirt-guest-tools-setup"
+!define NAME "oVirt Guest Tools"
+!define PUBLISHER "The oVirt Project"
+!define REGKEYNAME "oVirtGuestTools"
+!define URL "http://www.ovirt.org/Home";
+!else
+!error "OVIRT or SPICE symbol should passed to makensis with the -D flag"
+!endif
+!define VERSION "0.103"
+
+Name "${NAME}"
+Caption "${NAME} Installer"
+OutFile "${FILENAME}-${VERSION}.exe"
+InstallDir "$PROGRAMFILES\${NAME}"
+BrandingText " "
+
+# SilentInstall silent
+ShowInstDetails nevershow
+# ShowUninstDetails hide
+
+!include "MUI2.nsh"
+!insertmacro MUI_PAGE_WELCOME
+!insertmacro MUI_PAGE_LICENSE win-driver-license.txt
+!insertmacro MUI_PAGE_INSTFILES
+!insertmacro MUI_PAGE_FINISH
+
+!insertmacro MUI_UNPAGE_WELCOME
+!insertmacro MUI_UNPAGE_INSTFILES
+!insertmacro MUI_UNPAGE_FINISH
+
+!insertmacro MUI_LANGUAGE "English"
+
+XPStyle on
+RequestExecutionLevel admin
+
+ComponentText "Select which optional components you want to install."
+
+DirText "Please select the installation folder."
+
+Section "install"
+  SectionIn RO
+
+  Call StopServices
+
+  SetOutPath "$INSTDIR"
+  File "version.txt"
+
+  SetOutPath "$INSTDIR\32"
+  File "bin/vdagent_x86/vdagent.exe"
+  File "bin/vdagent_x86/vdservice.exe"
+  SetOutPath "$INSTDIR\64"
+  File "bin/vdagent_x64/vdagent.exe"
+  File "bin/vdagent_x64/vdservice.exe"
+
+  SetOutPath "$INSTDIR\drivers"
+  File /r drivers/virtio/
+  File /r drivers/qxl/
+
+  Push "vioserial"
+  Push "vioser"
+  Push "PCI\VEN_1AF4&DEV_1003&SUBSYS_00031AF4"
+  Call InstallDriver
+
+  Call InstallQemuGuestAgent
+
+  ${if} ${AtLeastWin8}
+    Push "qxldod"
+    Push "qxldod"
+  ${else}
+    Push "qxl"
+    Push "qxl"
+  ${endif}
+  Push "PCI\VEN_1b36&DEV_0100&SUBSYS_11001af4"
+  Call InstallDriver
+
+  Push "Balloon"
+  Push "balloon"
+  Push "PCI\VEN_1AF4&DEV_1002&SUBSYS_00051AF4&REV_00"
+  Call InstallBalloonDriver
+
+  Push "viostor"
+  Push "viostor"
+  Push "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00"
+  Call InstallDriver
+
+  ${If}  ${IsWinVista}
+  ${OrIf} ${IsWin2008}
+  ${OrIf} ${IsWin7}
+  ${OrIf} ${IsWin2008R2}
+  ${OrIf} ${IsWin8}
+  ${OrIf} ${IsWin2012}
+  ${OrIf} ${IsWin8.1}
+  ${OrIf} ${IsWin2012R2}
+    Push "vioscsi"
+    Push "vioscsi"
+    Push "PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00"
+    Call InstallDriver
+  ${EndIf}
+
+  Push "."
+  Push "qemupciserial"
+  Push "PCI\VEN_1B36&DEV_0002"
+  Call InstallDriver
+
+  Push "."
+  Push "qemupciserial"
+  Push "PCI\VEN_1B36&DEV_0003"
+  Call InstallDriver
+
+  Push "."
+  Push "qemupciserial"
+  Push "PCI\VEN_1B36&DEV_0003"
+  Call InstallDriver
+
+  Push "NetKVM"
+  Push "netkvm"
+  Push "PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00"
+  Call InstallDriver
+
+  Call InstallVdAgentService
+
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "DisplayName" "${NAME}"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "DisplayVersion" "${VERSION}"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "Publisher" "${PUBLISHER}"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "URLInfoAbout" "${URL}"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "UninstallString" "$\"$INSTDIR\Uninstall ${FILENAME}$\""
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "QuietUninstallString" "$\"$INSTDIR\Uninstall ${FILENAME}$\" /S"
+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "NoModify" "1"
+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "NoRepair" "1"
+  ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
+  IntFmt $0 "0x%08X" $0
+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
+                 "EstimatedSize" "$0"
+SectionEnd
+
+Section "Uninstall"
+  Call un.StopServices
+  Call un.UninstallQemuGuestAgent
+
+  SetOutPath "$TEMP"
+
+  Delete /rebootok "$INSTDIR\version.txt"
+  Delete /rebootok "$INSTDIR\Uninstall ${FILENAME}.exe"
+  Delete /rebootok "$INSTDIR\32\vdagent.exe"
+  Delete /rebootok "$INSTDIR\32\vdservice.exe"
+  RMDir /rebootok "$INSTDIR\32"
+  Delete /rebootok "$INSTDIR\64\vdagent.exe"
+  Delete /rebootok "$INSTDIR\64\vdservice.exe"
+  RMDir /rebootok "$INSTDIR\64"
+  RMDir /rebootok /r "$INSTDIR\drivers"
+  RMDir /rebootok "$INSTDIR"
+
+  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}"
+SectionEnd
+
+Section -post
+  WriteUninstaller "$INSTDIR\Uninstall ${FILENAME}.exe"
+SectionEnd
+
+Function .onInit
+   ${if} ${RunningX64}
+     ${if} ${IsWinXP}
+       MessageBox MB_ICONEXCLAMATION "Windows XP 64 bit is an unsupported Windows version"
+       Abort ; causes installer to quit.
+     ${endif}
+   ${endif}
+   ${if} ${AtMostWin2000}
+       MessageBox MB_ICONEXCLAMATION "Drivers only available for Windows XP or newer"
+       Abort ; causes installer to quit.
+   ${endif}
+FunctionEnd
+
+Function GetDriverSubdir
+   Pop $0
+   ${If} ${IsWinXP}
+      StrCpy $0 "$0\xp"
+   ${ElseIf} ${IsWinVista}
+      StrCpy $0 "$0\vista"
+   ${ElseIf} ${IsWin2003}
+      StrCpy $0 "$0\2k3"
+   ${ElseIf} ${IsWin7}
+      StrCpy $0 "$0\w7"
+   ${ElseIf} ${IsWin2008}
+      StrCpy $0 "$0\w2k8"
+   ${ElseIf} ${IsWin2008R2}
+      StrCpy $0 "$0\w2k8R2"
+   ${ElseIf} ${IsWin8}
+      StrCpy $0 "$0\w8"
+   ${ElseIf} ${IsWin2012}
+      StrCpy $0 "$0\w2k12"
+   ${ElseIf} ${IsWin8.1}
+      StrCpy $0 "$0\w8.1"
+   ${ElseIf} ${IsWin2012R2}
+      StrCpy $0 "$0\w2k12r2"
+   ${Else}
+      MessageBox MB_ICONEXCLAMATION "Unsupported Windows version"
+      Abort ; causes installer to quit.
+   ${EndIf}
+
+   ${If} ${RunningX64}
+      StrCpy $0 "$0\amd64"
+   ${Else}
+      StrCpy $0 "$0\x86"
+   ${EndIf}
+
+   Push $0
+FunctionEnd
+
+Function InstallBalloonDriver
+  Call InstallDriver
+
+  Call InstallBalloonService
+
+FunctionEnd
+
+Function InstallDriver
+  Pop $R0 ; HID
+  Pop $R1 ; driver name
+  Pop $R2 ; driver path
+  Push $R2
+  Call GetDriverSubdir
+  Pop $0
+  StrCpy $1 $R1
+  Push $1
+  StrCpy $2 "$INSTDIR\drivers\$0"
+  Push $2
+  StrCpy $3 "$2\$R1.inf"
+  Push $3
+  Push $R0
+  DetailPrint "Installing $R1.inf"
+  Call InstallUpgradeDriver
+FunctionEnd
+
+!macro StopServices un
+Function ${un}StopService
+  pop $R0
+
+  SimpleSC::ServiceIsRunning $R0
+  pop $0
+  pop $1
+  ${if} $0 != 0
+    # error
+    Return
+  ${endif}
+  ${if} $1 == 0
+    # service not running
+    Return
+  ${endif}
+
+  DetailPrint "Stopping $R0"
+  SimpleSC::StopService $R0 1 30
+  pop $0
+  ${if} $0 != 0
+    DetailPrint "Failed to stop $R0: $0"
+    Return
+  ${endif}
+  DetailPrint "$R0 stopped"
+FunctionEnd
+
+Function ${un}StopServices
+  push "vdservice"
+  Call ${un}StopService
+
+  push "BalloonService"
+  Call ${un}StopService
+
+
+FunctionEnd
+!macroend
+
+!insertmacro StopServices ""
+!insertmacro StopServices "un."
+
+Function InstallService
+  pop $R0 #service name
+  pop $R1 #service path
+  pop $R2 #service pretty name
+
+  SimpleSC::ExistsService $R0
+  Pop $0
+  ${if} $0 == 0
+    DetailPrint "$R2 service already installed"
+    goto InstallService
+  ${endif}
+
+  DetailPrint "Installing $R2 service"
+  SimpleSC::InstallService $R0 $R2 16 2 $R1 "" "" ""
+  Pop $0
+  ${if} $0 != 0
+    DetailPrint "Failed to install $R2 service: $0"
+    Return
+  ${endif}
+  DetailPrint "$R2 service installed"
+
+InstallService:
+  DetailPrint "Starting $R2 service"
+  SimpleSC::StartService $R0 "" 30
+  Pop $0
+  ${if} $0 != 0
+    DetailPrint "Failed to start $R2 service: $0"
+    Return
+  ${endif}
+  DetailPrint "$R2 service started"
+FunctionEnd
+
+Function InstallQemuGuestAgent
+  ${if} ${RunningX64}
+    StrCpy $0 "$INSTDIR\guest-agent\qemu-ga-x64.msi"
+  ${else}
+    StrCpy $0 "$INSTDIR\guest-agent\qemu-ga-x86.msi"
+  ${endif}
+  ExecWait '"msiexec.exe" /qn /i "$0"'
+FunctionEnd
+
+Function un.UninstallQemuGuestAgent
+  ${if} ${RunningX64}
+    StrCpy $0 "$INSTDIR\guest-agent\qemu-ga-x64.msi"
+  ${else}
+    StrCpy $0 "$INSTDIR\guest-agent\qemu-ga-x86.msi"
+  ${endif}
+  ExecWait '"msiexec.exe" /qn /x "$0"'
+FunctionEnd
+
+Function InstallVdAgentService
+  ${if} ${RunningX64}
+    StrCpy $0 "$INSTDIR\64\vdservice.exe"
+  ${else}
+    StrCpy $0 "$INSTDIR\32\vdservice.exe"
+  ${endif}
+
+  push "SPICE VDAgent"
+  push $0
+  push "vdservice"
+  Call InstallService
+
+FunctionEnd
+
+Function InstallBalloonService
+  Push "Balloon"
+  Call GetDriverSubdir
+  Pop $0
+  StrCpy $0 "$INSTDIR\drivers\$0\blnsvr.exe"
+
+  Push "Balloon Service"
+  Push $0
+  Push "BalloonService"
+  Call InstallService
+
+FunctionEnd
-- 
2.1.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]