From 889906a0de4750eb84dcb5f6bedb9104f7fae28b Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sat, 7 Feb 2015 18:58:43 -0600 Subject: [PATCH 1/2] (GH-78) Unpack self should use relative directory Using ApplicationParameters.InstallLocation will use the global chocolatey install path, which can lead to undesired behavior. --- .../infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs | 2 +- .../infrastructure/extractors/AssemblyFileExtractor.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs index 3fa541c7a5..9b16d04cad 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs @@ -98,7 +98,7 @@ public void run(ChocolateyConfiguration configuration) AssemblyFileExtractor.extract_all_resources_to_relative_directory( _fileSystem, assembly, - ApplicationParameters.InstallLocation, + _fileSystem.get_directory_name(Assembly.GetExecutingAssembly().Location), folders, ApplicationParameters.ChocolateyFileResources, overwriteExisting: configuration.Force); diff --git a/src/chocolatey/infrastructure/extractors/AssemblyFileExtractor.cs b/src/chocolatey/infrastructure/extractors/AssemblyFileExtractor.cs index 31c9f426b4..74957c46a3 100644 --- a/src/chocolatey/infrastructure/extractors/AssemblyFileExtractor.cs +++ b/src/chocolatey/infrastructure/extractors/AssemblyFileExtractor.cs @@ -100,6 +100,7 @@ public static void extract_all_resources_to_relative_directory(IFileSystem fileS //var fileLocation = fileSystem.combine_paths("", resourceString.ToString().Split('.')) + resourceName.Substring(fileExtensionLocation); var filePath = fileSystem.combine_paths(directoryPath, fileLocation); + "chocolatey".Log().Debug("Unpacking {0} to '{1}'".format_with(fileLocation,filePath)); extract_binary_file_from_assembly(fileSystem, assembly, resourceName, filePath, overwriteExisting); } } From 82d2760a3d325a43ed0b810098b4a0ac7c8a7a83 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sat, 7 Feb 2015 19:02:22 -0600 Subject: [PATCH 2/2] (GH-7) install - unpacking log debut output When set in debug mode, unpackself should also be called with `-dv` --- nuget/chocolatey/tools/chocolateysetup.psm1 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/nuget/chocolatey/tools/chocolateysetup.psm1 b/nuget/chocolatey/tools/chocolateysetup.psm1 index faca2d3a5e..4eeee38e45 100644 --- a/nuget/chocolatey/tools/chocolateysetup.psm1 +++ b/nuget/chocolatey/tools/chocolateysetup.psm1 @@ -4,6 +4,7 @@ $sysDrive = $env:SystemDrive $tempDir = $env:TEMP $defaultChocolateyPathOld = "$sysDrive\Chocolatey" $ErrorActionPreference = 'Stop' +$debugMode = $false function Initialize-Chocolatey { <# @@ -30,9 +31,16 @@ function Initialize-Chocolatey { param( [Parameter(Mandatory=$false)][string]$chocolateyPath = '' ) + if ($env:ChocolateyEnvironmentDebug -ne $null) { + $debugMode = $true + } $chocoNew = Join-Path $thisScriptFolder 'chocolateyInstall\choco.exe' - & $chocoNew unpackself --force + if ($debugMode) { + & $chocoNew unpackself -fdv + } else { + & $chocoNew unpackself -f + } $installModule = Join-Path $thisScriptFolder 'chocolateyInstall\helpers\chocolateyInstaller.psm1' Import-Module $installModule -Force @@ -200,7 +208,12 @@ param( $chocoExe = Join-Path $chocInstallFolder 'choco.exe' $chocoExeDest = Join-Path $chocolateyPath 'choco.exe' Copy-Item $chocoExe $chocoExeDest -force - & $chocoExeDest unpackself --force + + if ($debugMode) { + & $chocoExeDest unpackself -fdv + } else { + & $chocoExeDest unpackself -f + } } function Ensure-ChocolateyLibFiles {