From: Ashley Penney Date: Wed, 2 Oct 2013 17:56:06 +0000 (-0400) Subject: This switches us to doing a `test -s` instead of checking for the X-Git-Tag: 1.4.0~4^2~1 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2f9c16a2736e1de4eda3250984e2b1125efd849e;p=puppet-modules%2Fpuppetlabs-apt.git This switches us to doing a `test -s` instead of checking for the files existence as add-apt-repository --remove leaves a 0 byte file behind instead of deleting everything properly. --- diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 61b9b3a..e6954af 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -42,7 +42,7 @@ define apt::ppa( exec { "add-apt-repository-${name}": environment => $proxy_env, command => "/usr/bin/add-apt-repository ${options} ${name}", - creates => "${sources_list_d}/${sources_list_d_filename}", + onlyif => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", logoutput => 'on_failure', notify => Exec['apt_update'], require => [ diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index dfaf09c..853fdb6 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -45,7 +45,7 @@ describe 'apt::ppa', :type => :define do it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{options} #{t}", - 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) @@ -74,7 +74,7 @@ describe 'apt::ppa', :type => :define do it { should contain_exec("add-apt-repository-#{title}").with( 'environment' => [], 'command' => "/usr/bin/add-apt-repository #{options} #{title}", - 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) @@ -100,7 +100,7 @@ describe 'apt::ppa', :type => :define do "https_proxy=http://user:pass@proxy:8080", ], 'command' => "/usr/bin/add-apt-repository #{options} #{title}", - 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) diff --git a/spec/system/apt_ppa_spec.rb b/spec/system/apt_ppa_spec.rb index 8e7090b..2e2baf5 100644 --- a/spec/system/apt_ppa_spec.rb +++ b/spec/system/apt_ppa_spec.rb @@ -5,10 +5,11 @@ describe 'apt::ppa' do context 'reset' do it 'removes ppa' do shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*') + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') end end - context 'apt::ppa' do + context 'adding a ppa that doesnt exist' do it 'should work with no errors' do pp = <<-EOS include '::apt' @@ -29,9 +30,29 @@ describe 'apt::ppa' do end end + context 'readding a removed ppa.' do + it 'setup' do + shell('add-apt-repository -y ppa:raravena80/collectd5') + # This leaves a blank file + shell('add-apt-repository --remove ppa:raravena80/collectd5') + end + + it 'should readd it successfully' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:raravena80/collectd5': } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + end + end + end + context 'reset' do - it 'removes ppa' do + it 'removes added ppas' do shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*') + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') end end