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

backports: pin using codename on Debian #1188

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions manifests/backports.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
84 changes: 1 addition & 83 deletions spec/classes/apt_backports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
release: 'bookworm-backports',
pin: {
'priority' => 200,
'release' => 'bookworm-backports'
'codename' => 'bookworm-backports'
},
keyring: '/usr/share/keyrings/debian-archive-keyring.gpg',
)
Expand Down Expand Up @@ -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
{
Expand Down
Loading