-repository_actions = Hash.new do |_, repository|
- node[:apt][:sources].include?(repository) ? :add : :remove
-end
-
-apt_repository "brightbox-ruby-ng" do
- action repository_actions["brightbox-ruby-ng"]
- uri "ppa:brightbox/ruby-ng"
-end
-
-apt_repository "ubuntugis-stable" do
- action repository_actions["ubuntugis-stable"]
- uri "ppa:ubuntugis/ppa"
-end
-
-apt_repository "ubuntugis-unstable" do
- action repository_actions["ubuntugis-unstable"]
- uri "ppa:ubuntugis/ubuntugis-unstable"
-end
-
-apt_repository "openstreetmap" do
- action repository_actions["openstreetmap"]
- uri "ppa:osmadmins/ppa"
-end
-
-apt_repository "squid2" do
- action repository_actions["squid2"]
- uri "ppa:osmadmins/squid2"
-end
-
-apt_repository "squid3" do
- action repository_actions["squid3"]
- uri "ppa:osmadmins/squid3"
-end
-
-apt_repository "management-component-pack" do
- action repository_actions["management-component-pack"]
- uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
- if node[:lsb][:release].to_f >= 16.04
- distribution "xenial/current"
- else
- distribution "#{node[:lsb][:codename]}/current"
+if backport_packages.empty?
+ apt_preference "backports" do
+ action :remove
+ end
+else
+ apt_preference "backports" do
+ glob backport_packages.sort.map { |p| "src:#{p}" }.join(" ")
+ pin "release n=#{node[:lsb][:codename]}-backports"
+ pin_priority "500"