Skip to content

Commit 1a27b45

Browse files
authored
Merge pull request #2755 from OSInside/allow_sourcetype_on_commandline
Support sourcetype setting on the commandline
2 parents 807aa36 + 48d3ccf commit 1a27b45

File tree

10 files changed

+93
-58
lines changed

10 files changed

+93
-58
lines changed

doc/source/commands/system_build.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ SYNOPSIS
1818
[--clear-cache]
1919
[--ignore-repos]
2020
[--ignore-repos-used-for-build]
21-
[--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>]
21+
[--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>]
2222
[--set-repo-credentials=<user:pass_or_filename>]
23-
[--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>...]
23+
[--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>...]
2424
[--add-repo-credentials=<user:pass_or_filename>...]
2525
[--add-package=<name>...]
2626
[--add-bootstrap-package=<name>...]
@@ -66,7 +66,7 @@ OPTIONS
6666
Specify package to add (install). The option can be specified
6767
multiple times.
6868

69-
--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>
69+
--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>
7070

7171
Add a new repository to the existing repository setup in the XML
7272
description. This option can be specified multiple times.
@@ -120,7 +120,7 @@ OPTIONS
120120
Works the same way as `--ignore-repos`, except that repository configuration
121121
with the imageonly attribute set to **true** is not ignored.
122122

123-
--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>
123+
--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>
124124

125125
Overwrite the first repository entry in the XML description with the
126126
provided information:
@@ -178,6 +178,15 @@ OPTIONS
178178
Set to either **true** or **false** to indicate if the repository
179179
should validate the repository signature.
180180

181+
- **repo_sourcetype**
182+
183+
Specify the source type of the repository path. Supported values
184+
are baseurl, metalink or mirrorlist. With baseurl the source
185+
path is interpreted as simple URI. If metalink is set the source
186+
path is resolved as metalink URI and if mirrorlist is set the
187+
source path is resolved as a mirrorlist file. If not specified,
188+
baseurl is the default
189+
181190
--set-repo-credentials=<user:pass_or_filename>
182191

183192
For **uri://user:pass@location** type repositories, set the user and

doc/source/commands/system_prepare.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ SYNOPSIS
1616
[--clear-cache]
1717
[--ignore-repos]
1818
[--ignore-repos-used-for-build]
19-
[--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>]
19+
[--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>]
2020
[--set-repo-credentials=<user:pass_or_filename>]
21-
[--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>...]
21+
[--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>...]
2222
[--add-repo-credentials=<user:pass_or_filename>...]
2323
[--add-package=<name>...]
2424
[--add-bootstrap-package=<name>...]
@@ -66,7 +66,7 @@ OPTIONS
6666
Specify a package to add (install). The option can be specified
6767
multiple times.
6868

69-
--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>
69+
--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>
7070

7171
Add a new repository to the existing repository setup in the XML
7272
description. This option can be specified multiple times.
@@ -121,7 +121,7 @@ OPTIONS
121121

122122
Path to the new root system.
123123

124-
--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>
124+
--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>
125125

126126
Overwrite the first repository entry in the XML description with the
127127
provided information:
@@ -179,6 +179,15 @@ OPTIONS
179179
Set to either **true** or **false** to specify if the repository
180180
must validate the repository signature.
181181

182+
- **repo_sourcetype**
183+
184+
Specify the source type of the repository path. Supported values
185+
are baseurl, metalink or mirrorlist. With baseurl the source
186+
path is interpreted as simple URI. If metalink is set the source
187+
path is resolved as metalink URI and if mirrorlist is set the
188+
source path is resolved as a mirrorlist file. If not specified,
189+
baseurl is the default
190+
182191
--set-repo-credentials=<user:pass_or_filename>
183192

184193
For **uri://user:pass@location** type repositories, set the user and

kiwi/tasks/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,12 @@ def quadruple_token(
222222
"""
223223
return self._ntuple_token(option, 4)
224224

225-
def tentuple_token(
225+
def eleventuple_token(
226226
self, option: str
227227
) -> List[Union[bool, str, List[str], None]]:
228228
"""
229229
Helper method for commandline options of the
230-
form --option a,b,c,d,e,f,g,h,i,j
230+
form --option a,b,c,d,e,f,g,h,i,j,k
231231
232232
Make sure to provide a common result for option values which
233233
separates the information in a comma separated list of values
@@ -238,7 +238,7 @@ def tentuple_token(
238238
239239
:rtype: list
240240
"""
241-
return self._ntuple_token(option, 10)
241+
return self._ntuple_token(option, 11)
242242

243243
def attr_token(
244244
self, option: str

kiwi/tasks/system_build.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
[--clear-cache]
2323
[--ignore-repos]
2424
[--ignore-repos-used-for-build]
25-
[--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>]
25+
[--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>]
2626
[--set-repo-credentials=<user:pass_or_filename>]
27-
[--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>...]
27+
[--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>...]
2828
[--add-repo-credentials=<user:pass_or_filename>...]
2929
[--add-package=<name>...]
3030
[--add-bootstrap-package=<name>...]
@@ -54,8 +54,8 @@
5454
priority, imageinclude(true|false), package_gpgcheck(true|false),
5555
list of signing_keys enclosed in curly brackets delimited by a colon,
5656
component list for debian based repos as string delimited by a space,
57-
main distribution name for debian based repos and
58-
repo_gpgcheck(true|false)
57+
main distribution name for debian based repos,
58+
repo_gpgcheck(true|false) and repo_sourcetype(metalink|baseurl|mirrorlist)
5959
--add-repo-credentials=<user:pass_or_filename>
6060
for uri://user:pass@location type repositories, set the user and
6161
password connected with an add-repo specification. The first
@@ -94,13 +94,13 @@
9494
add a container label in the container configuration metadata. It
9595
overwrites the label with the provided key-value pair in case it was
9696
already defined in the XML description
97-
--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>
97+
--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>
9898
overwrite the first XML listed repository source, type, alias,
9999
priority, imageinclude(true|false), package_gpgcheck(true|false),
100100
list of signing_keys enclosed in curly brackets delimited by a colon,
101101
component list for debian based repos as string delimited by a space,
102-
main distribution name for debian based repos and
103-
repo_gpgcheck(true|false)
102+
main distribution name for debian based repos,
103+
repo_gpgcheck(true|false) and repo_sourcetype(metalink|baseurl|mirrorlist)
104104
--set-repo-credentials=<user:pass_or_filename>
105105
for uri://user:pass@location type repositories, set the user and
106106
password connected to the set-repo specification. If the provided
@@ -366,7 +366,7 @@ def _help(self):
366366
return self.manual
367367

368368
def _get_repo_parameters(self, tokens, credentials):
369-
parameters = self.tentuple_token(tokens)
369+
parameters = self.eleventuple_token(tokens)
370370
signing_keys_index = 6
371371
repo_source_index = 0
372372
if not parameters[signing_keys_index]:

kiwi/tasks/system_prepare.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
[--clear-cache]
2323
[--ignore-repos]
2424
[--ignore-repos-used-for-build]
25-
[--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>]
25+
[--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>]
2626
[--set-repo-credentials=<user:pass_or_filename>]
27-
[--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>...]
27+
[--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>...]
2828
[--add-repo-credentials=<user:pass_or_filename>...]
2929
[--add-package=<name>...]
3030
[--add-bootstrap-package=<name>...]
@@ -48,13 +48,13 @@
4848
install the given package name as part of the early bootstrap process
4949
--add-package=<name>
5050
install the given package name
51-
--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>
51+
--add-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>
5252
add repository with given source, type, alias,
5353
priority, imageinclude(true|false), package_gpgcheck(true|false),
5454
list of signing_keys enclosed in curly brackets delimited by a colon,
5555
component list for debian based repos as string delimited by a space,
56-
main distribution name for debian based repos and
57-
repo_gpgcheck(true|false)
56+
main distribution name for debian based repos,
57+
repo_gpgcheck(true|false) and repo_sourcetype(metalink|baseurl|mirrorlist)
5858
--add-repo-credentials=<user:pass_or_filename>
5959
for uri://user:pass@location type repositories, set the user and
6060
password connected with an add-repo specification. The first
@@ -94,13 +94,13 @@
9494
add a container label in the container configuration metadata. It
9595
overwrites the label with the provided key-value pair in case it was
9696
already defined in the XML description
97-
--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck>
97+
--set-repo=<source,type,alias,priority,imageinclude,package_gpgcheck,{signing_keys},components,distribution,repo_gpgcheck,repo_sourcetype>
9898
overwrite the first XML listed repository source, type, alias,
9999
priority, imageinclude(true|false), package_gpgcheck(true|false),
100100
list of signing_keys enclosed in curly brackets delimited by a colon,
101101
component list for debian based repos as string delimited by a space,
102-
main distribution name for debian based repos and
103-
repo_gpgcheck(true|false)
102+
main distribution name for debian based repos,
103+
repo_gpgcheck(true|false) and repo_sourcetype(metalink|baseurl|mirrorlist)
104104
--set-repo-credentials=<user:pass_or_filename>
105105
for uri://user:pass@location type repositories, set the user and
106106
password connected to the set-repo specification. If the provided
@@ -326,7 +326,7 @@ def _help(self):
326326
return self.manual
327327

328328
def _get_repo_parameters(self, tokens, credentials):
329-
parameters = self.tentuple_token(tokens)
329+
parameters = self.eleventuple_token(tokens)
330330
signing_keys_index = 6
331331
repo_source_index = 0
332332
if not parameters[signing_keys_index]:

kiwi/xml_state.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,8 @@ def set_repository(
23082308
repo_prio: str, repo_imageinclude: bool = False,
23092309
repo_package_gpgcheck: Optional[bool] = None,
23102310
repo_signing_keys: List[str] = [], components: str = None,
2311-
distribution: str = None, repo_gpgcheck: Optional[bool] = None
2311+
distribution: str = None, repo_gpgcheck: Optional[bool] = None,
2312+
repo_sourcetype: str = None
23122313
) -> None:
23132314
"""
23142315
Overwrite repository data of the first repository
@@ -2349,13 +2350,16 @@ def set_repository(
23492350
repository.set_distribution(distribution)
23502351
if repo_gpgcheck is not None:
23512352
repository.set_repository_gpgcheck(repo_gpgcheck)
2353+
if repo_sourcetype:
2354+
repository.set_sourcetype(repo_sourcetype)
23522355

23532356
def add_repository(
23542357
self, repo_source: str, repo_type: str, repo_alias: str = None,
23552358
repo_prio: str = '', repo_imageinclude: bool = False,
23562359
repo_package_gpgcheck: Optional[bool] = None,
23572360
repo_signing_keys: List[str] = [], components: str = None,
2358-
distribution: str = None, repo_gpgcheck: Optional[bool] = None
2361+
distribution: str = None, repo_gpgcheck: Optional[bool] = None,
2362+
repo_sourcetype: str = None
23592363
) -> None:
23602364
"""
23612365
Add a new repository section at the end of the list
@@ -2392,7 +2396,8 @@ def add_repository(
23922396
package_gpgcheck=repo_package_gpgcheck,
23932397
repository_gpgcheck=repo_gpgcheck,
23942398
components=components,
2395-
distribution=distribution
2399+
distribution=distribution,
2400+
sourcetype=repo_sourcetype
23962401
)
23972402
)
23982403

test/unit/tasks/base_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ def test_setup_custom_log_level_invalid(
148148
def test_quadruple_token(self):
149149
assert self.task.quadruple_token('a,b') == ['a', 'b', None, None]
150150

151-
def test_tentuple_token(self):
152-
assert self.task.tentuple_token(
153-
'a,b,,d,e,f,{1;2;3},x y z,jammy,false'
151+
def test_eleventuple_token(self):
152+
assert self.task.eleventuple_token(
153+
'a,b,,d,e,f,{1;2;3},x y z,jammy,false,metalink'
154154
) == [
155155
'a', 'b', '', 'd', 'e', 'f', ['1', '2', '3'], 'x y z',
156-
'jammy', False
156+
'jammy', False, 'metalink'
157157
]
158-
assert self.task.tentuple_token('a,b,,d,e,f,{1;2;3}') == [
158+
assert self.task.eleventuple_token('a,b,,d,e,f,{1;2;3}') == [
159159
'a', 'b', '', 'd', 'e', 'f', ['1', '2', '3'],
160-
None, None, None
160+
None, None, None, None
161161
]
162162

163163
def test_attr_token(self):

test/unit/tasks/system_build_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,22 +342,22 @@ def test_process_system_build_prepare_stage_set_repo(
342342
self.task.process()
343343
mock_set_repo.assert_called_once_with(
344344
'http://example.com', 'yast2', 'alias',
345-
None, None, None, [], None, None, None
345+
None, None, None, [], None, None, None, None
346346
)
347347
self.task.command_args['--set-repo-credentials'] = 'user:pass'
348348
mock_set_repo.reset_mock()
349349
self.task.process()
350350
mock_set_repo.assert_called_once_with(
351351
'http://user:[email protected]', 'yast2', 'alias',
352-
None, None, None, [], None, None, None
352+
None, None, None, [], None, None, None, None
353353
)
354354
self.task.command_args['--set-repo-credentials'] = '../data/credentials'
355355
mock_os_path_is_file.return_value = True
356356
mock_set_repo.reset_mock()
357357
self.task.process()
358358
mock_set_repo.assert_called_once_with(
359359
'http://user:[email protected]', 'yast2', 'alias',
360-
None, None, None, [], None, None, None
360+
None, None, None, [], None, None, None, None
361361
)
362362
mock_os_unlink.assert_called_once_with('../data/credentials')
363363

@@ -377,15 +377,15 @@ def test_process_system_build_prepare_stage_add_repo(
377377
assert mock_add_repo.call_args_list == [
378378
call(
379379
'http://example1.com', 'yast2', 'alias', '99',
380-
False, True, [], None, None, None
380+
False, True, [], None, None, None, None
381381
),
382382
call(
383383
'http://example2.com', 'yast2', 'alias', '99',
384-
False, True, [], None, None, None
384+
False, True, [], None, None, None, None
385385
),
386386
call(
387387
'http://example3.com', 'yast2', 'alias', '99',
388-
False, True, [], None, None, None
388+
False, True, [], None, None, None, None
389389
)
390390
]
391391
self.task.command_args['--add-repo-credentials'] = [
@@ -397,15 +397,15 @@ def test_process_system_build_prepare_stage_add_repo(
397397
assert mock_add_repo.call_args_list == [
398398
call(
399399
'http://user1:[email protected]', 'yast2', 'alias', '99',
400-
False, True, [], None, None, None
400+
False, True, [], None, None, None, None
401401
),
402402
call(
403403
'http://user2:[email protected]', 'yast2', 'alias', '99',
404-
False, True, [], None, None, None
404+
False, True, [], None, None, None, None
405405
),
406406
call(
407407
'http://example3.com', 'yast2', 'alias', '99',
408-
False, True, [], None, None, None
408+
False, True, [], None, None, None, None
409409
)
410410
]
411411

0 commit comments

Comments
 (0)