Added --ignore-repos for build and prepare tasks

The option allows to ignore all repos configured in the
XML description. This allows to specify a complete set
of repositories via the commandline
This commit is contained in:
Marcus Schäfer 2016-08-17 16:26:35 +02:00
parent aa9c542024
commit 08bbe74abc
No known key found for this signature in database
GPG Key ID: AD11DD02B44996EF
7 changed files with 42 additions and 0 deletions

View File

@ -18,6 +18,7 @@
"""
usage: kiwi system build -h | --help
kiwi system build --description=<directory> --target-dir=<directory>
[--ignore-repos]
[--set-repo=<source,type,alias,priority>]
[--add-repo=<source,type,alias,priority>...]
[--obs-repo-internal]
@ -42,6 +43,8 @@ options:
--description=<directory>
the description must be a directory containing a kiwi XML
description and optional metadata files
--ignore-repos
ignore all repos from the XML configuration
--obs-repo-internal
when using obs:// repos resolve them using the SUSE internal
buildservice. This only works if access to SUSE's internal
@ -103,6 +106,9 @@ class SystemBuildTask(CliTask):
self.command_args['--target-dir']
)
if self.command_args['--ignore-repos']:
self.xml_state.delete_repository_sections()
if self.command_args['--set-repo']:
(repo_source, repo_type, repo_alias, repo_prio) = \
self.quadruple_token(self.command_args['--set-repo'])

View File

@ -19,6 +19,7 @@
usage: kiwi system prepare -h | --help
kiwi system prepare --description=<directory> --root=<directory>
[--allow-existing-root]
[--ignore-repos]
[--set-repo=<source,type,alias,priority>]
[--add-repo=<source,type,alias,priority>...]
[--obs-repo-internal]
@ -46,6 +47,8 @@ options:
--description=<directory>
the description must be a directory containing a kiwi XML
description and optional metadata files
--ignore-repos
ignore all repos from the XML configuration
--obs-repo-internal
when using obs:// repos resolve them using the SUSE internal
buildservice. This only works if access to SUSE's internal
@ -96,6 +99,9 @@ class SystemPrepareTask(CliTask):
self.command_args['--root']
)
if self.command_args['--ignore-repos']:
self.xml_state.delete_repository_sections()
if self.command_args['--set-repo']:
(repo_source, repo_type, repo_alias, repo_prio) = \
self.quadruple_token(self.command_args['--set-repo'])

View File

@ -781,6 +781,12 @@ class XMLState(object):
self.xml_data.get_repository()
)
def delete_repository_sections(self):
"""
Delete all repository sections matching configured profiles
"""
self.xml_data.set_repository([])
def translate_obs_to_ibs_repositories(self):
"""
Change obs:// repotype to ibs:// type

View File

@ -30,6 +30,7 @@ class TestCli(object):
'--allow-existing-root': False,
'--description': 'description',
'--help': False,
'--ignore-repos': False,
'--obs-repo-internal': False,
'--root': 'directory',
'--set-repo': None,

View File

@ -72,6 +72,7 @@ class TestSystemBuildTask(object):
self.task.command_args['--add-repo'] = []
self.task.command_args['--add-package'] = []
self.task.command_args['--delete-package'] = []
self.task.command_args['--ignore-repos'] = False
@patch('kiwi.logger.Logger.set_logfile')
def test_process_system_build(self, mock_log):
@ -185,3 +186,13 @@ class TestSystemBuildTask(object):
self.task.manual.show.assert_called_once_with(
'kiwi::system::build'
)
@patch('kiwi.xml_state.XMLState.delete_repository_sections')
@patch('kiwi.logger.Logger.set_logfile')
def test_process_system_prepare_ignore_repos(
self, mock_log, mock_delete_repos
):
self._init_command_args()
self.task.command_args['--ignore-repos'] = True
self.task.process()
mock_delete_repos.assert_called_once_with()

View File

@ -61,6 +61,7 @@ class TestSystemPrepareTask(object):
self.task.command_args['--obs-repo-internal'] = False
self.task.command_args['--add-package'] = []
self.task.command_args['--delete-package'] = []
self.task.command_args['--ignore-repos'] = False
def test_process_system_prepare(self):
self._init_command_args()
@ -156,3 +157,10 @@ class TestSystemPrepareTask(object):
self.task.manual.show.assert_called_once_with(
'kiwi::system::prepare'
)
@patch('kiwi.xml_state.XMLState.delete_repository_sections')
def test_process_system_prepare_delete_repos(self, mock_delete_repos):
self._init_command_args()
self.task.command_args['--ignore-repos'] = True
self.task.process()
mock_delete_repos.assert_called_once_with()

View File

@ -433,3 +433,7 @@ class TestXMLState(object):
):
mock_boot.return_value = 'invalid'
self.state.get_distribution_name_from_boot_attribute()
def test_delete_repository_sections(self):
self.state.delete_repository_sections()
assert self.state.get_repository_sections() == []