Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self._load_boot_image_instance(), self.custom_args
)
if self.install_iso or self.install_stick:
log.info('Creating hybrid ISO installation image')
install_image.create_install_iso()
result_instance.add(
key='installation_image',
filename=install_image.isoname,
use_for_bundle=True,
compress=False,
shasum=True
)
if self.install_pxe:
log.info('Creating PXE installation archive')
install_image.create_install_pxe_archive()
result_instance.add(
key='installation_pxe_archive',
filename=install_image.pxename,
use_for_bundle=True,
compress=False,
shasum=True
)
return result_instance
def _write_crypttab_to_system_image(self):
if self.luks:
log.info('Creating etc/crypttab')
self.luks_root.create_crypttab(
self.root_dir + '/etc/crypttab'
)
def __del__(self):
if self.storage_provider.is_loop() and self.is_mapped:
log.info('Cleaning up %s instance', type(self).__name__)
try:
Command.run(
['kpartx', '-s', '-d', self.storage_provider.get_device()]
)
except Exception:
log.warning(
'cleanup of partition device maps failed, %s still busy',
self.storage_provider.get_device()
)
def create_disk_format(self, result_instance):
"""
Create a bootable disk format from a previously
created raw disk image
"""
if self.image_format:
log.info('Creating %s Disk Format', self.image_format)
disk_format = DiskFormat(
self.image_format, self.xml_state,
self.root_dir, self.target_dir
)
disk_format.create_image_format()
disk_format.store_to_result(result_instance)
return result_instance
def _write_recovery_metadata_to_boot_image(self):
if os.path.exists(self.root_dir + '/recovery.partition.size'):
log.info('Copying recovery metadata to boot image')
Command.run(
[
'cp', self.root_dir + '/recovery.partition.size',
self.boot_image.boot_root_directory
]
def install(self):
"""
install bootloader on self.device
"""
log.info('Installing grub2 on disk %s', self.device)
if not self.root_mount.device == self.boot_mount.device:
self.root_mount.mount()
self.boot_mount.mount()
module_directory = self.root_mount.mountpoint \
+ self.modules_dir
boot_directory = self.boot_mount.mountpoint
else:
self.root_mount.mount()
module_directory = self.root_mount.mountpoint \
+ self.modules_dir
boot_directory = self.root_mount.mountpoint \
+ '/boot'
Command.run(
['grub2-install'] + self.install_arguments + [
def _build_boot_filesystems(self, device_map):
if 'efi' in device_map:
log.info(
'Creating EFI(fat16) filesystem on %s',
device_map['efi'].get_device()
)
filesystem = FileSystem(
'fat16', device_map['efi'], self.root_dir + '/boot/efi/'
)
filesystem.create_on_device(
label=self.disk_setup.get_efi_label()
)
self.system_efi = filesystem
if 'boot' in device_map:
boot_filesystem = self.requested_boot_filesystem
if not boot_filesystem:
boot_filesystem = self.requested_filesystem
boot_directory = self.root_dir + '/boot/'
# create second stage metadata to system image
self._copy_first_boot_files_to_system_image()
self._write_bootloader_config_to_system_image(device_map)
self.mbrid.write_to_disk(
self.disk.storage_provider
)
# set SELinux file security contexts if context exists
self._setup_selinux_file_contexts()
# syncing system data to disk image
log.info('Syncing system to image')
if self.system_efi:
log.info('--> Syncing EFI boot data to EFI partition')
self.system_efi.sync_data()
if self.system_boot:
log.info('--> Syncing boot data at extra partition')
self.system_boot.sync_data(
self._get_exclude_list_for_boot_data_sync()
)
log.info('--> Syncing root filesystem data')
if self.root_filesystem_is_overlay:
squashed_root_file = NamedTemporaryFile()
squashed_root = FileSystemSquashFs(
device_provider=None, root_dir=self.root_dir
)
squashed_root.create_on_file(
filename=squashed_root_file.name,
def _write_generic_fstab_to_system_image(self, device_map):
log.info('Creating generic system etc/fstab')
self._write_generic_fstab(device_map, self.system_setup)