Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable: (22 commits)
  (GH-121) Making Uninstall-ChocolateyZipPackage more robust when
deleting files that were copied during installation of the Zip package
  (doc) update changelog/nuspec
  (GH-238) ApiKey source matching intuitive
  (maint) formatting
  (GH-240) Set CredentialProvider for NuGet
  (GH-240) ChocolateyNugetCredentialProvider
  (GH-240) Add default sources to machine sources
  (maint) Only warn subcommand list if not empty
  (GH-171) Use RedirectedHttpClient
  (GH-240) pass credentials at runtime
  (GH-240)(config) Add machine sources
  (doc) how to quote values
  (GH-230) Export all functions and aliases imported
  (GH-230) Fix Issues with Generate/Remove BinFile
  (GH-185) Remove console prompt default choices
  (GH-186) Uninstall - no prompt for one version
  (GH-182) Ask before printing ps1 scripts
  (GH-187) Show log file path in messages.
  (maint) formatting
  (GH-169) Do not resolve disabled sources
  ...

Conflicts:
	src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs
	src/chocolatey/infrastructure.app/runners/GenericRunner.cs
  • Loading branch information
ferventcoder committed Apr 20, 2015
2 parents a7e9cae + 3618159 commit 2ed0d63
Show file tree
Hide file tree
Showing 31 changed files with 409 additions and 99 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
## [0.9.9.5](https://github.com/chocolatey/choco/issues?q=milestone%3A0.9.9.5+is%3Aclosed) (April 20, 2015)

### BREAKING CHANGES

* Renamed short option `p` to `i` for list --include-programs so that `p` could be ubiquitous for password across commands that optionally can pass a password - see [#240](https://github.com/chocolatey/choco/issues/240)

### BUG FIXES

* Fix - Secure Sources Not Working - see [#240](https://github.com/chocolatey/choco/issues/240)
* Fix - Generate-BinFile / Remove-BinFile - see [#230](https://github.com/chocolatey/choco/issues/230)
* Fix - cpack should only include files from nuspec - see [#232](https://github.com/chocolatey/choco/issues/232)
* Fix - cpack should leave nupkg in current directory - see [#231](https://github.com/chocolatey/choco/issues/231)
* Fix - Install-PowerShellCommand uses incorrect path - see [#241](https://github.com/chocolatey/choco/issues/241)
* Fix - choco list source with redirects does not resolve - see [#171](https://github.com/chocolatey/choco/issues/171)
* Fix - choco tried to resolve disabled repo - see [#169](https://github.com/chocolatey/choco/issues/169)
* Fix - cpack nuspec results in "The path is not of a legal form" - see [#164](https://github.com/chocolatey/choco/issues/164)
* Fix - cpack hangs on security related issue - see [#160](https://github.com/chocolatey/choco/issues/160)
* Fix - spelling error in "package has been upgradeed successfully" - see [#64](https://github.com/chocolatey/choco/issues/64)

### IMPROVEMENTS

* Api Key and Source matching could be more intuitive - see [#228](https://github.com/chocolatey/choco/issues/238)
* Remove warning about allowGlobalConfirmation being enabled - see [#237](https://github.com/chocolatey/choco/issues/237)
* Include log file path when saying 'See the log for details' - see [#187](https://github.com/chocolatey/choco/issues/187)
* Uninstall prompts for version when there is only one installed - see [#186](https://github.com/chocolatey/choco/issues/186)
* Do not offer a default option when prompting for a user choice - see [#185](https://github.com/chocolatey/choco/issues/185)
* Remove the warning note about skipping, and instead show the warning when selecting skip - see [#183](https://github.com/chocolatey/choco/issues/183)
* Do not print PowerShell install/update scripts by default - see [#182](https://github.com/chocolatey/choco/issues/182)

## [0.9.9.4](https://github.com/chocolatey/choco/issues?q=milestone%3A0.9.9.4+is%3Aclosed) (March 30, 2015)

### BUG FIXES
Expand Down
29 changes: 29 additions & 0 deletions nuget/chocolatey/chocolatey.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@ In that mess there is a link to the [Helper Reference](https://github.com/chocol
<releaseNotes>
See all - https://github.com/chocolatey/choco/blob/master/CHANGELOG.md

## 0.9.9.5

### BREAKING CHANGES

* Renamed short option `p` to `i` for list --include-programs so that `p` could be ubiquitous for password across commands that optionally can pass a password - see [#240](https://github.com/chocolatey/choco/issues/240)

### BUG FIXES

* Fix - Secure Sources Not Working - see [#240](https://github.com/chocolatey/choco/issues/240)
* Fix - Generate-BinFile / Remove-BinFile - see [#230](https://github.com/chocolatey/choco/issues/230)
* Fix - cpack should only include files from nuspec - see [#232](https://github.com/chocolatey/choco/issues/232)
* Fix - cpack should leave nupkg in current directory - see [#231](https://github.com/chocolatey/choco/issues/231)
* Fix - Install-PowerShellCommand uses incorrect path - see [#241](https://github.com/chocolatey/choco/issues/241)
* Fix - choco list source with redirects does not resolve - see [#171](https://github.com/chocolatey/choco/issues/171)
* Fix - choco tried to resolve disabled repo - see [#169](https://github.com/chocolatey/choco/issues/169)
* Fix - cpack nuspec results in "The path is not of a legal form" - see [#164](https://github.com/chocolatey/choco/issues/164)
* Fix - cpack hangs on security related issue - see [#160](https://github.com/chocolatey/choco/issues/160)
* Fix - spelling error in "package has been upgradeed successfully" - see [#64](https://github.com/chocolatey/choco/issues/64)

### IMPROVEMENTS

* Api Key and Source matching could be more intuitive - see [#228](https://github.com/chocolatey/choco/issues/238)
* Remove warning about allowGlobalConfirmation being enabled - see [#237](https://github.com/chocolatey/choco/issues/237)
* Include log file path when saying 'See the log for details' - see [#187](https://github.com/chocolatey/choco/issues/187)
* Uninstall prompts for version when there is only one installed - see [#186](https://github.com/chocolatey/choco/issues/186)
* Do not offer a default option when prompting for a user choice - see [#185](https://github.com/chocolatey/choco/issues/185)
* Remove the warning note about skipping, and instead show the warning when selecting skip - see [#183](https://github.com/chocolatey/choco/issues/183)
* Do not print PowerShell install/update scripts by default - see [#182](https://github.com/chocolatey/choco/issues/182)

## 0.9.9.4

### BUG FIXES
Expand Down
25 changes: 0 additions & 25 deletions src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ private static void Main(string[] args)
"chocolatey".Log().Debug(() => "{0} is running on {1} v {2}".format_with(ApplicationParameters.Name, config.Information.PlatformType, config.Information.PlatformVersion.to_string()));
//"chocolatey".Log().Debug(() => "Command Line: {0}".format_with(Environment.CommandLine));

warn_when_admin_needs_elevation(config);
remove_old_chocolatey_exe(fileSystem);

LicenseValidation.validate(fileSystem);
Expand Down Expand Up @@ -180,30 +179,6 @@ private static void trap_exit_scenarios(ChocolateyConfiguration config)
ExitScenarioHandler.SetHandler();
}

private static void warn_when_admin_needs_elevation(ChocolateyConfiguration config)
{
// NOTE: blended options may not have been fully initialized yet
if (!config.PromptForConfirmation) return;

if (!config.Information.IsProcessElevated && config.Information.IsUserAdministrator)
{
var selection = InteractivePrompt.prompt_for_confirmation(@"
Chocolatey detected you are not running from an elevated command shell
(cmd/powershell). You may experience errors - many functions/packages
require admin rights. Only advanced users should run choco w/out an
elevated shell. When you open the command shell, you should ensure
that you do so with ""Run as Administrator"" selected.
Do you want to continue?", new[] {"yes", "no"}, "no", requireAnswer: true);

if (selection.is_equal_to("no"))
{
pause_execution_if_debug();
Environment.Exit(-1);
}
}
}

private static void remove_old_chocolatey_exe(IFileSystem fileSystem)
{
try
Expand Down
4 changes: 2 additions & 2 deletions src/chocolatey.resources/chocolatey.resources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
<EmbeddedResource Include="helpers\functions\Test-ProcessAdminRights.ps1" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="helpers\functions\Generate-BinFile.ps1" />
<EmbeddedResource Include="helpers\functions\Remove-BinFile.ps1" />
<EmbeddedResource Include="helpers\functions\Install-BinFile.ps1" />
<EmbeddedResource Include="helpers\functions\Uninstall-BinFile.ps1" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="helpers\chocolateyScriptRunner.ps1" />
Expand Down
6 changes: 4 additions & 2 deletions src/chocolatey.resources/helpers/chocolateyInstaller.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Get-Item $helpersPath\functions\*.ps1 |
? { -not ($_.Name.Contains(".Tests.")) } |
% {
. $_.FullName;
Export-ModuleMember -Function $_.BaseName
#Export-ModuleMember -Function $_.BaseName
}

# load extensions if they exist
Expand All @@ -48,4 +48,6 @@ if(Test-Path($extensionsPath)) {
Write-Debug 'Loading community extensions'
#Resolve-Path $extensionsPath\**\*\*.psm1 | % { Write-Debug "Importing `'$_`'"; Import-Module $_.ProviderPath }
Get-ChildItem $extensionsPath -recurse -filter "*.psm1" | Select -ExpandProperty FullName | % { Write-Debug "Importing `'$_`'"; Import-Module $_; }
}
}

Export-ModuleMember -Function * -Alias *
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function Generate-BinFile {
function Install-BinFile {
param(
[string] $name,
[string] $path,
[switch] $useStart,
[string] $command = ''
)
Write-Debug "Running 'Generate-BinFile' for $name with path:`'$path`'|`$useStart:$useStart|`$command:$command";
Write-Debug "Running 'Install-BinFile' for $name with path:`'$path`'|`$useStart:$useStart|`$command:$command";

$nugetPath = [System.IO.Path]::GetFullPath((Join-Path "$helpersPath" '..\'))
$nugetExePath = Join-Path "$nugetPath" 'bin'
$packageBatchFileName = Join-Path $nugetExePath "$name.bat"
$packageBashFileName = Join-Path $nugetExePath "$name"
$packageShimFileName = Join-Path $nugetExePath "$name.exe"
Expand Down Expand Up @@ -68,16 +70,16 @@ param(
}

if (Test-Path ($packageShimFileName)) {
Write-Host "Added $packageShimFileName shim pointed to `'$path`'." -ForegroundColor $Note
Write-Host "Added $packageShimFileName shim pointed to `'$path`'."
} else {
Write-Warning "An error occurred generating shim, using old method."

$path = "%DIR%$($path)"
$pathBash = $path.Replace("%DIR%..\","`$DIR/../").Replace("\","/")
Write-Host "Adding $packageBatchFileName and pointing to `'$path`'." -ForegroundColor $Note
Write-Host "Adding $packageBashFileName and pointing to `'$path`'." -ForegroundColor $Note
Write-Host "Adding $packageBatchFileName and pointing to `'$path`'."
Write-Host "Adding $packageBashFileName and pointing to `'$path`'."
if ($useStart) {
Write-Host "Setting up $name as a non-command line application." -ForegroundColor $Note
Write-Host "Setting up $name as a non-command line application."
"@echo off
SET DIR=%~dp0%
start """" ""$path"" %*" | Out-File $packageBatchFileName -encoding ASCII
Expand All @@ -100,4 +102,7 @@ exit /b %ERRORLEVEL%" | Out-File $packageBatchFileName -encoding ASCII

}
}
}
}

Set-Alias Generate-BinFile Install-BinFile
Set-Alias Add-BinFile Install-BinFile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# limitations under the License.

function UnInstall-ChocolateyZipPackage {
<#
.SYNOPSIS
Expand Down Expand Up @@ -50,7 +50,7 @@ param(
$zipContentFile
$zipContents=get-content $zipContentFile
foreach ($fileInZip in $zipContents) {
remove-item "$fileInZip" -ErrorAction SilentlyContinue
remove-item -Path "$fileInZip" -ErrorAction SilentlyContinue -Recurse -Force
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function Remove-BinFile {
function Uninstall-BinFile {
param(
[string] $name,
[string] $path
)
Write-Debug "Running 'Remove-BinFile' for $name with path:`'$path`'";
Write-Debug "Running 'Uninstall-BinFile' for $name with path:`'$path`'";

$nugetPath = [System.IO.Path]::GetFullPath((Join-Path "$helpersPath" '..\'))
$nugetExePath = Join-Path "$nugetPath" 'bin'
$packageBatchFileName = Join-Path $nugetExePath "$name.bat"
$packageBashFileName = Join-Path $nugetExePath "$name"
$packageShimFileName = Join-Path $nugetExePath "$name.exe"
Expand All @@ -28,15 +30,15 @@ param(
Write-Debug "Attempting to remove the batch and bash shortcuts: $packageBatchFileName and $packageBashFileName"

if (Test-Path $packageBatchFileName) {
Write-Host "Removing batch file $packageBatchFileName which pointed to `'$path`'." -ForegroundColor $Note
Write-Host "Removing batch file $packageBatchFileName which pointed to `'$path`'."
Remove-Item $packageBatchFileName
}
else {
Write-Debug "Tried to remove batch file $packageBatchFileName but it was already removed."
}

if (Test-Path $packageBashFileName) {
Write-Host "Removing bash file $packageBashFileName which pointed to `'$path`'." -ForegroundColor $Note
Write-Host "Removing bash file $packageBashFileName which pointed to `'$path`'."
Remove-Item $packageBashFileName
}
else {
Expand All @@ -45,10 +47,12 @@ param(

Write-Debug "Attempting to remove the shim: $packageShimFileName"
if (Test-Path $packageShimFileName) {
Write-Host "Removing shim $packageShimFileName which pointed to `'$path`'." -ForegroundColor $Note
Write-Host "Removing shim $packageShimFileName which pointed to `'$path`'."
Remove-Item $packageShimFileName
}
else {
Write-Debug "Tried to remove shim $packageShimFileName but it was already removed."
}
}
}

Set-Alias Remove-BinFile Uninstall-BinFile
1 change: 1 addition & 0 deletions src/chocolatey/chocolatey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<Compile Include="infrastructure.app\domain\PinCommandType.cs" />
<Compile Include="infrastructure.app\domain\SourceCommandType.cs" />
<Compile Include="infrastructure.app\messages\PostRunEvent.cs" />
<Compile Include="infrastructure.app\nuget\ChocolateyNugetCredentialProvider.cs" />
<Compile Include="infrastructure.app\nuget\NugetPush.cs" />
<Compile Include="infrastructure.app\runners\GenericRunner.cs" />
<Compile Include="infrastructure.app\services\AutomaticUninstallerService.cs" />
Expand Down
48 changes: 26 additions & 22 deletions src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static void set_file_configuration(ChocolateyConfiguration config, IFile

var configFileSettings = xmlService.deserialize<ConfigFileSettings>(globalConfigPath);
var sources = new StringBuilder();
foreach (var source in configFileSettings.Sources.or_empty_list_if_null())
foreach (var source in configFileSettings.Sources.Where(s => !s.Disabled).or_empty_list_if_null())
{
sources.AppendFormat("{0};", source.Value);
}
Expand All @@ -82,16 +82,18 @@ private static void set_file_configuration(ChocolateyConfiguration config, IFile
config.Sources = sources.Remove(sources.Length - 1, 1).ToString();
}

set_machine_sources(config, configFileSettings);

config.CacheLocation = !string.IsNullOrWhiteSpace(configFileSettings.CacheLocation) ? configFileSettings.CacheLocation : System.Environment.GetEnvironmentVariable("TEMP");
if (string.IsNullOrWhiteSpace(config.CacheLocation))
{
config.CacheLocation = fileSystem.combine_paths(ApplicationParameters.InstallLocation, "temp");
}

FaultTolerance.try_catch_with_logging_exception(
() => fileSystem.create_directory_if_not_exists(config.CacheLocation),
"Could not create temp directory at '{0}'".format_with(config.CacheLocation),
logWarningInsteadOfError: true);
() => fileSystem.create_directory_if_not_exists(config.CacheLocation),
"Could not create temp directory at '{0}'".format_with(config.CacheLocation),
logWarningInsteadOfError: true);

config.ContainsLegacyPackageInstalls = configFileSettings.ContainsLegacyPackageInstalls;
if (configFileSettings.CommandExecutionTimeoutSeconds <= 0)
Expand All @@ -101,20 +103,6 @@ private static void set_file_configuration(ChocolateyConfiguration config, IFile
config.CommandExecutionTimeoutSeconds = configFileSettings.CommandExecutionTimeoutSeconds;

set_feature_flags(config, configFileSettings);
if (!config.PromptForConfirmation)
{
if (notifyWarnLoggingAction != null)
{
const string logMessage = @"
Config has insecure allowGlobalConfirmation set to true.
This setting lowers the integrity of the security of your system. If
this is not intended, please change the setting using the feature
command.
";
notifyWarnLoggingAction.Invoke(logMessage);
}
}


// save so all updated configuration items get set to existing config
FaultTolerance.try_catch_with_logging_exception(
Expand All @@ -123,6 +111,20 @@ This setting lowers the integrity of the security of your system. If
logWarningInsteadOfError: true);
}

private static void set_machine_sources(ChocolateyConfiguration config, ConfigFileSettings configFileSettings)
{
foreach (var source in configFileSettings.Sources.Where(s => !s.Disabled).or_empty_list_if_null())
{
config.MachineSources.Add(new MachineSourceConfiguration
{
Key = source.Value,
Name = source.Id,
Username = source.UserName,
EncryptedPassword = source.Password
});
}
}

private static void set_feature_flags(ChocolateyConfiguration config, ConfigFileSettings configFileSettings)
{
config.Features.CheckSumFiles = set_feature_flag(ApplicationParameters.Features.CheckSumFiles, configFileSettings);
Expand Down Expand Up @@ -228,10 +230,12 @@ the local options are parsed.
* **Use Equals**: You can also include or not include an equals sign
`=` between options and values.
* **Quote Values**: When you need to quote things, such as when using
spaces, please use single quote marks (`'`). In cmd.exe, you can
also use double double quotes (i.e. `""""yo""""`). This is due to
the hand off to PowerShell - it seems to strip off the outer set of
quotes. TODO: TEST THIS, MAY NOT BE RELEVANT NOW.
spaces, please use apostrophes (`'value'`). In cmd.exe you may be
able to use just double quotes (`""value""`) but in powershell.exe
you may need to either escape the quotes with backticks
(`` `""value`"" ``) or use a combination of double quotes and
apostrophes (`""'value'""`). This is due to the hand off to
PowerShell - it seems to strip off the outer set of quotes.
* Options and switches apply to all items passed, so if you are
installing multiple packages, and you use `--version=1.0.0`, choco
is going to look for and try to install version 1.0.0 of every
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,10 @@ public void run(ChocolateyConfiguration configuration)
_configSettingsService.set_api_key(configuration);
}
}

public bool may_require_admin_access()
{
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void handle_additional_argument_parsing(IList<string> unparsedArguments,
Enum.TryParse(unparsedCommand, true, out command);
if (command == FeatureCommandType.unknown)
{
this.Log().Warn("Unknown command {0}. Setting to list.".format_with(unparsedCommand));
if (!string.IsNullOrWhiteSpace(unparsedCommand)) this.Log().Warn("Unknown command {0}. Setting to list.".format_with(unparsedCommand));
command = FeatureCommandType.list;
}

Expand Down Expand Up @@ -120,5 +120,10 @@ public void run(ChocolateyConfiguration configuration)
break;
}
}

public bool may_require_admin_access()
{
return true;
}
}
}
Loading

0 comments on commit 2ed0d63

Please sign in to comment.