Skip to content

Commit b565ce0

Browse files
authored
Merge pull request #1188 from kenyon/backports-pin-to-codename
backports: pin using codename on Debian
2 parents a229aed + b717f97 commit b565ce0

File tree

2 files changed

+7
-86
lines changed

2 files changed

+7
-86
lines changed

manifests/backports.pp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,14 @@
9494
if $pin =~ Hash {
9595
$_pin = $pin
9696
} elsif $pin =~ Numeric or $pin =~ String {
97-
# apt::source defaults to pinning to origin, but we should pin to release
98-
# for backports
97+
$pin_type = $facts['os']['name'] ? {
98+
'Debian' => 'codename',
99+
'Ubuntu' => 'release',
100+
}
101+
99102
$_pin = {
100103
'priority' => $pin,
101-
'release' => $_release,
104+
$pin_type => $_release,
102105
}
103106
} else {
104107
fail('pin must be either a string, number or hash')

spec/classes/apt_backports_spec.rb

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
release: 'bookworm-backports',
3333
pin: {
3434
'priority' => 200,
35-
'release' => 'bookworm-backports'
35+
'codename' => 'bookworm-backports'
3636
},
3737
keyring: '/usr/share/keyrings/debian-archive-keyring.gpg',
3838
)
@@ -146,88 +146,6 @@
146146
end
147147
end
148148

149-
describe 'linuxmint tests' do
150-
let(:facts) do
151-
{
152-
os: {
153-
family: 'Debian',
154-
name: 'LinuxMint',
155-
release: {
156-
major: '17',
157-
full: '17'
158-
},
159-
distro: {
160-
codename: 'qiana',
161-
id: 'LinuxMint'
162-
}
163-
}
164-
}
165-
end
166-
167-
context 'with all the needed things set' do
168-
let(:params) do
169-
{
170-
location: 'http://archive.ubuntu.com/ubuntu',
171-
release: 'trusty-backports',
172-
repos: 'main universe multiverse restricted',
173-
key: '630239CC130E1A7FD81A27B140976EAF437D05B5'
174-
}
175-
end
176-
177-
it {
178-
expect(subject).to contain_apt__source('backports').with(
179-
location: 'http://archive.ubuntu.com/ubuntu',
180-
key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
181-
repos: 'main universe multiverse restricted',
182-
release: 'trusty-backports',
183-
pin: { 'priority' => 200, 'release' => 'trusty-backports' },
184-
)
185-
}
186-
end
187-
188-
context 'with missing location' do
189-
let(:params) do
190-
{
191-
release: 'trusty-backports',
192-
repos: 'main universe multiverse restricted',
193-
key: '630239CC130E1A7FD81A27B140976EAF437D05B5'
194-
}
195-
end
196-
197-
it do
198-
expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, and repos})
199-
end
200-
end
201-
202-
context 'with missing release' do
203-
let(:params) do
204-
{
205-
location: 'http://archive.ubuntu.com/ubuntu',
206-
repos: 'main universe multiverse restricted',
207-
key: '630239CC130E1A7FD81A27B140976EAF437D05B5'
208-
}
209-
end
210-
211-
it do
212-
expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, and repos})
213-
end
214-
end
215-
216-
context 'with missing repos' do
217-
let(:params) do
218-
{
219-
location: 'http://archive.ubuntu.com/ubuntu',
220-
release: 'trusty-backports',
221-
key: '630239CC130E1A7FD81A27B140976EAF437D05B5'
222-
}
223-
end
224-
225-
it do
226-
expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, and repos})
227-
end
228-
end
229-
end
230-
231149
describe 'validation' do
232150
let(:facts) do
233151
{

0 commit comments

Comments
 (0)