Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid CHEF-3694 in apt_preference resource #214

Merged
merged 1 commit into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache 2.0'
description 'Configures apt and apt services. Ships resources for managing apt repositories'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '5.0.0'
version '5.0.1'

recipe 'apt::default', 'Runs apt-get update during compile phase and sets up preseed directories'
recipe 'apt::cacher-ng', 'Set up an apt-cacher-ng caching proxy'
Expand Down
9 changes: 6 additions & 3 deletions providers/preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ def safe_name(name)

name = safe_name(new_resource.name)

file "/etc/apt/preferences.d/#{new_resource.name}.pref" do
file "cleanup_#{new_resource.name}.pref" do
path "/etc/apt/preferences.d/#{new_resource.name}.pref"
action :delete
if ::File.exist?("/etc/apt/preferences.d/#{new_resource.name}.pref")
Chef::Log.warn "Replacing #{new_resource.name}.pref with #{name}.pref in /etc/apt/preferences.d/"
end
only_if { name != new_resource.name }
end

file "/etc/apt/preferences.d/#{new_resource.name}" do
file "cleanup_#{new_resource.name}" do
path "/etc/apt/preferences.d/#{new_resource.name}"
action :delete
if ::File.exist?("/etc/apt/preferences.d/#{new_resource.name}")
Chef::Log.warn "Replacing #{new_resource.name} with #{new_resource.name}.pref in /etc/apt/preferences.d/"
Expand All @@ -77,7 +79,8 @@ def safe_name(name)
name = safe_name(new_resource.name)
if ::File.exist?("/etc/apt/preferences.d/#{name}.pref")
Chef::Log.info "Un-pinning #{name} from /etc/apt/preferences.d/"
file "/etc/apt/preferences.d/#{name}.pref" do
file "remove_#{name}.pref" do
path "/etc/apt/preferences.d/#{name}.pref"
action :delete
end
end
Expand Down