Skip to content

Commit

Permalink
(GH-134) Only Enable AutoUninstaller in 0.9.9.x
Browse files Browse the repository at this point in the history
In 0.9.10, auto uninstaller should be enabled by default, so there is
no need to run to enable it.
  • Loading branch information
ferventcoder committed Jul 10, 2016
1 parent 9aa8af7 commit 79d2d17
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ if explicitly_require_windows_gems
gem 'win32-taskscheduler', '0.2.2', :require => false
gem 'windows-api', '0.4.3', :require => false
gem 'windows-pr', '1.2.3', :require => false
else

end

if File.exists? "#{__FILE__}.local"
Expand Down
15 changes: 5 additions & 10 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,22 @@
# version less than 0.9.9 and we don't know what the
# user may link to - it could be an older version of
# Chocolatey
if versioncmp($chocolatey::chocolatey_version, '0.9.9.0') >= 0 {

# lint:ignore:80chars
if versioncmp($chocolatey::chocolatey_version, '0.9.9.0') >= 0 and versioncmp($chocolatey::chocolatey_version, '0.9.10.0') < 0 {
$_choco_exe_path = "${chocolatey::choco_install_location}\\bin\\choco.exe"

$_enable_autouninstaller = $chocolatey::enable_autouninstaller ? {
false => 'disable',
default => 'enable'
}

if versioncmp($chocolatey::chocolatey_version, '0.9.10.0') >= 0 {
$_find_str = "autoUninstaller|${_enable_autouninstaller}d|"
} else {
$_find_str = "autoUninstaller - [${_enable_autouninstaller}d]"
}

# lint:ignore:80chars
exec { "chocolatey_autouninstaller_${_enable_autouninstaller}":
path => $::path,
command => "${_choco_exe_path} feature -r ${_enable_autouninstaller} -n autoUninstaller",
unless => "cmd.exe /c ${_choco_exe_path} feature list -r | findstr /B /I /C:\"${_find_str}\"",
unless => "cmd.exe /c ${_choco_exe_path} feature list -r | findstr /B /I /C:\"autoUninstaller - [${_enable_autouninstaller}d]\"",
environment => ["ChocolateyInstall=${::chocolatey::choco_install_location}"]
}
# lint:endignore
}
# lint:endignore
}
30 changes: 19 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
# `chocolatey.nupkg`. This must be a url, but not necessarily an OData feed.
# Any old url location will work. Defaults to
# `'https://chocolatey.org/api/v2/package/chocolatey/'`.
# @param [Boolean] enable_autouninstaller Should auto uninstaller be turned on?
# Auto uninstaller is what allows Chocolatey to automatically manage the
# uninstall of software from Programs and Features without necessarily
# requiring a `chocolateyUninstall.ps1` file in the package. Defaults to
# `true`.
# @param [Boolean] enable_autouninstaller [Deprecated] - Should auto
# uninstaller be turned on? Auto uninstaller is what allows Chocolatey to
# automatically manage the uninstall of software from Programs and Features
# without necessarily requiring a `chocolateyUninstall.ps1` file in the
# package. Defaults to `true`. Setting is ignored in Chocolatey v0.9.10+.
# @param [Boolean] log_output Log output from the installer. Defaults to
# `false`.
# @param [String] chocolatey_version chocolatey version, falls back to
Expand All @@ -69,16 +69,24 @@
$chocolatey_version = $::chocolatey::params::chocolatey_version
) inherits ::chocolatey::params {


validate_string($choco_install_location)
# lint:ignore:140chars
validate_re($choco_install_location, '^\w\:',
"Please use a full path for choco_install_location starting with a local drive. Reference choco_install_location => '${choco_install_location}'."
)
# lint:endignore

validate_bool($use_7zip)
validate_integer($choco_install_timeout_seconds)

validate_string($chocolatey_download_url)
# lint:ignore:140chars
validate_re($chocolatey_download_url,['^http\:\/\/','^https\:\/\/','file\:\/\/\/'],
"For chocolatey_download_url, if not using the default '${::chocolatey::params::download_url}', please use a Http/Https/File Url that downloads 'chocolatey.nupkg'."
)
validate_bool($use_7zip)
validate_string($choco_install_location)
validate_re($choco_install_location, '^\w\:',
"Please use a full path for choco_install_location starting with a local drive. Reference choco_install_location => '${choco_install_location}'."
)
validate_integer($choco_install_timeout_seconds)
# lint:endignore

validate_bool($enable_autouninstaller)

if ((versioncmp($::clientversion, '3.4.0') >= 0) and (!defined('$::serverversion') or versioncmp($::serverversion, '3.4.0') >= 0)) {
Expand Down

0 comments on commit 79d2d17

Please sign in to comment.