Skip to content

Commit

Permalink
kiwi/builder/live: Clean up leftover dracut configuration file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Conan-Kudo committed Aug 24, 2024
1 parent d5bff98 commit eb39120
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions kiwi/builder/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 14 additions & 7 deletions test/unit/builder/live_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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()

0 comments on commit eb39120

Please sign in to comment.