Skip to content

Commit ebe5ee2

Browse files
jps-helpjamesps-ebi
authored andcommitted
Add forward-compatibility with deb822
Allow array values for certain parameters to allow easy switching between .list and .sources formats.
1 parent abb91cb commit ebe5ee2

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

manifests/source.pp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,23 @@
116116
# Specifies whether to check if the package release date is valid.
117117
#
118118
define apt::source (
119-
Enum['list', 'sources'] $source_format = 'list',
119+
Enum['list', 'sources'] $source_format = 'list',
120120
Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'],
121-
Optional[String] $location = undef,
121+
Optional[Variant[String, Array[String]]] $location = undef,
122122
Optional[Array[String]] $uris = undef, # deb822
123123
Boolean $enabled = true, # deb822
124124
String $comment = $name,
125125
String $ensure = present,
126-
Optional[String] $release = undef,
126+
Optional[Variant[String, Array[String]]] $release = undef,
127127
Optional[Array[String]] $suites = undef, # deb822
128-
String $repos = 'main',
128+
Variant[String, Array[String]] $repos = 'main',
129129
Optional[Array[String]] $components = undef, # deb822
130130
Variant[Hash] $include = {},
131131
Optional[Variant[String, Hash]] $key = undef,
132132
Optional[Stdlib::AbsolutePath] $keyring = undef,
133133
Optional[Variant[Stdlib::AbsolutePath,Array[String]]] $signed_by = undef, # deb822
134134
Optional[Variant[Hash, Numeric, String]] $pin = undef,
135-
Optional[String] $architecture = undef,
135+
Optional[Variant[String, Array[String]]] $architecture = undef,
136136
Optional[Array[String]] $architectures = undef, # deb822
137137
Optional[Boolean] $allow_unsigned = undef,
138138
Optional[Boolean] $repo_trusted = undef, # deb822
@@ -156,23 +156,40 @@
156156
}
157157
} else {
158158
$_release = $release
159+
# If the release is given as an array, use the first element only
160+
if (type($_release) =~ Array) {
161+
warning("Parameter, 'release', must be a string for 'list' format. Using the first array element instead.")
162+
$_release = $_release[0]
163+
}
164+
}
165+
166+
if (type($repos =~ Array)) {
167+
$_repos = join($repos, ' ')
168+
}
169+
else {
170+
$_repos = $repos
159171
}
160172

161173
if $release =~ Pattern[/\/$/] {
162174
$_components = $_release
163175
} else {
164-
$_components = "${_release} ${repos}"
176+
$_components = "${_release} ${_repos}"
165177
}
166178

167179
if $ensure == 'present' {
168180
if ! $location {
169181
fail('cannot create a source entry without specifying a location')
170182
}
171-
elsif ($apt::proxy['https_acng']) and ($location =~ /(?i:^https:\/\/)/) {
172-
$_location = regsubst($location, 'https://','http://HTTPS///')
173-
}
174183
else {
175184
$_location = $location
185+
# If the location is given as an array, use the first element only
186+
if (type($_location) =~ Array) {
187+
warning("Parameter, 'location', must be a string for 'list' format. Using the first array element instead.")
188+
$_location = $_location[0]
189+
}
190+
if ($apt::proxy['https_acng']) and ($_location =~ /(?i:^https:\/\/)/) {
191+
$_location = regsubst($_location, 'https://','http://HTTPS///')
192+
}
176193
}
177194
} else {
178195
$_location = undef
@@ -254,6 +271,9 @@
254271

255272
if $architecture {
256273
$_architecture = regsubst($architecture, '\baarch64\b', 'arm64')
274+
if (type($_architecture) =~ Array) {
275+
$_architecture = join($_architecture, ',')
276+
}
257277
} else {
258278
$_architecture = undef
259279
}

0 commit comments

Comments
 (0)