]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
(#11953) Apt::force passes $version to aptitude
authorMatthaus Litteken <matthaus@puppetlabs.com>
Fri, 13 Jan 2012 23:29:47 +0000 (15:29 -0800)
committerMatthaus Litteken <matthaus@puppetlabs.com>
Fri, 13 Jan 2012 23:29:47 +0000 (15:29 -0800)
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.

manifests/force.pp
spec/defines/force_spec.rb

index ece532acd0578ac740eba49c324e3b1a559cdbbe..ec6f57e2ccdb540bf4c1cad82edc115beb863861 100644 (file)
@@ -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}'"
index d040dc9962adc8a3afb75d7a8775770d1dcf85e6..8477a08560409f7cba390483e75cca8d51a143e0 100644 (file)
@@ -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