Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _target_file_for(self, suffix):
return ''.join(
[
self.target_dir, '/',
self.xml_state.xml_data.get_name(),
'.' + Defaults.get_platform_name(),
'-' + self.xml_state.get_image_version(),
'.', suffix
]
def _create_bios_image(self, mbrid=None, lookup_path=None):
early_boot_script = os.path.normpath(
os.sep.join([self._get_grub2_boot_path(), 'earlyboot.cfg'])
)
self._create_early_boot_script_for_mbrid_search(
early_boot_script, mbrid
)
Command.run(
[
self._get_grub2_mkimage_tool() or 'grub2-mkimage',
'-O', Defaults.get_bios_module_directory_name(),
'-o', self._get_bios_image_name(lookup_path),
'-c', early_boot_script,
'-p', self.get_boot_path() + '/' + self.boot_directory_name,
'-d', self._get_bios_modules_path(lookup_path)
] + Defaults.get_grub_bios_modules(multiboot=self.xen_guest)
)
:return: partition table name
:rtype: str
"""
if 's390' in self.arch:
if self.zipl_target_type and 'LDL' in self.zipl_target_type:
return 'dasd'
elif self.zipl_target_type and 'CDL' in self.zipl_target_type:
return 'dasd'
else:
return 'msdos'
elif 'ppc64' in self.arch:
return 'gpt'
elif self.efi_mode():
default_efi_table = Defaults.get_default_efi_partition_table_type()
return self.efi_partition_table or default_efi_table
else:
return 'msdos'
if not os.path.exists(self.root_dir):
raise KiwiFileSystemSyncError(
'given root directory %s does not exist' % self.root_dir
)
self.filesystem_mount = MountManager(
device=self.device_provider.get_device()
)
self.filesystem_mount.mount(
self.custom_args['mount_options']
)
self._apply_attributes()
data = DataSync(
self.root_dir, self.filesystem_mount.mountpoint
)
data.sync_data(
exclude=exclude, options=Defaults.get_sync_options()
)
['cp', script_file, script_target_file]
)
need_script_helper_functions = True
elif script.raise_if_not_exists:
raise KiwiImportDescriptionError(
'Specified script {0} does not exist'.format(
script_file
)
)
if need_script_helper_functions:
log.info('--> Importing script helper functions')
Command.run(
[
'cp',
Defaults.get_common_functions_file(),
self.root_dir + '/.kconfig'
]
def _type_complex_to_profile(self):
# kiwi_xendomain
# kiwi_install_volid
if self.xml_state.is_xen_server():
self.dot_profile['kiwi_xendomain'] = 'dom0'
if 'oem' in self.xml_state.get_build_type_name():
install_volid = self.xml_state.build_type.get_volid() or \
Defaults.get_install_volume_id()
self.dot_profile['kiwi_install_volid'] = install_volid
def _operate_on_file(self):
default_provider = DeviceProvider()
filesystem = FileSystem.new(
self.requested_filesystem, default_provider,
self.root_dir, self.filesystem_custom_parameters
)
filesystem.create_on_file(
self.filename, self.label,
Defaults.get_exclude_list_for_root_data_sync()
)
def get_xsl_stylesheet_file():
"""
Provides the file path to the KIWI XSLT style sheets
:return: file path
:rtype: str
"""
return Defaults.project_file('xsl/master.xsl')
def __init__(self, source_dir):
self.arch = Defaults.get_platform_name()
self.source_dir = source_dir
self.boot_path = Defaults.get_iso_boot_path()
self.iso_parameters = []
self.iso_loaders = []
# create initrd
self.boot_image_task.create_initrd()
# create append information
# this information helps to configure the deployment infrastructure
if self.filesystem and self.filesystem.root_uuid \
and self.initrd_system == 'dracut':
cmdline = 'root=UUID={}'.format(self.filesystem.root_uuid)
if self.custom_cmdline:
cmdline += ' {}'.format(self.custom_cmdline)
with open(self.append_file, 'w') as append:
append.write(cmdline)
# put results into a tarball
if not self.xz_options:
self.xz_options = Defaults.get_xz_compression_options()
kis_tarball_files = [
self.kernel_filename,
os.path.basename(self.boot_image_task.initrd_filename),
os.path.basename(self.checksum_name),
]
if self.image:
kis_tarball_files.append(os.path.basename(self.image))
if self.filesystem and self.filesystem.root_uuid \
and self.initrd_system == 'dracut':
kis_tarball_files.append(os.path.basename(self.append_file))
kis_tarball = ArchiveTar(
self.archive_name,