Skip to content
Browse files

Adding more debugging messages

  • Loading branch information...
1 parent b6c0b55 commit f3499b7c795793eff19aef32e56a5702e9980844 @ferventcoder ferventcoder committed Jun 16, 2012
Showing with 85 additions and 27 deletions.
  1. +2 −0 src/functions/Chocolatey-Cygwin.ps1
  2. +3 −1 src/functions/Chocolatey-Install.ps1
  3. +2 −0 src/functions/Chocolatey-InstallAll.ps1
  4. +2 −0 src/functions/Chocolatey-InstallIfMissing.ps1
  5. +5 −2 src/functions/Chocolatey-List.ps1
  6. +3 −0 src/functions/Chocolatey-NuGet.ps1
  7. +1 −0 src/functions/Chocolatey-Pack.ps1
  8. +3 −0 src/functions/Chocolatey-PackagesConfig.ps1
  9. +2 −0 src/functions/Chocolatey-Push.ps1
  10. +4 −0 src/functions/Chocolatey-Python.ps1
  11. +6 −4 src/functions/Chocolatey-Uninstall.ps1
  12. +1 −1 src/functions/Chocolatey-Update.ps1
  13. +2 −0 src/functions/Chocolatey-Version.ps1
  14. +3 −0 src/functions/Chocolatey-WebPI.ps1
  15. +3 −0 src/functions/Delete-ExistingErrorLog.ps1
  16. +2 −0 src/functions/Generate-BinFile.ps1
  17. +2 −0 src/functions/Get-ChocolateyBins.ps1
  18. +2 −0 src/functions/Get-ConfigValue.ps1
  19. +2 −0 src/functions/Get-LatestPackageVersion.ps1
  20. +2 −1 src/functions/Get-LongPackageVersion.ps1
  21. +2 −1 src/functions/Remove-LastInstallLog.ps1
  22. +7 −3 src/functions/Run-ChocolateyPS1.ps1
  23. +2 −1 src/functions/Run-NuGet.ps1
  24. +3 −2 src/helpers/functions/Get-ChocolateyUnzip.ps1
  25. +2 −0 src/helpers/functions/Get-ChocolateyWebFile.ps1
  26. +5 −2 src/helpers/functions/Get-WebFile.ps1
  27. +2 −1 src/helpers/functions/Install-ChocolateyDesktopLink.ps1
  28. +2 −1 src/helpers/functions/Install-ChocolateyPath.ps1
  29. +2 −1 src/helpers/functions/Install-ChocolateyPowershellCommand.ps1
  30. +2 −1 src/helpers/functions/Install-ChocolateyZipPackage.ps1
  31. +2 −1 src/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1
  32. +2 −0 src/helpers/functions/Uninstall-ChocolateyPackage.ps1
  33. +0 −2 src/helpers/functions/Write-ChocolateyFailure.ps1
  34. +0 −2 src/helpers/functions/Write-ChocolateySuccess.ps1
View
2 src/functions/Chocolatey-Cygwin.ps1
@@ -3,6 +3,7 @@ param(
[string] $packageName,
[string] $installerArguments =''
)
+ Write-Debug "Running 'Chocolatey-Cygwin' for $packageName with installerArguments:`'$installerArguments`'";
Chocolatey-InstallIfMissing 'cyg-get'
@@ -21,6 +22,7 @@ $h1
# }
if ($installerArguments -ne '') {
+ Write-Debug "Adding installerArguments `'$installerArguments`'"
$packageArgs = "$packageArgs $installerArguments";
}
View
4 src/functions/Chocolatey-Install.ps1
@@ -5,8 +5,10 @@ param(
[string] $version = '',
[string] $installerArguments = ''
)
-
+ Write-Debug "Running 'Chocolatey-Install' for $packageName with source: `'$source`', version: `'$version`', installerArguments:`'$installerArguments`'";
+
if($($packageName).EndsWith('.config')) {
+ Write-Debug "Chocolatey-Install has determined that package $packageName ends with `'.config`' - calling Chocolatey-PackagesConfig"
Chocolatey-PackagesConfig $packageName
return
}
View
2 src/functions/Chocolatey-InstallAll.ps1
@@ -3,6 +3,8 @@ param(
[string] $source = ''
)
+ Write-Debug "Running 'Chocolatey-InstallAll' with source:`'$source`'";
+
if ($source -eq '' -or $source -eq 'https://go.microsoft.com/fwlink/?LinkID=230477' -or $source -eq 'http://chocolatey.org/api/v2/') {
write-host 'Source must be specified and cannot be nuget.org/chocolatey.org'
return
View
2 src/functions/Chocolatey-InstallIfMissing.ps1
@@ -5,6 +5,8 @@ param(
[string] $version = ''
)
+ Write-Debug "Running 'Chocolatey-InstallIfMissing' for $packageName with source:`'$source`', version: `'$version`'";
+
$versions = Chocolatey-Version $packageName $source
if ($versions.'found' -contains 'no version' -or ($version -ne '' -and $versions.'found' -ne $version)) {
View
7 src/functions/Chocolatey-List.ps1
@@ -3,7 +3,8 @@ param(
[string] $selector='',
[string] $source=''
)
-
+ Write-Debug "Running 'Chocolatey-List' with selector: `'$selector`', source:`'$source`'";
+
if ($source -like 'webpi') {
$webpiArgs ="/c webpicmd /List /ListOption:All"
& cmd.exe $webpiArgs
@@ -17,15 +18,17 @@ param(
}
if ($allVersions -eq $true) {
+ Write-Debug "Showing all versions of packages"
$parameters = "$parameters -all"
}
if ($prerelease -eq $true) {
+ Write-Debug "Showing prerelease versions of packages"
$parameters = "$parameters -Prerelease";
}
+ Write-Debug "Calling nuget with `'$parameters $srcArgs`'"
$parameters = "$parameters $srcArgs"
- #write-host "TEMP: Args - $parameters"
Start-Process $nugetExe -ArgumentList $parameters -NoNewWindow -Wait
}
View
3 src/functions/Chocolatey-NuGet.ps1
@@ -3,6 +3,7 @@ param(
[string] $packageName,
[string] $source = ''
)
+ Write-Debug "Running 'Chocolatey-NuGet' for $packageName with source:`'$source`'";
if ($packageName -eq 'all') {
Chocolatey-InstallAll $source
@@ -23,6 +24,8 @@ $h1
$nugetOutput = Run-NuGet $packageName $source $version
foreach ($line in $nugetOutput) {
+ Write-Debug "Evaluating NuGet output for line: $line"
+
if ($line -like "*already installed." -and $force -eq $false) {
Write-Host "$line - If you want to reinstall the current version of an existing package, please use the -force command."
Write-Host ""
View
1 src/functions/Chocolatey-Pack.ps1
@@ -2,6 +2,7 @@
param(
[string] $packageName
)
+ Write-Debug "Running 'Chocolatey-Pack' for $packageName. If nuspec name is not passed, it will find the nuspec file in the current working directory";
$packageArgs = "pack $packageName -NoPackageAnalysis"
$logFile = Join-Path $nugetChocolateyPath 'pack.log'
View
3 src/functions/Chocolatey-PackagesConfig.ps1
@@ -4,9 +4,12 @@ param(
[ValidateNotNullOrEmpty()]
[string] $packagesConfigPath
)
+ Write-Debug "Running 'Chocolatey-PackagesConfig' with packagesConfigPath:`'$packagesConfigPath`'";
if(-not(Test-Path $packagesConfigPath)) {
+ Write-Debug "No file exists at `'$packagesConfigPath`'"
if (-not($($packagesConfigPath).Contains('\'))) {
+ Write-Debug "Going to attempt to install $packagesConfigPath as regular chocolatey package."
Chocolatey-NuGet $packagesConfigPath
}
View
2 src/functions/Chocolatey-Push.ps1
@@ -3,10 +3,12 @@ param(
[string] $packageName,
[string] $source = 'http://chocolatey.org/'
)
+ Write-Debug "Running 'Chocolatey-Push' for $packageName with source:`'$source`'";
$srcArgs = "-source $source"
if ($source -like '') {
$srcArgs = '-source http://chocolatey.org/'
+ Write-Debug "Setting source to `'$srcArgs`'"
}
$packageArgs = "push $packageName $srcArgs"
View
4 src/functions/Chocolatey-Python.ps1
@@ -5,6 +5,8 @@ param(
[string] $installerArguments =''
)
+ Write-Debug "Running 'Chocolatey-Python' for $packageName with version:`'$version`', installerArguments: `'$installerArguments`'";
+
Chocolatey-InstallIfMissing 'python'
if ($($env:Path).ToLower().Contains("python") -eq $false) {
@@ -24,10 +26,12 @@ $h1
$packageArgs = "/c easy_install $packageName"
if ($version -notlike '') {
+ Write-Debug "Adding version arguments `'$version`'"
$packageArgs = "/c easy_install $packageName==$version";
}
if ($installerArguments -ne '') {
+ Write-Debug "Adding installerArguments `'$installerArguments`'"
$packageArgs = "$packageArgs $installerArguments";
}
View
10 src/functions/Chocolatey-Uninstall.ps1
@@ -4,6 +4,7 @@ param(
[string] $version = '',
[string] $installerArguments = ''
)
+ Write-Debug "Running 'Chocolatey-Uninstall' for $packageName with version:`'$version`', installerArguments: `'$installerArguments`'";
if ($packageName -eq 'all') {
write-host "Uninstalling all packages is not yet supported in this version. "
@@ -21,12 +22,13 @@ $h1
foreach ($package in $packages) {
$versions = Chocolatey-Version $package $source
if ($versions.found -eq "no version") {
- write-host "not installed"
+ write-host "not installed"
}
else {
- $packageFolder = Join-Path $nugetLibPath "$($package).$($versions.found)"
- Run-ChocolateyPS1 $packageFolder $package "uninstall"
- Remove-Item -Recurse -Force $packageFolder
+ Write-Debug "Looking for $($package).$($versions.found)"
+ $packageFolder = Join-Path $nugetLibPath "$($package).$($versions.found)"
+ Run-ChocolateyPS1 $packageFolder $package "uninstall"
+ Remove-Item -Recurse -Force $packageFolder
}
}
}
View
2 src/functions/Chocolatey-Update.ps1
@@ -3,8 +3,8 @@ param(
[string] $packageName ='',
[string] $source = ''
)
-
if ($packageName -eq '') {$packageName = 'chocolatey';}
+ Write-Debug "Running 'Chocolatey-Update' for $packageName with source:`'$source`'.";
$packages = $packageName
if ($packageName -eq 'all') {
View
2 src/functions/Chocolatey-Version.ps1
@@ -5,9 +5,11 @@ param(
)
if ($packageName -eq '') {$packageName = 'chocolatey';}
+ Write-Debug "Running 'Chocolatey-Version' for $packageName with source:`'$source`'.";
$packages = $packageName
if ($packageName -eq 'all') {
+ Write-Debug "Updating all packages in $nugetLibPath"
@micahlmartin
micahlmartin added a note Jul 10, 2012

Not sure this message is correct. We should just be checking for versions not actually updating anything right? Or perhaps I'm missing something.

@ferventcoder
chocolatey member
ferventcoder added a note Jul 10, 2012

You are correct sir...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
$packageFolders = Get-ChildItem $nugetLibPath | sort name
$packages = $packageFolders -replace "(\.\d{1,})+"|gu
}
View
3 src/functions/Chocolatey-WebPI.ps1
@@ -3,6 +3,7 @@ param(
[string] $packageName,
[string] $installerArguments =''
)
+ Write-Debug "Running 'Chocolatey-WebPI' for $packageName with installerArguments:`'$installerArguments`'";
Chocolatey-InstallIfMissing 'webpicommandline'
@@ -17,8 +18,10 @@ $h1
$packageArgs = "/c webpicmd /Install /AcceptEula /SuppressReboot /Products:$packageName"
if ($installerArguments -ne '') {
+ Write-Debug "Adding installerArguments `'$installerArguments`'"
$packageArgs = "$packageArgs $installerArguments"
}
+
if ($overrideArgs -eq $true) {
$packageArgs = "/c webpicmd $installerArguments /Products:$packageName"
write-host "Overriding arguments for WebPI to be `'$packageArgs`'"
View
3 src/functions/Delete-ExistingErrorLog.ps1
@@ -2,11 +2,14 @@
param(
[string] $packageName
)
+ Write-Debug "Running 'Delete-ExistingErrorLog' for $packageName";
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName"
$failureLog = Join-Path $tempDir 'failure.log'
+ Write-Debug "Looking for failure log at `'$failureLog`'"
if ([System.IO.File]::Exists($failureLog)) {
+ Write-Debug "Found the failure log. Deleting it..."
[System.IO.File]::Delete($failureLog)
}
}
View
2 src/functions/Generate-BinFile.ps1
@@ -4,6 +4,8 @@ param(
[string] $path,
[switch] $useStart
)
+ Write-Debug "Running 'Generate-BinFile' for $name with path:`'$path`'";
+
$packageBatchFileName = Join-Path $nugetExePath "$name.bat"
$path = $path.ToLower().Replace($nugetPath.ToLower(), "%DIR%..\").Replace("\\","\")
Write-Host "Adding $packageBatchFileName and pointing to $path"
View
2 src/functions/Get-ChocolateyBins.ps1
@@ -2,6 +2,8 @@ function Get-ChocolateyBins {
param(
[string] $packageFolder
)
+ Write-Debug "Running 'Get-ChocolateyBins' for $packageFolder";
+
if ($packageFolder -notlike '') {
@"
$h2
View
2 src/functions/Get-ConfigValue.ps1
@@ -4,6 +4,7 @@ param(
[ValidateNotNullOrEmpty()]
[string] $configValue
)
+ Write-Debug "Running 'Get-ConfigValue' with configValue:`'$configValue`'";
if ($globalConfig -eq '') {
$globalConfigFile = Join-Path $nugetChocolateyPath chocolatey.config
@@ -16,6 +17,7 @@ param(
$userConfig = $globalConfig
if (Test-Path($userConfigFile)) {
+ Write-Debug "A user config exists. We will use that first."
$userConfig = [xml] (Get-Content $userConfigFile)
}
}
View
2 src/functions/Get-LatestPackageVersion.ps1
@@ -7,9 +7,11 @@ param(
$packageVersions = $packageVersions.GetEnumerator() | sort-object -property Name -descending
if ($packageVersions -is [Object[]]) {
$latestPackageVersion = $packageVersions.GetEnumerator() | Select-Object -First 1
+ Write-Debug "Using $($latestPackageVersion.Value) as the latest version (from multiple found versions)"
$latestVersion = $latestPackageVersion.Value
}
else {
+ Write-Debug "Using $($packageversions.value) as the latest version"
$latestversion=$packageversions.value
}
}
View
3 src/functions/Get-LongPackageVersion.ps1
@@ -2,7 +2,6 @@ function Get-LongPackageVersion {
param(
[string] $packageVersion = ''
)
- #todo - make this compare prerelease information as well
$longVersion = $packageVersion.Split('-')[0].Split('.') | %{('0' * (8 - $_.Length)) + $_}
$longVersionReturn = [System.String]::Join('.',$longVersion)
@@ -11,6 +10,8 @@ param(
$prerelease = $packageVersion.Substring($packageVersion.IndexOf('-') + 1)
$longVersionReturn += ".$($prerelease)"
}
+
+ Write-Debug "Long version of $packageVersion is `'$longVersionReturn`'"
return $longVersionReturn
}
View
3 src/functions/Remove-LastInstallLog.ps1
@@ -2,7 +2,8 @@
param(
[string] $chocoInstallLog = ''
)
-
+ Write-Debug "Running 'Remove-LastInstallLog' with chocoInstallLog:`'$chocoInstallLog`'";
+
if ($chocoInstallLog -eq '') {
$chocoInstallLog = (Join-Path $nugetChocolateyPath 'chocolateyInstall.log')
}
View
10 src/functions/Run-ChocolateyPS1.ps1
@@ -1,6 +1,10 @@
function Run-ChocolateyPS1 {
-param([string] $packageFolder, [string] $packageName, [string] $action)
-
+param(
+ [string] $packageFolder,
+ [string] $packageName,
+ [string] $action
+)
+ Write-Debug "Running 'Run-ChocolateyPS1' for $packageName with packageFolder:`'$packageFolder`', action: `'$action`'";
switch ($action)
{
@@ -24,7 +28,7 @@ $h2
$ps1 = Get-ChildItem $packageFolder -recurse | ?{$_.name -match $actionFile} | sort name -Descending | select -First 1
$installps1 = Get-ChildItem $packageFolder -recurse | ?{$_.name -match 'chocolateyinstall.ps1'} | sort name -Descending | select -First 1
- Write-Debug "action file is $ps1"
+ Write-Debug "action file is `'$ps1`'"
if ($ps1 -notlike '') {
$env:chocolateyInstallArguments = "$installArguments"
View
3 src/functions/Run-NuGet.ps1
@@ -4,6 +4,7 @@ param(
[string] $source = '',
[string] $version = ''
)
+ Write-Debug "Running 'Run-NuGet' for $packageName with source: `'$source`', version:`'$version`'";
@"
$h2
NuGet
@@ -36,7 +37,7 @@ $h2
}
if (($nugetOutput -eq '' -or $nugetOutput -eq $null) -and ($errors -eq '' -or $errors -eq $null)) {
- $noExecution = 'Execution of NuGet not detected. Please make sure you have .NET Framework 4.0 installed.'
+ $noExecution = 'Execution of NuGet not detected. Please make sure you have .NET Framework 4.0 installed and are passing arguments to the install command.'
#write-host -BackgroundColor Red -ForegroundColor White
Throw $noExecution
}
View
5 src/helpers/functions/Get-ChocolateyUnzip.ps1
@@ -28,8 +28,9 @@ param(
[string] $fileFullPath,
[string] $destination
)
-
- Write-Host "Extracting $fileFullPath to $destination..."
+ Write-Debug "Running 'Get-ChocolateyUnzip' with fileFullPath:`'$fileFullPath`'',destination:$destination";
+
+ Write-Host "Extracting $fileFullPath to $destination..."
if (![System.IO.Directory]::Exists($destination)) {[System.IO.Directory]::CreateDirectory($destination)}
$shellApplication = new-object -com shell.application
View
2 src/helpers/functions/Get-ChocolateyWebFile.ps1
@@ -36,6 +36,7 @@ param(
[string] $url,
[string] $url64bit = $url
)
+ Write-Debug "Running 'Get-ChocolateyWebFile' for $packageName with url:`'$url`', fileFullPath:`'$fileFullPath`',and url64bit:`'$url64bit`'";
$url32bit = $url;
$processor = Get-WmiObject Win32_Processor
@@ -54,6 +55,7 @@ param(
if ($url.StartsWith('http')) {
Get-WebFile $url $fileFullPath
} else {
+ Write-Debug "We are attempting to copy the local item `'$url`' to `'$fileFullPath`'"
Copy-Item $url -Destination $fileFullPath -Force
}
View
7 src/helpers/functions/Get-WebFile.ps1
@@ -16,20 +16,22 @@
##############################################################################################################
function Get-WebFile {
param(
- $url = (Read-Host "The URL to download"),
+ $url = '', #(Read-Host "The URL to download"),
$fileName = $null,
$userAgent = $null,
[switch]$Passthru,
[switch]$quiet
)
-
+ Write-Debug "Running 'Get-WebFile' for $fileName with url:`'$url`', userAgent: `'$userAgent`' ";
+ #if ($url -eq '' return)
$req = [System.Net.HttpWebRequest]::Create($url);
#to check if a proxy is required
$webclient = new-object System.Net.WebClient
if (!$webclient.Proxy.IsBypassed($url))
{
$creds = [net.CredentialCache]::DefaultCredentials
if ($creds -eq $null) {
+ Write-Debug "Default credentials were null. Attempting backup method"
$cred = get-credential
$creds = $cred.GetNetworkCredential();
}
@@ -43,6 +45,7 @@ param(
#http://stackoverflow.com/questions/518181/too-many-automatic-redirections-were-attempted-error-message-when-using-a-httpw
$req.CookieContainer = New-Object System.Net.CookieContainer
if ($userAgent -ne $null) {
+ Write-Debug "Setting the UserAgent to `'$userAgent`'"
$req.UserAgent = $userAgent
}
$res = $req.GetResponse();
View
3 src/helpers/functions/Install-ChocolateyDesktopLink.ps1
@@ -2,7 +2,8 @@
param(
[string] $targetFilePath
)
-
+ Write-Debug "Running 'Install-ChocolateyDesktopLink' with targetFilePath:`'$targetFilePath`'";
+
if (test-path($targetFilePath)) {
$desktop = $([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::DesktopDirectory))
$link = Join-Path $desktop "$([System.IO.Path]::GetFileName($targetFilePath)).lnk"
View
3 src/helpers/functions/Install-ChocolateyPath.ps1
@@ -3,7 +3,8 @@ param(
[string] $pathToInstall,
[System.EnvironmentVariableTarget] $pathType = [System.EnvironmentVariableTarget]::User
)
-
+ Write-Debug "Running 'Install-ChocolateyPath' with pathToInstall:`'$pathToInstall`'";
+
#get the PATH variable
$envPath = $env:PATH
#$envPath = [Environment]::GetEnvironmentVariable('Path', $pathType)
View
3 src/helpers/functions/Install-ChocolateyPowershellCommand.ps1
@@ -5,7 +5,8 @@ param(
[string] $url ='',
[string] $url64bit = $url
)
-
+ Write-Debug "Running 'Install-ChocolateyPowershellCommand' for $packageName with psFileFullPath:`'$psFileFullPath`', url: `'$url`', url64bit:`'$url64bit`' ";
+
try {
if ($url -ne '') {
View
3 src/helpers/functions/Install-ChocolateyZipPackage.ps1
@@ -39,7 +39,8 @@ param(
[string] $unzipLocation,
[string] $url64bit = $url
)
-
+ Write-Debug "Running 'Install-ChocolateyZipPackage' for $packageName with url:`'$url`', unzipLocation: `'$unzipLocation`', url64bit: `'$url64bit`' ";
+
try {
$fileType = 'zip'
View
3 src/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1
@@ -6,7 +6,8 @@ param(
[switch] $noSleep,
$validExitCodes = @(0)
)
-
+ Write-Debug "Running 'Start-ChocolateyProcessAsAdmin' with exeToRun:`'$exeToRun`', statements: `'$statements`' ";
+
$wrappedStatements = $statements;
if ($exeToRun -eq 'powershell') {
$exeToRun = "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe"
View
2 src/helpers/functions/Uninstall-ChocolateyPackage.ps1
@@ -38,6 +38,8 @@ param(
[string] $file,
$validExitCodes = @(0)
)
+ Write-Debug "Running 'Uninstall-ChocolateyPackage' for $packageName with fileType:`'$fileType`', silentArgs: `'$silentArgs`', file: `'$file`'";
+
$installMessage = "Uninstalling $packageName..."
write-host $installMessage
View
2 src/helpers/functions/Write-ChocolateyFailure.ps1
@@ -23,6 +23,4 @@ param(
-----------------------"
$errorMessage | Out-File -FilePath $logFile -Force -Append
Write-Error $errorMessage
-
- #cutStart-Sleep 8
}
View
2 src/helpers/functions/Write-ChocolateySuccess.ps1
@@ -20,6 +20,4 @@ param(
$successMessage = "$packageName has finished succesfully! The chocolatey gods have answered your request!"
$successMessage | Out-File -FilePath $logFile -Force -Append
Write-Host $successMessage
-
- #cutStart-Sleep 7
}

0 comments on commit f3499b7

Please sign in to comment.
Something went wrong with that request. Please try again.