#!Nsis Installer Command Script # @configure_input@ # To build an installer from the script you would normally do: # # makensis spice-guest-tools # # which will generate the output file 'spice-guest-tools-$VERSION.exe' which is a Windows # installer containing your program. # # # # Copyright (c) 2012 Red Hat, Inc # Copyright (c) 2012 Grant Williamson # # 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 lzma !include "driver.nsh" !include "WinVer.nsh" !include "x64.nsh" Name "SPICE Guest Tools" Caption "SPICE Guest Tools Installer" OutFile "spice-guest-tools-0.0.1.exe" InstallDir "$PROGRAMFILES\SPICE Guest Tools" # SilentInstall silent # ShowInstDetails hide # ShowUninstDetails hide !include "MUI2.nsh" !insertmacro MUI_PAGE_WELCOME !define MUI_PAGE_CUSTOMFUNCTION_SHOW addLicense !insertmacro MUI_PAGE_LICENSE virtio-win_license.txt !insertmacro MUI_LANGUAGE "English" XPStyle on RequestExecutionLevel admin # Page components Page directory Page instfiles ComponentText "Select which optional components you want to install." DirText "Please select the installation folder." Section "spice-guest-tools" SectionIn RO 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 "vioser" Push "PCI\VEN_1AF4&DEV_1003&SUBSYS_00031AF4" Call InstallDriver Push "qxl" Push "PCI\VEN_1b36&DEV_0100&SUBSYS_11001af4" Call InstallDriver Push "balloon" Push "PCI\VEN_1AF4&DEV_1002&SUBSYS_00051AF4&REV_00" Call InstallDriver Push "viostor" Push "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00" Call InstallDriver Push "netkvm" Push "PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00" Call InstallDriver ${if} ${RunningX64} SetOutPath "$INSTDIR\64" ${else} SetOutPath "$INSTDIR\32" ${endif} nsExec::ExecToLog 'vdservice install' nsExec::ExecToLog 'net start vdservice' SectionEnd Section "Start Menu Shortcuts" CreateDirectory "$SMPROGRAMS\spice-guest-tools" CreateShortCut "$SMPROGRAMS\spice-guest-tools\Uninstall SPICE Guest Tools.lnk" "$INSTDIR\Uninstall-spice-guest-tools.exe" "" "$INSTDIR\Uninstall-spice-guest-tools.exe" 0 SectionEnd Section "Desktop Icons" # CreateShortCut "$DESKTOP\virt-viewer.exe.lnk" "$INSTDIR\bin\virt-viewer.exe" "" "$INSTDIR\bin\virt-viewer.exe" 0 SectionEnd Section "Uninstall" Delete /rebootok "$SMPROGRAMS\virt-viewer\Uninstall SPICE Guest Tools.lnk" RMDir "$SMPROGRAMS\spice-guest-tools" ${if} ${RunningX64} SetOutPath "$INSTDIR\64" ${else} SetOutPath "$INSTDIR\32" ${EndIf} nsExec::ExecToLog 'net stop vdservice' nsExec::ExecToLog 'vdservice uninstall' Delete /rebootok "$OUTDIR\vdagent.exe" Delete /rebootok "$OUTDIR\vdservice.exe" RMDir "$INSTDIR" SectionEnd Section -post WriteUninstaller "$INSTDIR\Uninstall virt-viewer.exe" SectionEnd !define LIC_NAME "virtio-win_license.txt" Function addLicense ClearErrors FileOpen $0 $EXEDIR\${LIC_NAME} r IfErrors exit System::Call 'kernel32::GetFileSize(i r0, i 0) i .r1' IntOp $1 $1 + 1 ; for terminating zero System::Alloc $1 Pop $2 System::Call 'kernel32::ReadFile(i r0, i r2, i r1, *i .r3, i 0)' FileClose $0 FindWindow $0 "#32770" "" $HWNDPARENT GetDlgItem $0 $0 1000 SendMessage $0 ${EM_SETLIMITTEXT} $1 0 SendMessage $0 ${WM_SETTEXT} 0 $2 System::Free $2 exit: FunctionEnd 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} SetOutPath "$TEMP" File "../redhat/virt-what-cpuid-helper.exe" File "../redhat/virt-what-cpuid-helper.bat" nsExec::ExecToStack "$TEMP\virt-what-cpuid-helper.bat" Pop $0 ${if} $0 == 1 MessageBox MB_ICONEXCLAMATION "You may only install these drivers in a Windows guest running as a KVM Virtual Image!" Abort ; causes installer to quit. ${EndIf} FunctionEnd Function GetDriverSubdir ${If} ${IsWinXP} StrCpy $0 "WXp" ${ElseIf} ${IsWinVista} StrCpy $0 "Wlh" ${ElseIf} ${IsWin2003} StrCpy $0 "Wnet" ${ElseIf} ${IsWin7} StrCpy $0 "Win7" ${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 InstallDriver Pop $R0 ; HID Pop $R1 ; driver name Call GetDriverSubdir Pop $0 StrCpy $1 "$INSTDIR\drivers\$0" Push $1 StrCpy $2 "$1\$R1.inf" Push $2 Push $R0 Call InstallUpgradeDriver FunctionEnd