diff --git a/kiwi.yml b/kiwi.yml index f5f71400..ddfda812 100644 --- a/kiwi.yml +++ b/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 diff --git a/kiwi/runtime_checker.py b/kiwi/runtime_checker.py index 83a08e61..2ce5f6da 100644 --- a/kiwi/runtime_checker.py +++ b/kiwi/runtime_checker.py @@ -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 element to be specified as part diff --git a/kiwi/tasks/base.py b/kiwi/tasks/base.py index 2492f723..e0088d55 100644 --- a/kiwi/tasks/base.py +++ b/kiwi/tasks/base.py @@ -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': [], diff --git a/test/unit/runtime_checker_test.py b/test/unit/runtime_checker_test.py index f7d5b1ee..da3f3d95 100644 --- a/test/unit/runtime_checker_test.py +++ b/test/unit/runtime_checker_test.py @@ -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' diff --git a/test/unit/tasks/system_build_test.py b/test/unit/tasks/system_build_test.py index 8baa1adf..125da22b 100644 --- a/test/unit/tasks/system_build_test.py +++ b/test/unit/tasks/system_build_test.py @@ -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() diff --git a/test/unit/tasks/system_prepare_test.py b/test/unit/tasks/system_prepare_test.py index 1251edaf..76ef271c 100644 --- a/test/unit/tasks/system_prepare_test.py +++ b/test/unit/tasks/system_prepare_test.py @@ -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()