support/install_command.ps1 in mixlib-install-0.3.0 vs support/install_command.ps1 in mixlib-install-0.4.0
- old
+ new
@@ -1,12 +1,15 @@
Function Check-UpdateChef($root, $version) {
if (-Not (Test-Path $root)) { return $true }
elseif ("$version" -eq "true") { return $false }
elseif ("$version" -eq "latest") { return $true }
- Try { $chef_version = (& $root\bin\chef-solo.bat -v).split(" ", 2)[1] }
- Catch { $chef_version = "" }
+ Try { $chef_version = Get-Content $root\version-manifest.txt | select-object -1}
+ Catch {
+ Try { $chef_version = (& $root\bin\chef-solo.bat -v).split(" ", 2)[1] }
+ Catch { $chef_version = "" }
+ }
if ($chef_version.StartsWith($version)) { return $false }
else { return $true }
}
@@ -24,20 +27,19 @@
$bytes = $c.ComputeHash(($in = (Get-Item $src).OpenRead()))
return ([System.BitConverter]::ToString($bytes)).Replace("-", "").ToLower()
} Finally { if (($c -ne $null) -and ($c.GetType().GetMethod("Dispose") -ne $null)) { $c.Dispose() }; if ($in -ne $null) { $in.Dispose() } }
}
-Function Download-Chef($md_url, $dst) {
- $url, $md5 = Get-ChefMetadata $md_url
-
+Function Download-Chef($url, $md5, $dst) {
Try {
Log "Downloading package from $url"
($c = Make-WebClient).DownloadFile($url, $dst)
Log "Download complete."
} Finally { if ($c -ne $null) { $c.Dispose() } }
- if (($dmd5 = Get-MD5Sum $dst) -eq $md5) { Log "Successfully verified $dst" }
+ if ($md5 -eq $null) { Log "Skipping md5 verification" }
+ elseif (($dmd5 = Get-MD5Sum $dst) -eq $md5) { Log "Successfully verified $dst" }
else { throw "MD5 for $dst $dmd5 does not match $md5" }
}
Function Install-Chef($msi) {
Log "Installing Chef Omnibus package $msi"
@@ -67,10 +69,16 @@
$chef_omnibus_root = Unresolve-Path $chef_omnibus_root
$msi = Unresolve-Path $msi
if (Check-UpdateChef $chef_omnibus_root $version) {
Write-Host "-----> Installing Chef Omnibus ($pretty_version)`n"
- Download-Chef "$chef_metadata_url" $msi
+ if ($chef_metadata_url -ne $null) {
+ $url, $md5 = Get-ChefMetadata "$chef_metadata_url"
+ } else {
+ $url = $chef_msi_url
+ $md5 = $null
+ }
+ Download-Chef "$url" $md5 $msi
Install-Chef $msi
} else {
Write-Host "-----> Chef Omnibus installation detected ($pretty_version)`n"
}