Skip to content
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
8 changes: 5 additions & 3 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1211,11 +1211,11 @@ Default value: `undef`

##### <a name="-apt--source--types"></a>`types`

Data type: `Array[Enum['deb','deb-src'], 1, 2]`
Data type: `Optional[Array[Enum['deb','deb-src'], 1, 2]]`

DEB822: The package types this source manages.
DEB822: The package types this source manages. Defaults to the types enabled by `include`.

Default value: `['deb']`
Default value: `undef`

##### <a name="-apt--source--enabled"></a>`enabled`

Expand Down Expand Up @@ -1270,6 +1270,8 @@ Options:
* **:deb** `Boolean`: Specifies whether to request the distribution's compiled binaries.
* **:src** `Boolean`: Specifies whether to request the distribution's uncompiled source code.

DEB822: Used to set `types` when `types` is not given.

Default value: `{}`

##### <a name="-apt--source--key"></a>`key`
Expand Down
24 changes: 19 additions & 5 deletions manifests/source.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# DEB822: Supports an array of URL values
#
# @param types
# DEB822: The package types this source manages.
# DEB822: The package types this source manages. Defaults to the types enabled by `include`.
#
# @param enabled
# DEB822: Enable or Disable the APT source.
Expand Down Expand Up @@ -65,6 +65,8 @@
# @option include [Boolean] :src
# Specifies whether to request the distribution's uncompiled source code.
#
# DEB822: Used to set `types` when `types` is not given.
#
# @param key
# Creates an `apt::keyring` in `/etc/apt/keyrings` (or anywhere on disk given `filename`) Valid options:
# * a hash of `parameter => value` pairs to be passed to `file`: `name` (title), `content`, `source`, `filename`
Expand Down Expand Up @@ -102,7 +104,7 @@
#
define apt::source (
Enum['list', 'sources'] $source_format = 'list',
Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'],
Optional[Array[Enum['deb','deb-src'], 1, 2]] $types = undef,
Optional[Variant[String[1], Array[String[1]]]] $location = undef,
String[1] $comment = $name,
Boolean $enabled = true, # deb822
Expand Down Expand Up @@ -328,11 +330,23 @@
$_repos = $repos
}

if $types {
$_types = $types
} else {
$_includes = $apt::include_defaults + $include
$_types = delete_undef_values([
$_includes['deb'] ? { true => 'deb', default => undef },
$_includes['src'] ? { true => 'deb-src', default => undef },
])
}

if $architecture and $architecture !~ Array {
warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.")
$_architecture = split($architecture, '[,]')
$_architecture = regsubst(split($architecture, '[,]'), '\baarch64\b', 'arm64')
} elsif $architecture {
$_architecture = regsubst($architecture, '\baarch64\b', 'arm64')
} else {
$_architecture = $architecture
$_architecture = undef
}
case $ensure {
'present': {
Expand All @@ -341,7 +355,7 @@
'uris' => $_location,
'suites' => $_release,
'components' => $_repos,
'types' => $types,
'types' => $_types,
'comment' => $comment,
'enabled' => $enabled ? { true => 'yes', false => 'no' },
'architectures' => $_architecture,
Expand Down
71 changes: 71 additions & 0 deletions spec/defines/source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,77 @@
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Trusted: yes}) }
end

context 'with include' do
let :params do
super().merge(
{
location: ['http://debian.mirror.iweb.ca/debian/'],
repos: ['main'],
include: { 'src' => true },
},
)
end

it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{^Types: deb deb-src$}) }
end

context 'with include and types' do
let :params do
super().merge(
{
location: ['http://debian.mirror.iweb.ca/debian/'],
repos: ['main'],
include: { 'src' => true },
types: ['deb'],
},
)
end

it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{^Types: deb$}) }
end

context 'with apt::include_defaults' do
let(:pre_condition) { 'class { "apt": include_defaults => { "deb" => false, "src" => true } }' }
let :params do
super().merge(
{
location: ['http://debian.mirror.iweb.ca/debian/'],
repos: ['main'],
},
)
end

it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{^Types: deb-src$}) }
end

context 'with aarch64 architecture' do
let :params do
super().merge(
{
location: ['http://debian.mirror.iweb.ca/debian/'],
repos: ['main'],
architecture: ['amd64', 'aarch64'],
},
)
end

it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{^Architectures: amd64 arm64$}) }
end

context 'with aarch64 architecture as a string' do
let :params do
super().merge(
{
location: ['http://debian.mirror.iweb.ca/debian/'],
repos: ['main'],
architecture: 'aarch64,i386',
},
)
end

it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{^Architectures: arm64 i386$}) }
end

context '.list backwards compatibility' do
let :params do
super().merge(
Expand Down
Loading