Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-60) fix upgrade/installation Filestream errors on PSv2 #92

Merged
merged 1 commit into from
Oct 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions templates/InstallChocolatey.ps1.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ $chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "chocInstall"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}
$file = Join-Path $tempDir "chocolatey.zip"
$chocErrorLog = Join-Path $tempDir "chocError.log"

function Download-File {
param (
[string]$url,
[string]$file
)
Write-Host "Downloading $url to $file"
Write-Output "Downloading $url to $file"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fully on board with this idea. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced the final ones of these to write-output in chocolateySetup.psm1 as well.

$downloader = new-object System.Net.WebClient
$downloader.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
$downloader.DownloadFile($url, $file)
Expand All @@ -47,13 +48,13 @@ Download-File $url $file

if ($unzipMethod -eq '7zip') {
# download 7zip
Write-Host "Download 7Zip commandline tool"
Write-Output "Download 7Zip commandline tool"
$7zaExe = Join-Path $tempDir '7za.exe'

Download-File 'https://chocolatey.org/7za.exe' "$7zaExe"

# unzip the package
Write-Host "Extracting $file to $tempDir..."
Write-Output "Extracting $file to $tempDir..."
Start-Process "$7zaExe" -ArgumentList "x -o`"$tempDir`" -y `"$file`"" -Wait -NoNewWindow
} else {
$shellApplication = new-object -com shell.application
Expand All @@ -63,13 +64,21 @@ if ($unzipMethod -eq '7zip') {
}

# call chocolatey install
Write-Host "Installing chocolatey on this machine"
Write-Output "Installing chocolatey on this machine"
$toolsFolder = Join-Path $tempDir "tools"
$chocInstallPS1 = Join-Path $toolsFolder "chocolateyInstall.ps1"

& $chocInstallPS1
if ($PSVersionTable.psversion.Major -gt 2) {
& $chocInstallPS1
}
else {
$output = Invoke-Expression $chocInstallPS1
$output
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we'll be waiting the entire run before are able to see output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you will see the output, but not the error log... if you want to see the errors, like on all the silentlycontinue stuff, it is going to throw a lot of people off, on perfectly fine installs due to inconsequentialities. i tried on a dozen servers of varying configs, and think that if people have an issue with an install gone bad, they can be referred to the error log.

We can add a write-output that states the error logs for PS2 version folks are found in $env:temp if they have any issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like that. Adding a little message just in here. Nevermind, I see you are doing that already.

write-output "Any errors that occured during install or upgrade are logged here: $chocoErrorLog"
$error | out-file $chocErrorLog
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this will help. its an edge case thing, and ppl who encounter a real issue, we'll see why when they post their log, instead of the filestream bs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that would be fantastic.

}

Write-Host 'Ensuring chocolatey commands are on the path'
Write-Output 'Ensuring chocolatey commands are on the path'
$chocInstallVariableName = "ChocolateyInstall"
$chocoPath = [Environment]::GetEnvironmentVariable($chocInstallVariableName, [System.EnvironmentVariableTarget]::User)
if ($chocoPath -eq $null -or $chocoPath -eq '') {
Expand All @@ -82,7 +91,7 @@ if ($($env:Path).ToLower().Contains($($chocoBinPath).ToLower()) -eq $false) {
$env:Path = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine);
}

Write-Host 'Ensuring chocolatey.nupkg is in the lib folder'
Write-Output 'Ensuring chocolatey.nupkg is in the lib folder'
$chocoPkgDir = Join-Path $chocoPath 'lib\chocolatey'
$nupkg = Join-Path $chocoPkgDir 'chocolatey.nupkg'
if (![System.IO.Directory]::Exists($chocoPkgDir)) { [System.IO.Directory]::CreateDirectory($chocoPkgDir); }
Expand Down