From 7e78e9c47e039929b281bfd85497a09a2a6bc08f Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Mon, 10 Jun 2024 12:56:37 -0700 Subject: [PATCH 1/2] backports: pin using codename on Debian Debian 11 bullseye and Debian 12 bookworm backports release files look like this: https://deb.debian.org/debian/dists/bullseye-backports/InRelease: Suite: bullseye-backports Codename: bullseye-backports https://deb.debian.org/debian/dists/bookworm-backports/InRelease: Suite: stable-backports Codename: bookworm-backports Using "release" (aka Suite in the InRelease file) causes our pin to not match for bookworm because they changed it to stable-backports instead of $codename-backports. We can use codename to support both for this pin. Fixes #1187. --- manifests/backports.pp | 9 ++++++--- spec/classes/apt_backports_spec.rb | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index 83e3c49500..f2acb98a40 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -94,11 +94,14 @@ if $pin =~ Hash { $_pin = $pin } elsif $pin =~ Numeric or $pin =~ String { - # apt::source defaults to pinning to origin, but we should pin to release - # for backports + $pin_type = $facts['os']['name'] ? { + 'Debian' => 'codename', + 'Ubuntu' => 'release', + } + $_pin = { 'priority' => $pin, - 'release' => $_release, + $pin_type => $_release, } } else { fail('pin must be either a string, number or hash') diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 23031ab73a..765ae9be45 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -32,7 +32,7 @@ release: 'bookworm-backports', pin: { 'priority' => 200, - 'release' => 'bookworm-backports' + 'codename' => 'bookworm-backports' }, keyring: '/usr/share/keyrings/debian-archive-keyring.gpg', ) From b717f9743faa97c67e80d5791530d5a30f24bc0e Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Mon, 10 Jun 2024 14:21:45 -0700 Subject: [PATCH 2/2] backports unit tests: delete linuxmint tests Linux Mint is not listed as supported in the metadata.json file, so we shouldn't carry tests for it (which are using facts for an end-of-life release). --- spec/classes/apt_backports_spec.rb | 82 ------------------------------ 1 file changed, 82 deletions(-) diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 765ae9be45..e051913aae 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -146,88 +146,6 @@ end end - describe 'linuxmint tests' do - let(:facts) do - { - os: { - family: 'Debian', - name: 'LinuxMint', - release: { - major: '17', - full: '17' - }, - distro: { - codename: 'qiana', - id: 'LinuxMint' - } - } - } - end - - context 'with all the needed things set' do - let(:params) do - { - location: 'http://archive.ubuntu.com/ubuntu', - release: 'trusty-backports', - repos: 'main universe multiverse restricted', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5' - } - end - - it { - expect(subject).to contain_apt__source('backports').with( - location: 'http://archive.ubuntu.com/ubuntu', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5', - repos: 'main universe multiverse restricted', - release: 'trusty-backports', - pin: { 'priority' => 200, 'release' => 'trusty-backports' }, - ) - } - end - - context 'with missing location' do - let(:params) do - { - release: 'trusty-backports', - repos: 'main universe multiverse restricted', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5' - } - end - - it do - expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, and repos}) - end - end - - context 'with missing release' do - let(:params) do - { - location: 'http://archive.ubuntu.com/ubuntu', - repos: 'main universe multiverse restricted', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5' - } - end - - it do - expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, and repos}) - end - end - - context 'with missing repos' do - let(:params) do - { - location: 'http://archive.ubuntu.com/ubuntu', - release: 'trusty-backports', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5' - } - end - - it do - expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, and repos}) - end - end - end - describe 'validation' do let(:facts) do {