From: Matthaus Litteken Date: Fri, 13 Jan 2012 23:29:47 +0000 (-0800) Subject: (#11953) Apt::force passes $version to aptitude X-Git-Tag: 0.0.1~16^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f759bc039a6a132a262a196450aad2ca9fd5f735;p=puppet-modules%2Fpuppetlabs-apt.git (#11953) Apt::force passes $version to aptitude Previously, even if $version were passed to apt::force, aptitude would just install the default version of the package available. This updates the aptitude call to use the version string if it exists. If no version is passed, or if it is false, no version is added to the aptitude call. This also updates the rspec-puppet tests for the define, to reflect the changes to the exec. --- diff --git a/manifests/force.pp b/manifests/force.pp index ece532a..ec6f57e 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -6,7 +6,12 @@ define apt::force( $version = false ) { - exec { "/usr/bin/aptitude -y -t ${release} install ${name}": + $version_string = $version ? { + false => undef, + default => "=${version}", + } + + exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}": unless => $version ? { false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'", default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index d040dc9..8477a08 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -15,7 +15,8 @@ describe 'apt::force', :type => :define do base_command + (version ? "'Version: #{params[:version]}'" : "'Status: install'") end let :exec_title do - "/usr/bin/aptitude -y -t #{params[:release]} install #{title}" + base_exec = "/usr/bin/aptitude -y -t #{params[:release]} install #{title}" + base_exec + (version ? "=#{version}" : "") end it { should contain_exec(exec_title).with_unless(unless_query) } end