Add check_checkmedia_used_with_msdos_table
Add check_checkmedia_used_with_msdos_table runtime check to check if the used partition table type is compatible with the selected checkmedia/tagmedia tool. So far only plain MBR tables are supported bei checkmedia. This Fixes #2722
This commit is contained in:
parent
8beae9f913
commit
e5b14c8953
3
kiwi.yml
3
kiwi.yml
@ -128,6 +128,9 @@
|
||||
# # verify mediacheck is installed for ISO images that requests it
|
||||
# - check_mediacheck_installed
|
||||
|
||||
# # verify that checkmedia/tagmedia is used with an MBR(msdos) partition table
|
||||
# - check_checkmedia_used_with_msdos_table
|
||||
|
||||
# # verify dracut-kiwi-live is installed for ISO images
|
||||
# - check_dracut_module_for_live_iso_in_package_list
|
||||
|
||||
|
||||
@ -932,6 +932,29 @@ class RuntimeChecker:
|
||||
message_tool_not_found.format(name=tool)
|
||||
)
|
||||
|
||||
def check_checkmedia_used_with_msdos_table(self) -> None:
|
||||
"""
|
||||
The checkmedia/tagmedia tools only supports plain
|
||||
MBR partition tables.
|
||||
"""
|
||||
message = dedent('''\n
|
||||
ISO media tag tool tagmedia does not support {table} partition tables
|
||||
|
||||
The attribute 'mediacheck' is set to 'true' and the selected
|
||||
media tag tool only supports plain MBR (msdos) partition tables.
|
||||
Attributes influencing the partition table type are
|
||||
firmware, efiparttable and targettype. Please check your
|
||||
image description for the setup of these attributes.
|
||||
''')
|
||||
if self.xml_state.build_type.get_mediacheck() is True:
|
||||
media_tagger = RuntimeConfig().get_iso_media_tag_tool()
|
||||
firmware = FirmWare(self.xml_state)
|
||||
table_type = firmware.get_partition_table_type()
|
||||
if media_tagger == 'checkmedia' and table_type != 'msdos':
|
||||
raise KiwiRuntimeError(
|
||||
message.format(tool=media_tagger, table=table_type)
|
||||
)
|
||||
|
||||
def check_image_version_provided(self) -> None:
|
||||
"""
|
||||
Kiwi requires a <version> element to be specified as part
|
||||
|
||||
@ -82,6 +82,7 @@ class CliTask:
|
||||
'check_swap_name_used_with_lvm': [],
|
||||
'check_xen_uniquely_setup_as_server_or_guest': [],
|
||||
'check_mediacheck_installed': [],
|
||||
'check_checkmedia_used_with_msdos_table': [],
|
||||
'check_dracut_module_for_live_iso_in_package_list': [],
|
||||
'check_dracut_module_for_disk_overlay_in_package_list': [],
|
||||
'check_dracut_module_for_disk_oem_in_package_list': [],
|
||||
|
||||
@ -378,6 +378,29 @@ class TestRuntimeChecker:
|
||||
|
||||
assert f"Required tool {tool_binary} not found in caller environment" in str(rt_err_ctx.value)
|
||||
|
||||
@patch('kiwi.runtime_checker.Path.which')
|
||||
@patch('kiwi.runtime_checker.RuntimeConfig')
|
||||
@patch('kiwi.runtime_checker.FirmWare')
|
||||
def test_check_checkmedia_used_with_msdos_table(
|
||||
self, mock_FirmWare, mock_RuntimeConfig, mock_which
|
||||
):
|
||||
firmware = Mock()
|
||||
firmware.get_partition_table_type.return_value = 'gpt'
|
||||
mock_FirmWare.return_value = firmware
|
||||
runtime_config = Mock()
|
||||
runtime_config.get_iso_media_tag_tool.return_value = 'checkmedia'
|
||||
mock_RuntimeConfig.return_value = runtime_config
|
||||
mock_which.return_value = False
|
||||
xml_state = XMLState(
|
||||
self.description.load(), ['vmxFlavour'], 'iso'
|
||||
)
|
||||
runtime_checker = RuntimeChecker(xml_state)
|
||||
with raises(KiwiRuntimeError) as runtime_context:
|
||||
runtime_checker.check_checkmedia_used_with_msdos_table()
|
||||
|
||||
assert 'ISO media tag tool tagmedia does not support gpt' in \
|
||||
format(runtime_context)
|
||||
|
||||
def test_check_dracut_module_for_live_iso_in_package_list(self):
|
||||
xml_state = XMLState(
|
||||
self.description.load(), ['vmxFlavour'], 'iso'
|
||||
|
||||
@ -147,6 +147,8 @@ class TestSystemBuildTask:
|
||||
)
|
||||
self.runtime_checker.\
|
||||
check_mediacheck_installed.assert_called_once_with()
|
||||
self.runtime_checker.\
|
||||
check_checkmedia_used_with_msdos_table.assert_called_once_with()
|
||||
self.runtime_checker.\
|
||||
check_dracut_module_for_live_iso_in_package_list.\
|
||||
assert_called_once_with()
|
||||
|
||||
@ -133,6 +133,8 @@ class TestSystemPrepareTask:
|
||||
)
|
||||
self.runtime_checker.\
|
||||
check_mediacheck_installed.assert_called_once_with()
|
||||
self.runtime_checker.\
|
||||
check_checkmedia_used_with_msdos_table.assert_called_once_with()
|
||||
self.runtime_checker.\
|
||||
check_dracut_module_for_live_iso_in_package_list.\
|
||||
assert_called_once_with()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user