From 538a9f9aaba94f8089c20dd33e13bd87c3b659ac Mon Sep 17 00:00:00 2001 From: wilman0 Date: Fri, 18 Jul 2014 10:51:32 +0200 Subject: [PATCH] Update hold.pp fix for default debian installations all files in /etc/apt/preferences without _ will be silently ignore according to debian manpage. Addionally its not a good idea to write versionnumber in filename cause there is no way to delete this files if you increase versionumber Update source_spec.rb add a way to include debsrc only (useful for debian/ubuntu build server ... jenkins ect) Update source_spec.rb var rename Update source.list.erb add include_deb "switch" Update source.pp "include_deb" defaultvalue = true Update hold_spec.rb change the name of the preferences file (hold) Update source_spec.rb Update README.md Doku: 'include_deb' included next to 'include_src' in examples Update README.md typo --- README.md | 4 +++- manifests/hold.pp | 4 ++-- manifests/source.pp | 1 + spec/defines/hold_spec.rb | 6 +++--- spec/defines/source_spec.rb | 6 ++++-- templates/source.list.erb | 2 ++ 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0749cb8..9f3bbbe 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,8 @@ Adds an apt source to `/etc/apt/sources.list.d/`. key => '46925553', key_server => 'subkeys.pgp.net', 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 @@ -234,6 +235,7 @@ apt::sources: key_server: 'subkeys.pgp.net' pin: '-10' include_src: 'true' + include_deb: 'true' 'puppetlabs': location: 'http://apt.puppetlabs.com' diff --git a/manifests/hold.pp b/manifests/hold.pp index c4016c6..61e8afc 100644 --- a/manifests/hold.pp +++ b/manifests/hold.pp @@ -40,13 +40,13 @@ define apt::hold( } if $ensure == 'present' { - ::apt::pin { "hold ${package} at ${version}": + ::apt::pin { "hold_${package}": packages => $package, version => $version, priority => $priority, } } else { - ::apt::pin { "hold ${package} at ${version}": + ::apt::pin { "hold_${package}": ensure => 'absent', } } diff --git a/manifests/source.pp b/manifests/source.pp index dd00adc..259d0eb 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -8,6 +8,7 @@ define apt::source( $release = 'UNDEF', $repos = 'main', $include_src = true, + $include_deb = true, $required_packages = false, $key = undef, $key_server = 'keyserver.ubuntu.com', diff --git a/spec/defines/hold_spec.rb b/spec/defines/hold_spec.rb index 731e218..9da21d7 100644 --- a/spec/defines/hold_spec.rb +++ b/spec/defines/hold_spec.rb @@ -25,7 +25,7 @@ describe 'apt::hold' do :priority => 1001, }) - should contain_apt__pin("hold #{title} at #{params[:version]}").with({ + should contain_apt__pin("hold_#{title}").with({ :ensure => 'present', :packages => title, :version => params[:version], @@ -42,7 +42,7 @@ describe 'apt::hold' do :ensure => params[:ensure], }) - should contain_apt__pin("hold #{title} at #{params[:version]}").with({ + should contain_apt__pin("hold_#{title}").with({ :ensure => params[:ensure], }) end @@ -59,7 +59,7 @@ describe 'apt::hold' do :priority => params[:priority], }) - should contain_apt__pin("hold #{title} at #{params[:version]}").with({ + should contain_apt__pin("hold_#{title}").with({ :ensure => 'present', :packages => title, :version => params[:version], diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 7c7ae39..284adca 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -15,6 +15,7 @@ describe 'apt::source', :type => :define do :release => 'karmic', :repos => 'main', :include_src => true, + :include_deb => true, :required_packages => false, :key => false, :key_server => false, @@ -83,8 +84,9 @@ describe 'apt::source', :type => :define do if param_hash[:architecture] arch = "[arch=#{param_hash[:architecture]}] " 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] content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" end diff --git a/templates/source.list.erb b/templates/source.list.erb index a57244f..01b2176 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,6 +1,8 @@ #file generated by puppet # <%= @comment %> +<%- if @include_deb then -%> deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> +<%- end -%> <%- if @include_src then -%> deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> -- 2.32.3