mitchellh/vagrant-installers — pull request #43 by StefanScherer (2014-07-10 07:36:02+00:00)
Title: added version info to bsdtar.exe to fix MSI update issues

@mitchellh Yesterday I have seen that this repo also contains the bsdtar in substrate/modules/bsdtar/files/windows.zip.

So it wasn't necessary to patch the binaries within the package.ps1 script as I have done in a previous PR #37. I just fixed the windows.zip and added the version info to both bsdtar.exe and bsdcpio.exe to fix the MSI update problem from Vagrant 1.4/1.5 -> 1.6. There still are many responses in mitchellh/vagrant#3674 and I think it might be useful for other windows users that haven't upgraded yet.

What I have done was in an empty Windows 7 VM was running this PowerShell script. It downloads the verpatch tool, downloads the latest windows.zip from this repo, patches the current version into the two exes. Afterwards I have zipped the bin directory with 7-Zip and put it into this PR.

It also would be a good idea to reopen the vagrant issue 3674 and close it again and mark it as resolve in the CHANGELOG, so all other users finding this issue with google can see the progress for eg. Vagrant 1.6.4.

```powershell
#--------------------------------------------------------------------
# Helper Functions
#--------------------------------------------------------------------
function Expand-ZipFile($file, $destination) {
$shell = New-Object -ComObject "Shell.Application"
$zip = $shell.NameSpace($file)
foreach($item in $zip.items()) {
$shell.Namespace($destination).copyhere($item, 0x14) # overwrite flag
}
}

#-------------------------------------------------------------------
# Patch version info into bsdtar.exe and bsdcpio.exe with verpatch.exe
# Fix for vagrant issue #3674, MSI Upgrade 1.5 -> 1.6
#--------------------------------------------------------------------
# Download verpatch from http://ddverpatch.codeplex.com/

$verpatchSourceURL = "http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=ddverpatch&DownloadId=713811&FileTime=130201209882270000&Build=20907"
$verpatchDest = "$env:TEMP\verpatch.zip"

Write-Host "Downloading verpatch 1.0.14"
(New-Object System.Net.WebClient).DownloadFile($verpatchSourceURL, $verpatchDest)

Write-Host "Unzipping verpatch"
Expand-ZipFile -file $verpatchDest -destination "$env:TEMP"

$verpatch = "$env:TEMP\verpatch.exe"

$bsdtarWindowsZipURL = "https://github.com/mitchellh/vagrant-installers/raw/master/substrate/modules/bsdtar/files/windows.zip"
$bsdtarWindowsZipDest = "$env:TEMP\windows.zip"
$bsdtarWindowsZipVersioned = "$env:TEMP\windows-versioned.zip"

Write-Host "Downloading bsdtar windows.zip from GitHub repo"
(New-Object System.Net.WebClient).DownloadFile($bsdtarWindowsZipURL, $bsdtarWindowsZipDest)

$bsdtarTempDir = "$env:TEMP\bsdtar"
if (-not (Test-Path -path $bsdtarTempDir)) {
New-Item -ItemType directory -Path "$bsdtarTempDir"
}

Write-Host "Unzipping bsdtar windows.zip"
Expand-ZipFile -file $bsdtarWindowsZipDest -destination "$bsdtarTempDir"

$bsdtar = "$bsdtarTempDir\bin\bsdtar.exe"
$bsdcpio = "$bsdtarTempDir\bin\bsdcpio.exe"

$version = & $bsdtar --version
$version -match '([\d.]+)'
$bsdversion = "$($matches[0]).0"

Write-Host "Patching version $bsdversion into $bsdtar"
& $verpatch $bsdtar /va $bsdversion /pv $bsdversion

Write-Host "Patching version $bsdversion into $bsdcpio"
& $verpatch $bsdcpio /va $bsdversion /pv $bsdversion

Write-Host "Done"

Write-Host "Now you can create a new windows.zip from folder $bsdtarTempDir"
```