Skip to content

Commit

Permalink
provision.ps1: fixed virtio-win-guest-tools.exe installation (chef#1516)
Browse files Browse the repository at this point in the history
Newer virtio-win.iso has E:\virtio-win-guest-tools.exe. From the code it
seems like older virtio-win.iso has this file in  E:\driver.
Made sure script works with both old and new virtio-win.iso.

Signed-off-by: Zalan Bleneszy <[email protected]>
  • Loading branch information
zbleness authored Jul 25, 2023
1 parent 465cb8a commit ebbbdcc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packer_templates/scripts/windows/provision.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ Add-Type -A System.IO.Compression.FileSystem
# install Guest Additions.
$systemVendor = (Get-CimInstance -ClassName Win32_ComputerSystemProduct -Property Vendor).Vendor
if ($systemVendor -eq 'QEMU') {
$guestToolsPath = "e:\drivers\virtio-win-guest-tools.exe"
$guestTools = "$env:TEMP\$(Split-Path -Leaf $guestToolsPath)"
$guestToolsLog = "$guestTools.log"
# in more recent virtio-win.iso virtio-win-guest-tools.exe has move to E:\
$guestToolsPath = dir -Path E:\ -Filter virtio-win-guest-tools.exe -Recurse | %{$_.FullName}
if (!$guestToolsPath) {
throw "did not find virtio-win-guest-tools.exe on E:\"
}
$guestToolsLog = "$env:TEMP\$(Split-Path -Leaf $guestToolsPath).log"
Write-Host 'Installing the guest tools...'
&$guestTools /install /norestart /quiet /log $guestToolsLog | Out-String -Stream
&$guestToolsPath /install /norestart /quiet /log $guestToolsLog | Out-String -Stream
if ($LASTEXITCODE) {
throw "failed to install guest tools with exit code $LASTEXITCODE"
}
Expand Down

0 comments on commit ebbbdcc

Please sign in to comment.