Browse Source

Merge pull request #333 from wilman0/master

Fix for debian/ubuntu hold and a way to add debian src only
Morgan Haskel 10 years ago
parent
commit
e970aa9a6d
6 changed files with 15 additions and 8 deletions
  1. 3 1
      README.md
  2. 2 2
      manifests/hold.pp
  3. 1 0
      manifests/source.pp
  4. 3 3
      spec/defines/hold_spec.rb
  5. 4 2
      spec/defines/source_spec.rb
  6. 2 0
      templates/source.list.erb

+ 3 - 1
README.md

@@ -202,7 +202,8 @@ Adds an apt source to `/etc/apt/sources.list.d/`.
       key               => '46925553',
       key               => '46925553',
       key_server        => 'subkeys.pgp.net',
       key_server        => 'subkeys.pgp.net',
       pin               => '-10',
       pin               => '-10',
-      include_src       => true
+      include_src       => true,
+      include_deb       => true
     }
     }
 
 
 If you would like to configure your system so the source is the Puppet Labs APT repository
 If you would like to configure your system so the source is the Puppet Labs APT repository
@@ -234,6 +235,7 @@ apt::sources:
       key_server: 'subkeys.pgp.net'
       key_server: 'subkeys.pgp.net'
       pin: '-10'
       pin: '-10'
       include_src: 'true'
       include_src: 'true'
+      include_deb: 'true'
 
 
   'puppetlabs':
   'puppetlabs':
       location: 'http://apt.puppetlabs.com'
       location: 'http://apt.puppetlabs.com'

+ 2 - 2
manifests/hold.pp

@@ -40,13 +40,13 @@ define apt::hold(
   }
   }
 
 
   if $ensure == 'present' {
   if $ensure == 'present' {
-    ::apt::pin { "hold ${package} at ${version}":
+    ::apt::pin { "hold_${package}":
       packages => $package,
       packages => $package,
       version  => $version,
       version  => $version,
       priority => $priority,
       priority => $priority,
     }
     }
   } else {
   } else {
-    ::apt::pin { "hold ${package} at ${version}":
+    ::apt::pin { "hold_${package}":
       ensure => 'absent',
       ensure => 'absent',
     }
     }
   }
   }

+ 1 - 0
manifests/source.pp

@@ -8,6 +8,7 @@ define apt::source(
   $release           = 'UNDEF',
   $release           = 'UNDEF',
   $repos             = 'main',
   $repos             = 'main',
   $include_src       = true,
   $include_src       = true,
+  $include_deb       = true,
   $required_packages = false,
   $required_packages = false,
   $key               = undef,
   $key               = undef,
   $key_server        = 'keyserver.ubuntu.com',
   $key_server        = 'keyserver.ubuntu.com',

+ 3 - 3
spec/defines/hold_spec.rb

@@ -25,7 +25,7 @@ describe 'apt::hold' do
         :priority => 1001,
         :priority => 1001,
       })
       })
 
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
         :ensure   => 'present',
         :packages => title,
         :packages => title,
         :version  => params[:version],
         :version  => params[:version],
@@ -42,7 +42,7 @@ describe 'apt::hold' do
         :ensure   => params[:ensure],
         :ensure   => params[:ensure],
       })
       })
 
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => params[:ensure],
         :ensure   => params[:ensure],
       })
       })
     end
     end
@@ -59,7 +59,7 @@ describe 'apt::hold' do
         :priority => params[:priority],
         :priority => params[:priority],
       })
       })
 
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
         :ensure   => 'present',
         :packages => title,
         :packages => title,
         :version  => params[:version],
         :version  => params[:version],

+ 4 - 2
spec/defines/source_spec.rb

@@ -15,6 +15,7 @@ describe 'apt::source', :type => :define do
       :release            => 'karmic',
       :release            => 'karmic',
       :repos              => 'main',
       :repos              => 'main',
       :include_src        => true,
       :include_src        => true,
+      :include_deb        => true,
       :required_packages  => false,
       :required_packages  => false,
       :key                => false,
       :key                => false,
       :key_server         => false,
       :key_server         => false,
@@ -83,8 +84,9 @@ describe 'apt::source', :type => :define do
         if param_hash[:architecture]
         if param_hash[:architecture]
           arch = "[arch=#{param_hash[:architecture]}] "
           arch = "[arch=#{param_hash[:architecture]}] "
         end
         end
-        content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
-
+        if param_hash[:include_deb]
+	  content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
+	end
         if param_hash[:include_src]
         if param_hash[:include_src]
           content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
           content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
         end
         end

+ 2 - 0
templates/source.list.erb

@@ -1,6 +1,8 @@
 #file generated by puppet
 #file generated by puppet
 # <%= @comment %>
 # <%= @comment %>
+<%- if @include_deb then -%>
 deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %>
 deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %>
+<%- end -%>
 <%- if @include_src then -%>
 <%- if @include_src then -%>
 deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %>
 deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %>
 <%- end -%>
 <%- end -%>