From f7628dac50cd43cd44bb4f7e5c343fe990b5af3f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 5 Sep 2024 09:27:27 +0100 Subject: [PATCH] Centralise enablement of backports --- cookbooks/apt/recipes/default.rb | 24 ++++++++++++++++++++++++ cookbooks/hardware/recipes/default.rb | 4 +--- cookbooks/otrs/recipes/default.rb | 4 +--- cookbooks/tile/recipes/default.rb | 7 ++----- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/cookbooks/apt/recipes/default.rb b/cookbooks/apt/recipes/default.rb index 75fa4147a..a8c35489b 100644 --- a/cookbooks/apt/recipes/default.rb +++ b/cookbooks/apt/recipes/default.rb @@ -45,6 +45,10 @@ if platform?("debian") archive_security_distro = "debian-security" archive_suites = %w[main updates backports security] archive_components = %w[main contrib non-free non-free-firmware] + backport_packages = case node[:lsb][:codename] + when "bookworm" then %w[osm2pgsql otrs2 smartmontools] + else %w[] + end elsif intel? archive_host = if node[:country] "#{node[:country]}.archive.ubuntu.com" @@ -56,6 +60,7 @@ elsif intel? archive_security_distro = archive_distro archive_suites = %w[main updates backports security] archive_components = %w[main restricted universe multiverse] + backport_packages = %w[] else archive_host = "ports.ubuntu.com" archive_security_host = archive_host @@ -63,6 +68,7 @@ else archive_security_distro = archive_distro archive_suites = %w[main updates backports security] archive_components = %w[main restricted universe multiverse] + backport_packages = %w[] end template "/etc/apt/sources.list" do @@ -80,6 +86,24 @@ template "/etc/apt/sources.list" do notifies :update, "apt_update[/etc/apt/sources.list]", :immediately end +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" + end +end + +execute "apt-cache-gencaches" do + action :nothing + command "apt-cache gencaches" + subscribes :run, "apt_preference[backports]", :immediately +end + apt_repository "openstreetmap" do uri "https://apt.openstreetmap.org" components ["main"] diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 5492134dc..6ea634ee9 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -466,9 +466,7 @@ disks = disks.compact.uniq if disks.count.positive? apt_preference "smartmontools" do - pin "release o=Debian Backports" - pin_priority "600" - only_if { platform?("debian") } + action :remove end package "smartmontools" diff --git a/cookbooks/otrs/recipes/default.rb b/cookbooks/otrs/recipes/default.rb index 13b6848ae..5ba8c1951 100644 --- a/cookbooks/otrs/recipes/default.rb +++ b/cookbooks/otrs/recipes/default.rb @@ -63,10 +63,8 @@ template "/etc/dbconfig-common/otrs2.conf" do :database_cluster => database_cluster end -# Ensure the OTRS package in backports has a priority preference. apt_preference "otrs2" do - pin "release o=Debian Backports" - pin_priority "600" + action :remove end apt_package "otrs2" diff --git a/cookbooks/tile/recipes/default.rb b/cookbooks/tile/recipes/default.rb index 4f067ee68..6d58bf806 100644 --- a/cookbooks/tile/recipes/default.rb +++ b/cookbooks/tile/recipes/default.rb @@ -505,11 +505,8 @@ directory "/var/log/tile" do mode "755" end -if platform?("debian") - apt_preference "osm2pgsql" do - pin "release o=Debian Backports" - pin_priority "600" - end +apt_preference "osm2pgsql" do + action :remove end package %w[ -- 2.39.5