From eb39120ea14b48ca83838c3519eccf5d0a72c596 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Sat, 24 Aug 2024 07:05:52 -0400 Subject: [PATCH 1/2] kiwi/builder/live: Clean up leftover dracut configuration file The existence of this file breaks installers on live media that sync the full filesystem to disk and are not aware of this configuration before generating the target system initramfs. --- kiwi/builder/live.py | 2 ++ test/unit/builder/live_test.py | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/kiwi/builder/live.py b/kiwi/builder/live.py index 7ec4159ec14..6204cbeb483 100644 --- a/kiwi/builder/live.py +++ b/kiwi/builder/live.py @@ -190,6 +190,8 @@ def create(self) -> Result: config_file=self.root_dir + '/etc/dracut.conf.d/02-livecd.conf' ) self.boot_image.create_initrd(self.mbrid) + # Clean up leftover dracut config file (which can break installs) + os.unlink(self.root_dir + '/etc/dracut.conf.d/02-livecd.conf') if self.bootloader == 'systemd_boot': # make sure the initrd name follows the dracut # naming conventions diff --git a/test/unit/builder/live_test.py b/test/unit/builder/live_test.py index a8cce38dac1..a08a75cc394 100644 --- a/test/unit/builder/live_test.py +++ b/test/unit/builder/live_test.py @@ -152,10 +152,11 @@ def test_init_for_ix86_platform(self): @patch('kiwi.builder.live.FileSystem.new') @patch('kiwi.builder.live.SystemSize') @patch('kiwi.builder.live.Defaults.get_grub_boot_directory_name') + @patch('os.unlink') @patch('os.path.exists') @patch('os.chmod') def test_create_overlay_structure_boot_on_systemd_boot( - self, mock_chmod, mock_exists, mock_grub_dir, mock_size, + self, mock_chmod, mock_exists, mock_unlink, mock_grub_dir, mock_size, mock_filesystem, mock_isofs, mock_Iso, mock_tag, mock_shutil, mock_Temporary, mock_setup_media_loader_directory, mock_DeviceProvider, mock_Command_run, mock_LoopDevice, mock_create_boot_loader_config @@ -190,10 +191,11 @@ def test_create_overlay_structure_boot_on_systemd_boot( @patch('kiwi.builder.live.FileSystem.new') @patch('kiwi.builder.live.SystemSize') @patch('kiwi.builder.live.Defaults.get_grub_boot_directory_name') + @patch('os.unlink') @patch('os.path.exists') @patch('os.chmod') def test_create_overlay_structure_boot_on_grub( - self, mock_chmod, mock_exists, mock_grub_dir, mock_size, + self, mock_chmod, mock_exists, mock_unlink, mock_grub_dir, mock_size, mock_filesystem, mock_isofs, mock_Iso, mock_tag, mock_shutil, mock_Temporary, mock_setup_media_loader_directory, mock_DeviceProvider, mock_LoopDevice, mock_create_boot_loader_config, xml_filesystem @@ -204,6 +206,7 @@ def test_create_overlay_structure_boot_on_grub( loop_provider = Mock() mock_LoopDevice.return_value.__enter__.return_value = loop_provider mock_exists.return_value = True + mock_unlink.return_value = True mock_grub_dir.return_value = 'grub2' temp_squashfs = Mock() @@ -413,9 +416,10 @@ def side_effect(): @patch('kiwi.builder.live.IsoToolsBase.setup_media_loader_directory') @patch('kiwi.builder.live.Temporary') @patch('kiwi.builder.live.shutil') + @patch('os.unlink') def test_create_no_kernel_found( - self, mock_shutil, mock_Temporary, mock_setup_media_loader_directory, - mock_create_boot_loader_config + self, mock_unlink, mock_shutil, mock_Temporary, + mock_setup_media_loader_directory, mock_create_boot_loader_config ): self.firmware.bios_mode.return_value = False mock_Temporary.return_value.new_dir.return_value.name = 'tmpdir' @@ -427,9 +431,10 @@ def test_create_no_kernel_found( @patch('kiwi.builder.live.IsoToolsBase.setup_media_loader_directory') @patch('kiwi.builder.live.Temporary') @patch('kiwi.builder.live.shutil') + @patch('os.unlink') def test_create_no_hypervisor_found( - self, mock_shutil, mock_Temporary, mock_setup_media_loader_directory, - mock_create_boot_loader_config + self, mock_unlink, mock_shutil, mock_Temporary, + mock_setup_media_loader_directory, mock_create_boot_loader_config ): self.firmware.bios_mode.return_value = False mock_Temporary.return_value.new_dir.return_value.name = 'tmpdir' @@ -441,14 +446,16 @@ def test_create_no_hypervisor_found( @patch('kiwi.builder.live.IsoToolsBase.setup_media_loader_directory') @patch('kiwi.builder.live.Temporary') @patch('kiwi.builder.live.shutil') + @patch('os.unlink') @patch('os.path.exists') def test_create_no_initrd_found( - self, mock_exists, mock_shutil, mock_Temporary, + self, mock_exists, mock_unlink, mock_shutil, mock_Temporary, mock_setup_media_loader_directory, mock_create_boot_loader_config ): self.firmware.bios_mode.return_value = False mock_Temporary.return_value.new_dir.return_value.name = 'tmpdir' mock_exists.return_value = False + mock_unlink.return_value = True with raises(KiwiLiveBootImageError): self.live_image.create() From 13af4621e6b3231fa14645103037e3801fc29cfc Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Sat, 24 Aug 2024 07:13:18 -0400 Subject: [PATCH 2/2] kiwi/builder/live: Log the correct value for Application ID Since it is now possible to set a custom application ID, we want to see this when it is being used for the image. --- kiwi/builder/live.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kiwi/builder/live.py b/kiwi/builder/live.py index 6204cbeb483..9be04d0a14d 100644 --- a/kiwi/builder/live.py +++ b/kiwi/builder/live.py @@ -74,6 +74,8 @@ def __init__( Defaults.get_volume_id() self.mbrid = SystemIdentifier() self.mbrid.calculate_id() + self.application_id = self.xml_state.build_type.get_application_id() or \ + self.mbrid.get_id() self.publisher = xml_state.build_type.get_publisher() or \ Defaults.get_publisher() self.custom_args = custom_args @@ -131,7 +133,7 @@ def create(self) -> Result: # custom iso metadata log.info('Using following live ISO metadata:') - log.info('--> Application id: {0}'.format(self.mbrid.get_id())) + log.info('--> Application id: {0}'.format(self.application_id)) log.info('--> Publisher: {0}'.format(self.publisher)) log.info('--> Volume id: {0}'.format(self.volume_id)) custom_iso_args = { @@ -140,7 +142,7 @@ def create(self) -> Result: 'preparer': Defaults.get_preparer(), 'volume_id': self.volume_id, 'mbr_id': self.mbrid.get_id(), - 'application_id': self.xml_state.build_type.get_application_id(), + 'application_id': self.application_id, 'efi_mode': self.firmware.efi_mode(), 'legacy_bios_mode': self.firmware.legacy_bios_mode() }