kiwi Package

Submodules

kiwi.app Module

class kiwi.app.App[source]

Bases: object

Implements creation of task instances

Each task class implements a process method which is called when constructing an instance of App

kiwi.cli Module

class kiwi.cli.Cli[source]

Bases: object

Implements the main command line interface

An instance of the Cli class builds the entry point for the application and implements methods to load further command plugins which itself provides their own command line interface

get_command()[source]

Extract selected command name

Returns:

command name

Return type:

str

get_command_args()[source]

Extract argument dict for selected command

Returns:

Contains dictionary of command arguments

{
    '--command-option': 'value'
}

Return type:

dict

get_global_args()[source]

Extract argument dict for global arguments

Returns:

Contains dictionary of global arguments

{
    '--global-option': 'value'
}

Return type:

dict

get_servicename()[source]

Extract service name from argument parse result

Returns:

service name

Return type:

str

load_command()[source]

Loads task class plugin according to service and command name

Returns:

loaded task module

Return type:

object

show_and_exit_on_help_request()[source]

Execute man to show the selected manual page

kiwi.command Module

class kiwi.command.Command[source]

Bases: object

Implements command invocation

An instance of Command provides methods to invoke external commands in blocking and non blocking mode. Control of stdout and stderr is given to the caller

static call(command: List[str], custom_env: MutableMapping[str, str] | None = None) CommandCallT[source]

Execute a program and return an io file handle pair back. stdout and stderr are both on different channels. The caller must read from the output file handles in order to actually run the command. This can be done using the CommandIterator from command_process

Example:

process = Command.call(['ls', '-l'])
Parameters:
  • command (list) – command and arguments

  • custom_env (list) – custom os.environ

Returns:

Contains process results in command type

command(
    output='string', output_available=bool,
    error='string', error_available=bool,
    process=subprocess
)

Return type:

namedtuple

static run(command: List[str], custom_env: MutableMapping[str, str] | None = None, raise_on_error: bool = True, stderr_to_stdout: bool = False, raise_on_command_not_found: Literal[False] = False) CommandT[source]
static run(command: List[str], custom_env: MutableMapping[str, str] | None = None, raise_on_error: bool = True, stderr_to_stdout: bool = False, raise_on_command_not_found: bool = True) CommandT | None

Execute a program and block the caller. The return value is a CommandT namedtuple containing the stdout, stderr and return code information. Unless raise_on_error is set to False an exception is thrown if the command exits with an error code not equal to zero. If raise_on_command_not_found is False and the command is not found, then None is returned.

Example:

result = Command.run(['ls', '-l'])
Parameters:
  • command (list) – command and arguments

  • custom_env (dict) – custom os.environ

  • raise_on_error (bool) – control error behaviour

  • stderr_to_stdout (bool) – redirects stderr to stdout

Returns:

Contains call results in command type

CommandT(output='string', error='string', returncode=int)

Return type:

CommandT

class kiwi.command.CommandCallT(output, output_available, error, error_available, process)[source]

Bases: NamedTuple

error: IO[bytes]

Alias for field number 2

error_available: Callable[[], bool]

Alias for field number 3

output: IO[bytes]

Alias for field number 0

output_available: Callable[[], bool]

Alias for field number 1

process: Popen

Alias for field number 4

class kiwi.command.CommandT(output, error, returncode)[source]

Bases: NamedTuple

error: str

Alias for field number 1

output: str

Alias for field number 0

returncode: int

Alias for field number 2

kiwi.command_process Module

class kiwi.command_process.CommandIterator(command: CommandCallT)[source]

Bases: object

Implements an Iterator for Instances of Command

Parameters:

command (subprocess) – instance of subprocess

get_error_code() int[source]

Provide return value from processed command

Returns:

errorcode

Return type:

int

get_error_output()[source]

Provide data which was sent to the stderr channel

Returns:

stderr data

Return type:

str

get_pid() int[source]

Provide process ID of command while running

Returns:

pid

Return type:

int

kill() None[source]

Send kill signal SIGTERM to command process

class kiwi.command_process.CommandProcess(command: CommandCallT, log_topic='system')[source]

Bases: object

Implements processing of non blocking Command calls

Provides methods to iterate over non blocking instances of the Command class with and without progress information

Parameters:
  • command (subprocess) – instance of subprocess

  • log_topic (string) – topic string for logging

create_match_method(method)[source]

create a matcher function pointer which calls the given method as method(item_to_match, data) on dereference

Parameters:

method (function) – function reference

Returns:

function pointer

Return type:

object

poll()[source]

Iterate over process, raise on error and log output

poll_and_watch()[source]

Iterate over process don’t raise on error and log stdout and stderr

poll_show_progress(items_to_complete, match_method)[source]

Iterate over process and show progress in percent raise on error and log output

Parameters:
  • items_to_complete (list) – all items

  • match_method (function) – method matching item

returncode()[source]

kiwi.defaults Module

class kiwi.defaults.Defaults[source]

Bases: object

Implements default values

Provides static methods for default values and state information

get(key)[source]

Implements get method for profile elements

Parameters:

key (string) – profile keyname

Returns:

key value

Return type:

str

static get_archive_image_types()[source]

Provides list of supported archive image types

Returns:

archive names

Return type:

list

static get_bios_image_name()[source]

Provides bios core boot binary name

Returns:

name

Return type:

str

static get_bios_module_directory_name()[source]

Provides BIOS directory name which stores the pc binaries

Returns:

directory name

Return type:

str

static get_bls_loader_entries_dir() str[source]

Provide default loader entries directory for BLS loaders

Returns:

directory name

Return type:

str

static get_boot_image_description_path()[source]

Provides the path to find custom kiwi boot descriptions

Returns:

directory path

Return type:

str

static get_boot_image_strip_file()[source]

Provides the file path to bootloader strip metadata. This file contains information about the files and directories automatically striped out from the kiwi initrd

Returns:

file path

Return type:

str

static get_buildservice_env_name()[source]

Provides the base name of the environment file in a buildservice worker

Returns:

file basename

Return type:

str

static get_common_functions_file()[source]

Provides the file path to config functions metadata.

This file contains bash functions used for system configuration or in the boot code from the kiwi initrd

Returns:

file path

Return type:

str

static get_container_base_image_tag()[source]

Provides the tag used to identify base layers during the build of derived images.

Returns:

tag

Return type:

str

static get_container_compression()[source]

Provides default container compression

Returns:

True

Return type:

bool

static get_container_image_types()[source]

Provides list of supported container image types

Returns:

container names

Return type:

list

static get_custom_rpm_bootstrap_macro_name()[source]

Returns the rpm bootstrap macro file name created in the custom rpm macros path

Returns:

filename

Return type:

str

static get_custom_rpm_image_macro_name()[source]

Returns the rpm image macro file name created in the custom rpm macros path

Returns:

filename

Return type:

str

static get_custom_rpm_macros_path()[source]

Returns the custom macros directory for the rpm database.

Returns:

path name

Return type:

str

static get_default_boot_mbytes()[source]

Provides default boot partition size in mbytes

Returns:

mbsize value

Return type:

int

static get_default_boot_timeout_seconds()[source]

Provides default boot timeout in seconds

Returns:

seconds

Return type:

int

static get_default_bootloader()[source]

Return default bootloader name which is grub2

Returns:

bootloader name

Return type:

str

static get_default_container_created_by()[source]

Provides the default ‘created by’ history entry for containers.

Returns:

the specific kiwi version used for the build

Return type:

str

static get_default_container_name()[source]

Provides the default container name.

Returns:

name

Return type:

str

static get_default_container_subcommand()[source]

Provides the default container subcommand.

Returns:

command as a list of arguments

Return type:

list

static get_default_container_tag()[source]

Provides the default container tag.

Returns:

tag

Return type:

str

static get_default_disk_start_sector()[source]

Provides the default initial disk sector for the first disk partition.

Returns:

sector value

Return type:

int

static get_default_efi_boot_mbytes()[source]

Provides default EFI partition size in mbytes

Returns:

mbsize value

Return type:

int

static get_default_efi_partition_table_type()[source]

Provides the default partition table type for efi firmwares.

Returns:

partition table type name

Return type:

str

static get_default_firmware(arch)[source]

Provides default firmware for specified architecture

Parameters:

arch (string) – machine architecture name

Returns:

firmware name

Return type:

str

static get_default_inode_size()[source]

Provides default size of inodes in bytes. This is only relevant for inode based filesystems

Returns:

bytesize value

Return type:

int

static get_default_legacy_bios_mbytes()[source]

Provides default size of bios_grub partition in mbytes

Returns:

mbsize value

Return type:

int

static get_default_live_iso_root_filesystem()[source]

Provides default live iso root filesystem type

Returns:

filesystem name

Return type:

str

static get_default_live_iso_type()[source]

Provides default live iso union type

Returns:

live iso type

Return type:

str

static get_default_package_manager() str[source]

Returns the default package manager name if none is configured in the image description

Returns:

package manager name

Return type:

str

static get_default_packager_tool(package_manager)[source]

Provides the packager tool according to the package manager

Parameters:

package_manager (string) – package manger name

Returns:

packager tool binary name

Return type:

str

static get_default_prep_mbytes()[source]

Provides default size of prep partition in mbytes

Returns:

mbsize value

Return type:

int

static get_default_uri_type()[source]

Provides default URI type

Absolute path specifications used in the context of an URI will apply the specified default mime type

Returns:

URI mime type

Return type:

str

static get_default_video_mode()[source]

Uses auto mode for default video. See get_video_mode_map for details on the value depending which bootloader is used

Returns:

auto

Return type:

str

static get_default_volume_group_name()[source]

Provides default LVM volume group name

Returns:

name

Return type:

str

static get_discoverable_partition_ids() Dict[str, str][source]

Provides arch specific partition UUIDs as defined by the UAPI group

Returns:

partition UUIDs

Return type:

dict

static get_disk_format_types()[source]

Provides supported disk format types

Returns:

disk types

Return type:

list

static get_disk_image_types()[source]

Provides supported disk image types

Returns:

disk image type names

Return type:

list

static get_dracut_conf_name()[source]

Provides file path of dracut config file to be used with KIWI

Returns:

file path name

Return type:

str

static get_ec2_capable_firmware_names()[source]

Provides list of EC2 capable firmware names. These are those for which kiwi supports the creation of disk images bootable within the Amazon EC2 public cloud

Returns:

firmware names

Return type:

list

static get_efi_capable_firmware_names()[source]

Provides list of EFI capable firmware names. These are those for which kiwi supports the creation of an EFI bootable disk image

Returns:

firmware names

Return type:

list

static get_efi_image_name(arch)[source]

Provides architecture specific EFI boot binary name

Parameters:

arch (string) – machine architecture name

Returns:

name

Return type:

str

static get_efi_module_directory_name(arch)[source]

Provides architecture specific EFI directory name which stores the EFI binaries for the desired architecture.

Parameters:

arch (string) – machine architecture name

Returns:

directory name

Return type:

str

static get_efi_vendor_directory(efi_path)[source]

Provides EFI vendor directory if present

Looks up distribution specific EFI vendor directory

Parameters:

root_path (string) – path to efi mountpoint

Returns:

directory path or None

Return type:

str

static get_enclaves_image_types()[source]

Provides supported enclave(initrd-only) image types

Returns:

enclave image type names

Return type:

list

static get_exclude_list_for_non_physical_devices()[source]

Provides the list of folders that are not associated with a physical device. KIWI returns the basename of the folders typically used as mountpoint for those devices.

Returns:

list of file and directory names

Return type:

list

static get_exclude_list_for_removed_files_detection() List[str][source]

Provides list of files/dirs to exclude from the removed files detection in a delta root build

static get_exclude_list_for_root_data_sync(no_tmpdirs: bool = True)[source]

Provides the list of files or folders that are created by KIWI for its own purposes. Those files should be not be included in the resulting image.

Returns:

list of file and directory names

Return type:

list

static get_exclude_list_from_custom_exclude_files(root_dir: str) List[source]

Provides the list of folders that are excluded by the optional metadata file image/exclude_files.yaml

Returns:

list of file and directory names

Parameters:

root_dir (string) – image root directory

Return type:

list

static get_failsafe_kernel_options()[source]

Provides failsafe boot kernel options

Returns:

list of kernel options

['option=value', 'option']

Return type:

list

static get_filesystem_image_types()[source]

Provides list of supported filesystem image types

Returns:

filesystem names

Return type:

list

static get_firmware_types()[source]

Provides supported architecture specific firmware types

Returns:

firmware types per architecture

Return type:

dict

static get_grub_basic_modules(multiboot)[source]

Provides list of basic grub modules

Parameters:

multiboot (bool) – grub multiboot mode

Returns:

list of module names

Return type:

list

static get_grub_bios_core_loader(root_path)[source]

Provides grub bios image

Searches distribution specific locations to find the core bios image below the given root path

Parameters:

root_path (string) – image root path

Returns:

file path or None

Return type:

str

static get_grub_bios_modules(multiboot=False)[source]

Provides list of grub bios modules

Parameters:

multiboot (bool) – grub multiboot mode

Returns:

list of module names

Return type:

list

static get_grub_boot_directory_name(lookup_path)[source]

Provides grub2 data directory name in boot/ directory

Depending on the distribution the grub2 boot path could be either boot/grub2 or boot/grub. The method will decide for the correct base directory name according to the name pattern of the installed grub2 tools

Returns:

directory basename

Return type:

str

static get_grub_custom_arguments(root_dir: str) Dict[str, str][source]
static get_grub_efi_font_directory(root_path)[source]

Provides distribution specific EFI font directory used with grub.

Parameters:

root_path (string) – image root path

Returns:

file path or None

Return type:

str

static get_grub_efi_modules(multiboot=False)[source]

Provides list of grub efi modules

Parameters:

multiboot (bool) – grub multiboot mode

Returns:

list of module names

Return type:

list

static get_grub_ofw_modules()[source]

Provides list of grub ofw modules (ppc)

Returns:

list of module names

Return type:

list

static get_grub_path(root_path, filename, raise_on_error=True)[source]

Provides grub path to given search file

Depending on the distribution grub could be installed below a grub2 or grub directory. grub could also reside in /usr/lib as well as in /usr/share. Therefore this information needs to be dynamically looked up

Parameters:
  • root_path (string) – root path to start the lookup from

  • filename (string) – filename to search

  • raise_on_error (bool) – raise on not found, defaults to True

The method returns the path to the given grub search file. By default it raises a KiwiBootLoaderGrubDataError exception if the file could not be found in any of the search locations. If raise_on_error is set to False and no file could be found the function returns None

Returns:

filepath

Return type:

str

static get_grub_s390_modules()[source]

Provides list of grub ofw modules (s390)

Returns:

list of module names

Return type:

list

static get_imported_root_image(root_dir)[source]

Provides the path to an imported root system image

If the image description specified a derived_from attribute the file from this attribute is copied into the root_dir using the name as provided by this method

Parameters:

root_dir (string) – image root directory

Returns:

file path name

Return type:

str

static get_install_volume_id()[source]

Provides default value for ISO volume ID for install media

Returns:

name

Return type:

str

static get_iso_boot_path()[source]

Provides arch specific relative path to boot files on kiwi iso filesystems

Returns:

relative path name

Return type:

str

static get_iso_grub_loader()[source]

Return name of eltorito grub image used as ISO loader

Returns:

file base name

Return type:

str

static get_iso_grub_mbr()[source]

Return name of hybrid MBR image used as ISO boot record

Returns:

file base name

Return type:

str

static get_iso_media_tag_tool()[source]

Provides default iso media tag tool

Returns:

name

Return type:

str

static get_iso_tool_category()[source]

Provides default iso tool category

Returns:

name

Return type:

str

static get_kis_image_types()[source]

Provides supported kis image types

Returns:

kis image type names

Return type:

list

static get_live_dracut_modules_from_flag(flag_name)[source]

Provides flag_name to dracut modules name map

Depending on the value of the flag attribute in the KIWI image description specific dracut modules need to be selected

Returns:

dracut module names as list

Return type:

list

static get_live_image_types()[source]

Provides supported live image types

Returns:

live image type names

Return type:

list

static get_live_iso_persistent_boot_options(persistent_filesystem=None)[source]

Provides list of boot options passed to the dracut kiwi-live module to setup persistent writing

Returns:

list of boot options

Return type:

list

static get_luks_key_length()[source]

Provides key length to use for random luks keys

static get_lvm_overhead_mbytes()[source]

Provides empiric LVM overhead size in mbytes

Returns:

mbsize value

Return type:

int

static get_min_partition_mbytes()[source]

Provides default minimum partition size in mbytes

Returns:

mbsize value

Return type:

int

static get_min_volume_mbytes(filesystem: str)[source]

Provides default minimum LVM volume size in mbytes per filesystem

Returns:

mbsize value

Return type:

int

static get_mok_manager(root_path: str) str | None[source]

Provides Mok Manager file path

Searches distribution specific locations to find the Mok Manager EFI binary

Parameters:

root_path (str) – image root path

Returns:

file path or None

Return type:

str

static get_obs_api_server_url()[source]

Provides the default API server url to access the public open buildservice API

Returns:

url path

Return type:

str

static get_obs_download_server_url()[source]

Provides the default download server url hosting the public open buildservice repositories

Returns:

url path

Return type:

str

static get_oci_archive_tool()[source]

Provides the default OCI archive tool name.

Returns:

name

Return type:

str

static get_part_mapper_tool()[source]

Provides the default partition mapper tool name.

Returns:

name

Return type:

str

static get_platform_name()[source]

Provides the machine architecture name as used by KIWI

This is the architecture name as it is returned by ‘uname -m’ with one exception for the 32bit x86 architecture which is handled as ‘ix86’ in general

Returns:

architecture name

Return type:

str

static get_preparer()[source]

Provides ISO preparer name

Returns:

name

Return type:

str

static get_profile_file(root_dir)[source]

Return name of profile file for given root directory

static get_publisher()[source]

Provides ISO publisher name

Returns:

name

Return type:

str

static get_recovery_spare_mbytes()[source]

Provides spare size of recovery partition in mbytes

Returns:

mbsize value

Return type:

int

static get_removed_files_name()[source]

Provides base file name to store removed files in a delta root build

static get_runtime_checker_metadata() Dict[source]
static get_schema_file()[source]

Provides file path to kiwi RelaxNG schema

Returns:

file path

Return type:

str

static get_schematron_module_name()[source]

Provides module name for XML SchemaTron validations

Returns:

python module name

Return type:

str

static get_shared_cache_location()[source]

Provides the shared cache location

This is a directory which shares data from the image buildsystem host with the image root system. The location is returned as an absolute path stripped off by the leading ‘/’. This is because the path is transparently used on the host /<cache-dir> and inside of the image imageroot/<cache-dir>

Returns:

directory path

Return type:

str

static get_shim_loader(root_path: str) shim_loader_type | None[source]

Provides shim loader file path

Searches distribution specific locations to find shim.efi below the given root path

Parameters:

root_path (string) – image root path

Returns:

shim_loader_type | None

Return type:

NamedTuple

static get_shim_vendor_directory(root_path)[source]

Provides shim vendor directory

Searches distribution specific locations to find shim.efi below the given root path and return the directory name to the file found

Parameters:

root_path (string) – image root path

Returns:

directory path or None

Return type:

str

static get_signed_grub_loader(root_path: str, target_type: str = 'disk') grub_loader_type | None[source]

Provides shim signed grub loader file path

Searches distribution specific locations to find a grub EFI binary within the given root path

Parameters:

root_path (str) – image root path

Returns:

grub_loader_type | None

Return type:

NamedTuple

static get_snapper_config_template_file(root: str) str[source]

Provides the default configuration template file for snapper. The location in etc/ are preferred over files in usr/

Returns:

file path

Return type:

str

static get_solvable_location()[source]

Provides the directory to store SAT solvables for repositories. The solvable files are used to perform package dependency and metadata resolution

Returns:

directory path

Return type:

str

static get_swapsize_mbytes()[source]

Provides swapsize in MB

static get_sync_options()[source]

Provides list of default data sync options

Returns:

list of rsync options

Return type:

list

static get_system_files_name()[source]

Provides base file name to store system files in a container build

static get_temp_location()[source]

Provides the base temp directory location

This is the directory used to store any temporary files and directories created by kiwi during runtime

Returns:

directory path

Return type:

str

static get_unsigned_grub_loader(root_path: str, target_type: str = 'disk') str | None[source]

Provides unsigned grub efi loader file path

Searches distribution specific locations to find a distro grub EFI binary within the given root path

Parameters:

root_path (string) – image root path

Returns:

file path or None

Return type:

str

static get_vagrant_config_virtualbox_guest_additions()[source]

Provides the default value for vagrantconfig.virtualbox_guest_additions_present

Returns:

whether guest additions are expected to be present in the vagrant box

Return type:

bool

static get_vendor_grubenv(efi_path)[source]
static get_video_mode_map()[source]

Provides video mode map

Assign a tuple to each kernel vesa hex id for each of the supported bootloaders

Returns:

video type map

{'kernel_hex_mode': video_type(grub2='mode')}

Return type:

dict

static get_volume_id()[source]

Provides default value for ISO volume ID

Returns:

name

Return type:

str

static get_xsl_stylesheet_file()[source]

Provides the file path to the KIWI XSLT style sheets

Returns:

file path

Return type:

str

static get_xz_compression_options()[source]

Provides compression options for the xz compressor

Returns:

Contains list of options

['--option=value']

Return type:

list

static is_buildservice_worker()[source]

Checks if build host is an open buildservice machine

The presence of /.buildenv on the build host indicates we are building inside of the open buildservice

Returns:

True if obs worker, else False

Return type:

bool

static is_ppc64_arch(arch)[source]

Checks if machine architecture is ppc64 based

Any arch that matches little endian or big endian ppc64 architecture causes the method to return True. Anything else will cause the method to return False

Return type:

bool

static is_x86_arch(arch)[source]

Checks if machine architecture is x86 based

Any arch that matches 32bit and 64bit x86 architecture causes the method to return True. Anything else will cause the method to return False

Return type:

bool

static project_file(filename)[source]

Provides the python module base directory search path

The method uses the importlib.resources.path method to identify files and directories from the application

Parameters:

filename (string) – relative project file

Returns:

absolute file path name

Return type:

str

static set_custom_runtime_config_file(filename)[source]

Sets the runtime config file once

Parameters:

filename (str) – a file path name

static set_platform_name(name: str)[source]

Sets the platform architecture once

Parameters:

name (str) – an architecture name

static set_runtime_checker_metadata(filename)[source]

Sets the runtime checker metadata filename

Parameters:

filename (str) – a file path name

static set_shared_cache_location(location)[source]

Sets the shared cache location once

Parameters:

location (str) – a location path

static set_temp_location(location)[source]

Sets the temp directory location once

Parameters:

location (str) – a location path

to_profile(profile)[source]

Implements method to add list of profile keys and their values to the specified instance of a Profile class

Parameters:

profile (object) – Profile instance

class kiwi.defaults.grub_loader_type(filename, binaryname)

Bases: tuple

binaryname: str

Alias for field number 1

filename: str

Alias for field number 0

class kiwi.defaults.shim_loader_type(filename, binaryname)

Bases: tuple

binaryname: str

Alias for field number 1

filename: str

Alias for field number 0

class kiwi.defaults.unit_type(byte, kb, mb, gb)

Bases: tuple

byte: str

Alias for field number 0

gb: str

Alias for field number 3

kb: str

Alias for field number 1

mb: str

Alias for field number 2

kiwi.exceptions Module

exception kiwi.exceptions.KiwiAnyMarkupPluginError(message)[source]

Bases: KiwiError

Exception raised if the python anymarkup module failed to load.

exception kiwi.exceptions.KiwiArchiveSetupError(message)[source]

Bases: KiwiError

Exception raised if an unsupported image archive type is used.

exception kiwi.exceptions.KiwiArchiveTarError(message)[source]

Bases: KiwiError

Exception raised if impossible to determine which tar command version is installed on the underlying system

exception kiwi.exceptions.KiwiBootImageSetupError(message)[source]

Bases: KiwiError

Exception raised if an unsupported initrd system type is used.

exception kiwi.exceptions.KiwiBootLoaderConfigSetupError(message)[source]

Bases: KiwiError

Exception raised if a configuration for an unsupported bootloader is requested.

exception kiwi.exceptions.KiwiBootLoaderDiskPasswordError(message)[source]

Bases: KiwiError

Exception raised if the disk password could not be set

exception kiwi.exceptions.KiwiBootLoaderGrubDataError(message)[source]

Bases: KiwiError

Exception raised if no grub installation was found.

exception kiwi.exceptions.KiwiBootLoaderGrubFontError(message)[source]

Bases: KiwiError

Exception raised if no grub unicode font was found.

exception kiwi.exceptions.KiwiBootLoaderGrubInstallError(message)[source]

Bases: KiwiError

Exception raised if grub install to master boot record has failed.

exception kiwi.exceptions.KiwiBootLoaderGrubModulesError(message)[source]

Bases: KiwiError

Exception raised if the synchronisation of modules from the grub installation to the boot space has failed.

exception kiwi.exceptions.KiwiBootLoaderGrubPlatformError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to use grub on an unsupported platform.

exception kiwi.exceptions.KiwiBootLoaderGrubSecureBootError(message)[source]

Bases: KiwiError

Exception raised if the Microsoft signed shim loader or grub2 loader could not be found in the image root system

exception kiwi.exceptions.KiwiBootLoaderInstallSetupError(message)[source]

Bases: KiwiError

Exception raised if an installation for an unsupported bootloader is requested.

exception kiwi.exceptions.KiwiBootLoaderTargetError(message)[source]

Bases: KiwiError

Exception raised if the target to read the bootloader path from is not a disk or an iso image.

exception kiwi.exceptions.KiwiBootLoaderZiplInstallError(message)[source]

Bases: KiwiError

Exception raised if the installation of zipl has failed.

exception kiwi.exceptions.KiwiBootLoaderZiplPlatformError(message)[source]

Bases: KiwiError

Exception raised if a configuration for an unsupported zipl architecture is requested.

exception kiwi.exceptions.KiwiBootLoaderZiplSetupError(message)[source]

Bases: KiwiError

Exception raised if the data set to configure the zipl bootloader is incomplete.

exception kiwi.exceptions.KiwiBootStrapPhaseFailed(message)[source]

Bases: KiwiError

Exception raised if the bootstrap phase of the system prepare command has failed.

exception kiwi.exceptions.KiwiBuildahError(message)[source]

Bases: KiwiError

Exception raised on inconsistent buildah class calls

exception kiwi.exceptions.KiwiBundleError(message)[source]

Bases: KiwiError

Exception raised if the system bundle command has failed.

exception kiwi.exceptions.KiwiCommandCapabilitiesError(message)[source]

Bases: KiwiError

Exception is raised when some the CommandCapabilities methods fails, usually meaning there is some issue trying to parse some command output.

exception kiwi.exceptions.KiwiCommandError(message)[source]

Bases: KiwiError

Exception raised if an external command called via a Command instance has returned with an exit code != 0 or could not be called at all.

exception kiwi.exceptions.KiwiCommandNotFound(message)[source]

Bases: KiwiError

Exception raised if any executable command cannot be found in the evironment PATH variable.

exception kiwi.exceptions.KiwiCommandNotLoaded(message)[source]

Bases: KiwiError

Exception raised if a kiwi command task module could not be loaded.

exception kiwi.exceptions.KiwiCompressionFormatUnknown(message)[source]

Bases: KiwiError

Exception raised if the compression format of the data could not be detected.

exception kiwi.exceptions.KiwiConfigFileFormatNotSupported(message)[source]

Bases: KiwiError

Exception raised if kiwi description file format is not supported.

exception kiwi.exceptions.KiwiConfigFileNotFound(message)[source]

Bases: KiwiError

Exception raised if no kiwi XML description was found.

exception kiwi.exceptions.KiwiContainerBuilderError(message)[source]

Bases: KiwiError

Exception is raised when something fails during a container image build procedure.

exception kiwi.exceptions.KiwiContainerImageSetupError(message)[source]

Bases: KiwiError

Exception raised if an attempt to create a container instance for an unsupported container type is performed.

exception kiwi.exceptions.KiwiContainerSetupError(message)[source]

Bases: KiwiError

Exception raised if an error in the creation of the container archive happened.

exception kiwi.exceptions.KiwiCredentialsError(message)[source]

Bases: KiwiError

Exception raised if required credentials information is missing

exception kiwi.exceptions.KiwiCustomPartitionConflictError(message)[source]

Bases: KiwiError

Exception raised if the entry in a custom partition setup conflicts with an existing partition table layout setting

exception kiwi.exceptions.KiwiDataStructureError(message)[source]

Bases: KiwiError

Exception raised if the XML description failed to parse the data structure.

exception kiwi.exceptions.KiwiDebianBootstrapError(message)[source]

Bases: KiwiError

Exception raised if the bootstrap installation for Debian based systems has failed

exception kiwi.exceptions.KiwiDecodingError(message)[source]

Bases: KiwiError

Exception is raised on decoding literals failure

exception kiwi.exceptions.KiwiDescriptionInvalid(message)[source]

Bases: KiwiError

Exception raised if the XML description failed to validate the XML schema.

exception kiwi.exceptions.KiwiDeviceProviderError(message)[source]

Bases: KiwiError

Exception raised if a storage provide is asked for its managed device but no such device exists.

exception kiwi.exceptions.KiwiDiskBootImageError(message)[source]

Bases: KiwiError

Exception raised if a kiwi boot image does not provide the requested data, e.g kernel, or hypervisor files.

exception kiwi.exceptions.KiwiDiskFormatSetupError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to create a disk format instance of an unsupported disk format.

exception kiwi.exceptions.KiwiDiskGeometryError(message)[source]

Bases: KiwiError

Exception raised if the disk geometry (partition table) could not be read or evaluated against their expected geometry and capabilities.

exception kiwi.exceptions.KiwiDistributionNameError(message)[source]

Bases: KiwiError

Exception raised if the distribution name could not be found. The information is extracted from the boot attribute of the XML description. If no boot attribute is present or does not match the naming conventions the exception is raised.

exception kiwi.exceptions.KiwiEnclaveBootImageError(message)[source]

Bases: KiwiError

Exception raised if no kernel image was found while building an enclave image.

exception kiwi.exceptions.KiwiEnclaveFormatError(message)[source]

Bases: KiwiError

Exception raised if no enclave_format attribute specified for the selected build type

exception kiwi.exceptions.KiwiError(message)[source]

Bases: Exception

Base class to handle all known exceptions

Specific exceptions are implemented as sub classes of KiwiError

Attributes

Parameters:

message (string) – Exception message text

exception kiwi.exceptions.KiwiExtensionError(message)[source]

Bases: KiwiError

Exception raised if an extension section of the same namespace is used multiple times as toplevel section within the extension section. Each extension must have a single toplevel entry point qualified by its namespace

exception kiwi.exceptions.KiwiFileAccessError(message)[source]

Bases: KiwiError

Exception raised if accessing a file or its metadata failed

exception kiwi.exceptions.KiwiFileNotFound(message)[source]

Bases: KiwiError

Exception raised if the requested file could not be found.

exception kiwi.exceptions.KiwiFileSystemSetupError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to build an unsupported or unspecified filesystem.

exception kiwi.exceptions.KiwiFileSystemSyncError(message)[source]

Bases: KiwiError

Exception raised if the data sync from the system into the loop mounted filesystem image failed.

exception kiwi.exceptions.KiwiFormatSetupError(message)[source]

Bases: KiwiError

Exception raised if the requested disk format could not be created.

exception kiwi.exceptions.KiwiHelpNoCommandGiven(message)[source]

Bases: KiwiError

Exception raised if the request for the help page is executed without a command to show the help for.

exception kiwi.exceptions.KiwiImageResizeError(message)[source]

Bases: KiwiError

Exception raised if the request to resize a disk image failed. Reasons could be a missing raw disk reference or a wrong size specification.

exception kiwi.exceptions.KiwiImportDescriptionError(message)[source]

Bases: KiwiError

Exception raised if the XML description data and scripts could not be imported into the root of the image.

exception kiwi.exceptions.KiwiIncludFileNotFoundError(message)[source]

Bases: KiwiError

Exception raised if the file reference in an <include> statement could not be found

exception kiwi.exceptions.KiwiInstallBootImageError(message)[source]

Bases: KiwiError

Exception raised if the required files to boot an installation image could not be found, e.g kernel or hypervisor.

exception kiwi.exceptions.KiwiInstallMediaError(message)[source]

Bases: KiwiError

Exception raised if a request for an installation media is made but the system image type is not an oem type.

exception kiwi.exceptions.KiwiInstallPhaseFailed(message)[source]

Bases: KiwiError

Exception raised if the install phase of a system prepare command has failed.

exception kiwi.exceptions.KiwiIsoMetaDataError(message)[source]

Bases: KiwiError

Exception raised if an inconsistency in the ISO header was found such like invalid eltorito specification or a broken path table.

exception kiwi.exceptions.KiwiIsoToolError(message)[source]

Bases: KiwiError

Exception raised if an iso helper tool such as isoinfo could not be found on the build system.

exception kiwi.exceptions.KiwiKernelLookupError(message)[source]

Bases: KiwiError

Exception raised if the search for the kernel image file failed

exception kiwi.exceptions.KiwiKisBootImageError(message)[source]

Bases: KiwiError

Exception raised if a required boot file e.g the kernel could not be found in the process of building a kis image.

exception kiwi.exceptions.KiwiLiveBootImageError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to use an unsupported live iso type.

exception kiwi.exceptions.KiwiLoadCommandUndefined(message)[source]

Bases: KiwiError

Exception raised if no command is specified for a given service on the commandline.

exception kiwi.exceptions.KiwiLogFileSetupFailed(message)[source]

Bases: KiwiError

Exception raised if the log file could not be created.

exception kiwi.exceptions.KiwiLogSocketSetupFailed(message)[source]

Bases: KiwiError

Exception raised if the Unix Domain log socket could not be created.

exception kiwi.exceptions.KiwiLoopSetupError(message)[source]

Bases: KiwiError

Exception raised if not enough user data to create a loop device is specified.

exception kiwi.exceptions.KiwiLuksSetupError(message)[source]

Bases: KiwiError

Exception raised if not enough user data is provided to setup the luks encryption on the given device.

exception kiwi.exceptions.KiwiMappedDeviceError(message)[source]

Bases: KiwiError

Exception raised if the device to become mapped does not exist.

exception kiwi.exceptions.KiwiMarkupConversionError(message)[source]

Bases: KiwiError

Exception raised if the markup format conversion is not possible.

exception kiwi.exceptions.KiwiMountKernelFileSystemsError(message)[source]

Bases: KiwiError

Exception raised if a kernel filesystem such as proc or sys could not be mounted.

exception kiwi.exceptions.KiwiMountSharedDirectoryError(message)[source]

Bases: KiwiError

Exception raised if the host <-> image shared directory could not be mounted.

exception kiwi.exceptions.KiwiNotImplementedError(message)[source]

Bases: KiwiError

Exception raised if a functionality is not yet implemented.

exception kiwi.exceptions.KiwiOCIArchiveToolError(message)[source]

Bases: KiwiError

Exception raised if the requested OCI archive tool is not supported

exception kiwi.exceptions.KiwiOSReleaseImportError(message)[source]

Bases: KiwiError

Exception raised if reading etc/os-release caused an issue

exception kiwi.exceptions.KiwiOffsetError(message)[source]

Bases: KiwiError

Exception raised if the offset for a seek operation does not match the expected data to write

exception kiwi.exceptions.KiwiPackageManagerSetupError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to create a package manager instance for an unsupported package manager.

exception kiwi.exceptions.KiwiPackagesDeletePhaseFailed(message)[source]

Bases: KiwiError

Exception raised if the packages deletion phase in system prepare fails.

exception kiwi.exceptions.KiwiPartitionTooSmallError(message)[source]

Bases: KiwiError

Exception raised if the specified partition size is smaller than the required bytes to store the data

exception kiwi.exceptions.KiwiPartitionerGptFlagError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to set an unknown partition flag for an entry in the GPT table.

exception kiwi.exceptions.KiwiPartitionerMsDosFlagError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to set an unknown partition flag for an entry in the MSDOS table.

exception kiwi.exceptions.KiwiPartitionerSetupError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to create an instance of a partitioner for an unsupporte partitioner.

exception kiwi.exceptions.KiwiPrivilegesError(message)[source]

Bases: KiwiError

Exception raised if root privileges are required but not granted.

exception kiwi.exceptions.KiwiProfileNotFound(message)[source]

Bases: KiwiError

Exception raised if a specified profile does not exist in the XML configuration.

exception kiwi.exceptions.KiwiRaidSetupError(message)[source]

Bases: KiwiError

Exception raised if invalid or not enough user data is provided to create a raid array on the specified storage device.

exception kiwi.exceptions.KiwiRepositorySetupError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to create an instance of a repository for an unsupported package manager.

exception kiwi.exceptions.KiwiRequestError(message)[source]

Bases: KiwiError

Exception raised if a package request could not be processed by the corresponding package manager instance.

exception kiwi.exceptions.KiwiRequestedTypeError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to build an image for an unsupported image type.

exception kiwi.exceptions.KiwiResizeRawDiskError(message)[source]

Bases: KiwiError

Exception raised if an attempt was made to resize the image disk to a smaller size than the current one. Simply shrinking a disk image file is not possible without data corruption because the partitions were setup to use the entire disk geometry as it fits into the file. A successful shrinking operation would require the filesystems and the partition table to be reduced which is not done by the provided simple storage resize method. In addition without the user overwriting the disk size in the XML setup, kiwi will calculate the minimum required size in order to store the data. Thus in almost all cases it will not be possible to store the data in a smaller disk.

exception kiwi.exceptions.KiwiResultError(message)[source]

Bases: KiwiError

Exception raised if the image build result pickle information could not be created or loaded.

exception kiwi.exceptions.KiwiRootDirExists(message)[source]

Bases: KiwiError

Exception raised if the specified image root directory already exists and should not be re-used.

exception kiwi.exceptions.KiwiRootImportError(message)[source]

Bases: KiwiError

Exception is raised when something fails during the root import procedure.

exception kiwi.exceptions.KiwiRootInitCreationError(message)[source]

Bases: KiwiError

Exception raised if the initialization of a new image root directory has failed.

exception kiwi.exceptions.KiwiRpmDirNotRemoteError(message)[source]

Bases: KiwiError

Exception raised if the provided rpm-dir repository is not local

exception kiwi.exceptions.KiwiRuntimeConfigFileError(message)[source]

Bases: KiwiError

Exception raised if the provided custom runtime config file could not be found

exception kiwi.exceptions.KiwiRuntimeConfigFormatError(message)[source]

Bases: KiwiError

Exception raised if the expected format in the yaml KIWI runtime config file does not match

exception kiwi.exceptions.KiwiRuntimeError(message)[source]

Bases: KiwiError

Exception raised if a runtime check has failed.

exception kiwi.exceptions.KiwiSatSolverJobError(message)[source]

Bases: KiwiError

Exception raised if a sat solver job can not be done, e.g because the requested package or collection does not exist in the registered repository metadata

exception kiwi.exceptions.KiwiSatSolverJobProblems(message)[source]

Bases: KiwiError

Exception raised if the sat solver operations returned with solver problems e.g package conflicts

exception kiwi.exceptions.KiwiSatSolverPluginError(message)[source]

Bases: KiwiError

Exception raised if the python solv module failed to load. The solv module is provided by SUSE’s rpm package python-solv and provides a python binding to the libsolv C library

exception kiwi.exceptions.KiwiSchemaImportError(message)[source]

Bases: KiwiError

Exception raised if the schema file could not be read by lxml.RelaxNG.

exception kiwi.exceptions.KiwiScriptFailed(message)[source]

Bases: KiwiError

Exception raised if a user script returned with an exit code != 0.

exception kiwi.exceptions.KiwiSetupIntermediateConfigError(message)[source]

Bases: KiwiError

Exception raised if the setup of the temporary image system configuration for the duration of the build process has failed.

exception kiwi.exceptions.KiwiShellVariableValueError(message)[source]

Bases: KiwiError

Exception raised if a given python value cannot be converted into a string representation for use in shell scripts

exception kiwi.exceptions.KiwiSizeError(message)[source]

Bases: KiwiError

Exception is raised when the convertion from a given size in string format to a number.

exception kiwi.exceptions.KiwiSolverRepositorySetupError(message)[source]

Bases: KiwiError

Exception raised if the repository type is not supported for the creation of a SAT solvable

exception kiwi.exceptions.KiwiSystemDeletePackagesFailed(message)[source]

Bases: KiwiError

Exception raised if the deletion of a package has failed in the corresponding package manager instance.

exception kiwi.exceptions.KiwiSystemInstallPackagesFailed(message)[source]

Bases: KiwiError

Exception raised if the installation of a package has failed in the corresponding package manager instance.

exception kiwi.exceptions.KiwiSystemUpdateFailed(message)[source]

Bases: KiwiError

Exception raised if the package upgrade has failed in the corresponding package manager instance.

exception kiwi.exceptions.KiwiTargetDirectoryNotFound(message)[source]

Bases: KiwiError

Exception raised if the specified target directory to store the image results was not found.

exception kiwi.exceptions.KiwiTemplateError(message)[source]

Bases: KiwiError

Exception raised if the substitution of variables in a configuration file template has failed.

exception kiwi.exceptions.KiwiTypeNotFound(message)[source]

Bases: KiwiError

Exception raised if no build type was found in the XML description.

exception kiwi.exceptions.KiwiUmountBusyError(message)[source]

Bases: KiwiError

Exception raised if the attempt to umount a resource has failed

exception kiwi.exceptions.KiwiUnknownServiceName(message)[source]

Bases: KiwiError

Exception raised if an unknown service name was provided on the commandline.

exception kiwi.exceptions.KiwiUriOpenError(message)[source]

Bases: KiwiError

Exception raised if the urllib urlopen request has failed

exception kiwi.exceptions.KiwiUriStyleUnknown(message)[source]

Bases: KiwiError

Exception raised if an unsupported URI style was used in the source definition of a repository.

exception kiwi.exceptions.KiwiUriTypeUnknown(message)[source]

Bases: KiwiError

Exception raised if the protocol type of an URI is unknown in the source definition of a repository.

exception kiwi.exceptions.KiwiValidationError(message)[source]

Bases: KiwiError

Exception raised if the XML validation against the schema has failed.

exception kiwi.exceptions.KiwiVhdTagError(message)[source]

Bases: KiwiError

Exception raised if the GUID tag is not provided in the expected format.

exception kiwi.exceptions.KiwiVolumeGroupConflict(message)[source]

Bases: KiwiError

Exception raised if the requested LVM volume group already is in use on the build system.

exception kiwi.exceptions.KiwiVolumeManagerSetupError(message)[source]

Bases: KiwiError

Exception raised if the preconditions for volume mangement support are not met or an attempt was made to create an instance of a volume manager for an unsupported volume management system.

exception kiwi.exceptions.KiwiVolumeRootIDError(message)[source]

Bases: KiwiError

Exception raised if the root volume can not be found. This concept currently exists only for the btrfs subvolume system.

exception kiwi.exceptions.KiwiVolumeTooSmallError(message)[source]

Bases: KiwiError

Exception raised if the specified volume size is smaller than the required bytes to store the data

kiwi.firmware Module

class kiwi.firmware.FirmWare(xml_state)[source]

Bases: object

Implements firmware specific methods

According to the selected firmware some parameters in a disk image changes. This class provides methods to provide firmware dependant information

  • param object xml_state:

    instance of XMLState

bios_mode()[source]

Check if BIOS mode is requested

Returns:

True or False

Return type:

bool

ec2_mode()[source]

Check if EC2 mode is requested

Returns:

True or False

Return type:

bool

efi_mode() str[source]

Check if EFI mode is requested

Returns:

The requested EFI mode or None if no EFI mode requested

Return type:

str

get_efi_partition_size()[source]

Size of EFI partition. Returns 0 if no such partition is needed

Returns:

mbsize value

Return type:

int

get_legacy_bios_partition_size()[source]

Size of legacy bios_grub partition if legacy BIOS mode is required. Returns 0 if no such partition is needed

Returns:

mbsize value

Return type:

int

get_partition_table_type()[source]

Provides partition table type according to architecture and firmware

Returns:

partition table name

Return type:

str

get_prep_partition_size()[source]

Size of Prep partition if OFW mode is requested. Returns 0 if no such partition is needed

Returns:

mbsize value

Return type:

int

legacy_bios_mode() bool[source]

Check if the legacy boot from BIOS systems should be activated

Returns:

True or False

Return type:

bool

ofw_mode()[source]

Check if OFW mode is requested

Returns:

True or False

Return type:

bool

opal_mode()[source]

Check if Opal mode is requested

Returns:

True or False

Return type:

bool

kiwi.help Module

class kiwi.help.Help[source]

Bases: object

Implements man page help for kiwi commands

Each kiwi command implements their own manual page, which is shown if the positional argument ‘help’ is passed to the command.

show(command=None)[source]

Call man to show the command specific manual page

All kiwi commands store their manual page in the section ‘8’ of the man system. The calling process is replaced by the man process

Parameters:

command (string) – man page name

kiwi.kiwi Module

kiwi.kiwi.extras(help_, version, options, doc)[source]

Overwritten method from docopt

Shows our own usage message for -h|–help

Parameters:
  • help (bool) – indicate to show help

  • version (string) – version string

  • options (list)

list of option tuples

[option(name='name', value='value')]
Parameters:

doc (string) – docopt doc string

kiwi.kiwi.main()[source]

kiwi - main application entry point

Initializes a global log object and handles all errors of the application. Every known error is inherited from KiwiError, everything else is passed down until the generic Exception which is handled as unexpected error including the python backtrace

kiwi.kiwi.usage(command_usage)[source]

Instead of the docopt way to show the usage information we provide a kiwi specific usage information. The usage data now always consists out of:

  1. the generic call kiwi-ng [global options] service <command> [<args>]

  2. the command specific usage defined by the docopt string short form by default, long form with -h | –help

  3. the global options

Parameters:

command_usage (string) – usage data

kiwi.logger Module

class kiwi.logger.Logger(name: str)[source]

Bases: Logger

Extended logging facility based on Python logging

Parameters:

name (str) – name of the logger

getLogFlags() Dict[str, bool][source]

Return logging flags

Returns:

Dictionary with flags and their activation status

Return type:

dict

getLogLevel() int[source]

Return currently used log level

Returns:

log level number

Return type:

int

get_logfile() str | None[source]

Return file path name of logfile

Returns:

file path

Return type:

str

static progress(current: int, total: int, prefix: str, bar_length: int = 40) None[source]

Custom progress log information. progress information is intentionally only logged to stdout and will bypass any handlers. We don’t want this information to show up in the log file

Parameters:
  • current (int) – current item

  • total (int) – total number of items

  • prefix (string) – prefix name

  • bar_length (int) – length of progress bar

setLogFlag(flag: str, value: bool = True) None[source]

Set logging flag for further properties of the logging facility Available flags are:

  • run-scripts-in-screen

Parameters:

flag (str) – name

setLogLevel(level: int, except_for: List[str] = [], only_for: List[str] = []) None[source]

Set custom log level for all console handlers

Parameters:
  • level (int) – log level number

  • except_for (list) – set log level to all handlers except for the given list

  • only_for (list) – set log level to the given handlers only

if both except_for and only_for handlers are specified, the except_for list will be ignored

set_color_format() None[source]

Set color format for all console handlers

set_log_socket(filename: str) None[source]

Set log socket handler

Parameters:

filename (str) – UDS socket file path. Note if there is no server listening on the socket the log handler setup will fail

set_logfile(filename: str) None[source]

Set logfile handler

Parameters:

filename (str) – logfile file path

kiwi.logger_color_formatter Module

class kiwi.logger_color_formatter.ColorFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: Formatter

Extended standard logging Formatter

Extended format supporting text with color metadata

Example:

ColorFormatter(message_format, '%H:%M:%S')
format(record: LogRecord) str[source]

Creates a logging Formatter with support for color messages

Parameters:

record (tuple) – logging message record

Returns:

result from format_message

Return type:

str

class kiwi.logger_color_formatter.ColorMessage[source]

Bases: object

Implements color messages for Python logging facility

Has to implement the format_message method to serve as message formatter

format_message(level: str, message: str) str[source]

Message formatter with support for embedded color sequences

The Message is allowed to contain the following color metadata:

  • $RESET, reset to no color mode

  • $BOLD, bold

  • $COLOR, color the following text

  • $LIGHTCOLOR, light color the following text

The color of the message depends on the level and is defined in the ColorMessage constructor

Parameters:
  • level (str) – color level name

  • message (str) – text

Returns:

color message with escape sequences

Return type:

str

kiwi.logger_filter Module

class kiwi.logger_filter.DebugFilter(name='')[source]

Bases: Filter

Extended standard debug logging Filter

filter(record: LogRecord) bool[source]

Only messages with record level DEBUG can pass for messages with another level an extra handler is used

Parameters:

record (tuple) – logging message record

Returns:

True|False

Return type:

bool

class kiwi.logger_filter.ErrorFilter(name='')[source]

Bases: Filter

Extended standard error logging Filter

filter(record: LogRecord) bool[source]

Only messages with record level DEBUG can pass for messages with another level an extra handler is used

Parameters:

record (tuple) – logging message record

Returns:

True|False

Return type:

bool

class kiwi.logger_filter.InfoFilter(name='')[source]

Bases: Filter

Extended standard logging Filter

filter(record: LogRecord) bool[source]

Only messages with record level INFO can pass for messages with another level an extra handler is used

Parameters:

record (tuple) – logging message record

Returns:

True|False

Return type:

bool

class kiwi.logger_filter.LoggerSchedulerFilter(name='')[source]

Bases: Filter

Extended standard logging Filter

filter(record: LogRecord) bool[source]

Messages from apscheduler scheduler instances are filtered out They conflict with console progress information

Parameters:

record (tuple) – logging message record

Returns:

True|False

Return type:

bool

class kiwi.logger_filter.WarningFilter(name='')[source]

Bases: Filter

Extended standard warning logging Filter

filter(record: LogRecord) bool[source]

Only messages with record level WARNING can pass for messages with another level an extra handler is used

Parameters:

record (tuple) – logging message record

Returns:

True|False

Return type:

bool

kiwi.mount_manager Module

class kiwi.mount_manager.MountManager(device: str, mountpoint: str = '', attributes: Dict[str, str] = {})[source]

Bases: object

Implements methods for mounting, umounting and mount checking

The caller is responsible for unmounting the device if the MountManager is used as is.

The class also supports to be used as a context manager, where the device is unmounted once the context manager’s with block is left

  • param string device:

    device node name

  • param string mountpoint:

    mountpoint directory name

  • param dict attributes:

    optional attributes to store

bind_mount() None[source]

Bind mount the device to the mountpoint

get_attributes() Dict[str, str][source]

Return attributes dict for this mount manager

is_mounted() bool[source]

Check if mounted

Returns:

True or False

Return type:

bool

mount(options: List[str] = []) None[source]

Standard mount the device to the mountpoint

Parameters:

options (list) – mount options

overlay_mount(lower: str) None[source]
tmpfs_mount() None[source]

tmpfs mount the device to the mountpoint

umount(raise_on_busy: bool = True) bool[source]

Umount by the mountpoint directory

Wait up to 10sec trying to umount. If the resource stays busy the call will raise an exception unless raise_on_busy is set to False. In case the umount failed and raise_on_busy is set to False, the method returns False to indicate the error condition.

Returns:

True or False

Return type:

bool

umount_lazy() None[source]

Umount by the mountpoint directory in lazy mode

Release the mount in any case, however the time when the mounted resource is released by the kernel depends on when the resource enters the non busy state

kiwi.path Module

class kiwi.path.Path[source]

Bases: object

Directory path helpers

static access(path: str, mode: int, **kwargs) bool[source]

Check whether path can be accessed with the given mode.

Parameters:
  • path (str) – The path that should be checked for access.

  • mode (int) – Which access mode should be checked. This value must be a bit-wise or of one or more of the following constants: os.F_OK (note that this one is zero), os.X_OK, os.R_OK and os.W_OK

  • kwargs – further keyword arguments are forwarded to os.access()

Returns:

Boolean value whether this access mode is allowed

Return type:

bool

Raises:
static create(path: str) None[source]

Create path and all sub directories to target

Parameters:

path (string) – path name

static move_to_root(root: str, elements: List[str]) List[str][source]

Change the given path elements to a new root directory

Parameters:
  • root (str) – the root path to trim

  • elements (list) – list of path names

Returns:

changed elements

Return type:

list

static rebase_to_root(root: str, elements: List[str]) List[str][source]

Include the root prefix for the given paths elements

Parameters:
  • root (str) – the new root path

  • elements (list) – list of path names

Returns:

changed elements

Return type:

list

static remove_hierarchy(root: str, path: str) None[source]

Recursively remove an empty path and its sub directories starting at a given root directory. Ignore non empty or protected paths and leave them untouched

Parameters:
  • root (string) – start at directory

  • path (string) – path name below root

static sort_by_hierarchy(path_list: List[str]) List[str][source]

Sort given list of path names by their hierachy in the tree

Example:

result = Path.sort_by_hierarchy(['/var/lib', '/var'])
Parameters:

path_list (list) – list of path names

Returns:

hierachy sorted path_list

Return type:

list

static which(filename: str, custom_env: MutableMapping[str, str] | None = None, access_mode: int = 1, root_dir: str | None = None) str | None[source]

Lookup file name in PATH

Parameters:
  • filename (string) – file base name

  • alternative_lookup_paths (list) – list of additional lookup paths

  • custom_env (list) – a custom os.environ used to obtain $PATH

  • access_mode (int) – one of the os access modes or a combination of them (os.R_OK, os.W_OK and os.X_OK). If the provided access mode does not match the file is considered not existing

  • root_dir (str) – the root path to look at

Returns:

absolute path to file or None

Return type:

str

static wipe(path: str) None[source]

Delete path and all contents

Parameters:

path (string) – path name

kiwi.privileges Module

class kiwi.privileges.Privileges[source]

Bases: object

Implements check for root privileges

static check_for_root_permissions()[source]

Check if we are effectively root on the system. If not an exception is thrown

Returns:

True or raise an Exception

Return type:

bool

kiwi.runtime_checker Module

class kiwi.runtime_checker.RuntimeChecker(xml_state: XMLState)[source]

Bases: object

Implements build consistency checks at runtime

check_appx_naming_conventions_valid() None[source]

When building wsl images there are some naming conventions that must be fulfilled to run the container on Microsoft Windows

check_boot_description_exists() None[source]

If a kiwi initrd is used, a lookup to the specified boot description is done and fails early if it does not exist

check_consistent_kernel_in_boot_and_system_image() None[source]

If a kiwi initrd is used, the kernel used to build the kiwi initrd and the kernel used in the system image must be the same in order to avoid an inconsistent boot setup

check_container_tool_chain_installed() None[source]

When creating container images the specific tools are used in order to import and export OCI or Docker compatible images. This check searches for those tools to be installed in the build system and fails if it can’t find them

check_dracut_module_for_disk_oem_in_package_list() None[source]

OEM images if configured to use dracut as initrd system requires the KIWI provided dracut-kiwi-oem-repart module to be installed at the time dracut is called. Thus this runtime check examines if the required package is part of the package list in the image description.

check_dracut_module_for_disk_overlay_in_package_list() None[source]

Disk images configured to use a root filesystem overlay requires the KIWI provided kiwi-overlay dracut module to be installed at the time dracut is called. Thus this runtime check examines if the required package is part of the package list in the image description.

check_dracut_module_for_live_iso_in_package_list() None[source]

Live ISO images uses a dracut initrd to boot and requires the KIWI provided kiwi-live dracut module to be installed at the time dracut is called. Thus this runtime check examines if the required package is part of the package list in the image description.

check_dracut_module_for_oem_install_in_package_list() None[source]

OEM images if configured to use dracut as initrd system and configured with one of the installiso, installstick or installpxe attributes requires the KIWI provided dracut-kiwi-oem-dump module to be installed at the time dracut is called. Thus this runtime check examines if the required package is part of the package list in the image description.

check_dracut_module_versions_compatible_to_kiwi(root_dir: str) None[source]

KIWI images which makes use of kiwi dracut modules has to use module versions compatible with the version of this KIWI builder code base. This is important to avoid inconsistencies between the way how kiwi includes its own dracut modules and former version of those dracut modules which could be no longer compatible with the builder. Therefore this runtime check maintains a min_version constraint for which we know this KIWI builder to be compatible with.

check_efi_fat_image_has_correct_size() None[source]

Verify that the efifatimagesize does not exceed the max El Torito load size of 65535 * 512 bytes

check_efi_mode_for_disk_overlay_correctly_setup() None[source]

Disk images configured to use a root filesystem overlay only supports the standard EFI mode and not secure boot. That’s because the shim setup performs changes to the root filesystem which can not be applied during the bootloader setup at build time because at that point the root filesystem is a read-only squashfs source.

check_image_include_repos_publicly_resolvable() None[source]

Verify that all repos marked with the imageinclude attribute can be resolved into a http based web URL

check_image_type_unique() None[source]

Verify that the selected image type is unique within the range of the configured types and profiles.

check_image_version_provided() None[source]

Kiwi requires a <version> element to be specified as part of at least one <preferences> section.

check_include_references_unresolvable() None[source]

Raise for still included <include> statements as not resolvable. The KIWI XSLT processing replaces the specified include directive(s) with the given file reference(s). If this action did not happen for example on nested includes, it can happen that they stay in the document as sort of waste.

check_initrd_selection_required() None[source]

If the boot attribute is used without selecting kiwi as the initrd_system, the setting of the boot attribute will not have any effect. We assume that configurations which explicitly specify the boot attribute wants to use the custom kiwi initrd system and not dracut.

check_luksformat_options_valid() None[source]

Options set via the luksformat element are passed along to the cryptsetup tool. Only options that are known to the tool should be allowed. Thus this runtime check looks up the provided option names if they exist in the cryptsetup version used on the build host

check_mediacheck_installed() None[source]

If the image description enables the mediacheck attribute the required tools to run this check must be installed on the image build host

check_partuuid_persistency_type_used_with_mbr() None[source]

The devicepersistency setting by-partuuid can only be used in combination with a partition table type that supports UUIDs. In any other case Linux creates artificial values for PTUUID and PARTUUID from the disk signature which can change without touching the actual partition table. We consider this unsafe and only allow the use of by-partuuid in combination with partition tables that actually supports it properly.

check_repositories_configured() None[source]

Verify that there are repositories configured

check_swap_name_used_with_lvm() None[source]

The optional oem-swapname is only effective if used together with the LVM volume manager. A name for the swap space can only be set if it is created as a LVM volume. In any other case the name does not apply to the system

static check_target_directory_not_in_shared_cache(target_dir: str) None[source]

The target directory must be outside of the kiwi shared cache directory in order to avoid busy mounts because kiwi bind mounts the cache directory into the image root tree to access host caching information

Parameters:

target_dir (string) – path name

check_volume_label_used_with_lvm() None[source]

The optional volume label in a systemdisk setup is only effective if the LVM, logical volume manager system is used. In any other case where the filesystem itself offers volume management capabilities there are no extra filesystem labels which can be applied per volume

check_volume_setup_defines_multiple_fullsize_volumes() None[source]

The volume size specification ‘all’ makes this volume to take the rest space available on the system. It’s only allowed to specify one all size volume

check_volume_setup_defines_reserved_labels() None[source]
check_volume_setup_has_no_root_definition() None[source]

The root volume in a systemdisk setup is handled in a special way. It is not allowed to setup a custom name or mountpoint for the root volume. Therefore the size of the root volume can be setup via the @root volume name. This check looks up the volume setup and searches if there is a configuration for the ‘/’ mountpoint which would cause the image build to fail

check_xen_uniquely_setup_as_server_or_guest() None[source]

If the image is classified to be used as Xen image, it can be either a Xen Server(dom0) or a Xen guest. The image configuration is checked if the information uniquely identifies the image as such

class kiwi.runtime_checker.dracut_module_type(package, min_version)

Bases: tuple

min_version: str

Alias for field number 1

package: str

Alias for field number 0

kiwi.runtime_config Module

class kiwi.runtime_config.RuntimeConfig(reread=False)[source]

Bases: object

Implements reading of runtime configuration file:

  1. Check for –config provided from the CLI

  2. ~/.config/kiwi/config.yml

  3. /etc/kiwi.yml

The KIWI runtime configuration file is a yaml formatted file containing information to control the behavior of the tools used by KIWI.

Parameters:

reread (bool) – reread runtime config

get_bundle_compression(default=True)[source]

Return boolean value to express if the image bundle should contain XZ compressed image results or not.

bundle:
  • compress: true|false

If compression of image build results is activated the size of the bundle is smaller and the download speed increases. However the image must be uncompressed before use

If no compression is explicitly configured, the provided default value applies

Parameters:

default (bool) – Default value

Returns:

True or False

Return type:

bool

get_container_compression()[source]

Return compression for container images

container:
  • compress: xz|none|true|false

if no or invalid configuration data is provided, the default compression from the Defaults class is returned

Returns:

True or False

Return type:

bool

get_credentials_verification_metadata_signing_key_file()[source]

Return verification metadata signing key file, used for signature creation of rootfs verification metadata:

credentials:
  • verification_metadata_signing_key_file: …

There is no default value for this setting available

Returns:

file path name or ‘’

Return type:

str

get_disabled_runtime_checks()[source]

Returns disabled runtime checks. Checks can be disabled with:

runtime_checks:
  • disable: check_container_tool_chain_installed

if the provided string does not match any RuntimeChecker method it is just ignored.

get_iso_media_tag_tool() Literal['checkmedia', 'isomd5sum'][source]

Return media tag tool used to checksum iso images

iso:
  • media_tag_tool: checkmedia

if no or invalid configuration exists the default media tagger from the Defaults class is returned

Returns:

A name

Return type:

str

get_iso_tool_category()[source]

Return tool category which should be used to build iso images

iso:
  • tool_category: xorriso

if no or invalid configuration exists the default tool category from the Defaults class is returned

Returns:

A name

Return type:

str

get_mapper_tool()[source]

Return partition mapper tool

mapper:
  • part_mapper: partx

if no configuration exists the default tool from the Defaults class is returned

Returns:

A name

Return type:

str

get_max_size_constraint()[source]

Returns the maximum allowed size of the built image. The value is returned in bytes and it is specified in build_constraints element with the max_size attribute. The value can be specified in bytes or it can be specified with m=MB or g=GB.

build_constraints:
  • max_size: 700m

if no configuration exists None is returned

Returns:

byte value or None

Return type:

int

get_obs_api_credentials()[source]

Return OBS API credentials if configured:

obs:
  • user:
    • user_name: user_credentials

Returns:

List of Dicts with credentials per user

Return type:

list

get_obs_api_server_url()[source]

Return URL of buildservice API server in:

obs:
  • api_url: …

if no configuration exists the API server from the Defaults class is returned

Returns:

URL type data

Return type:

str

get_obs_download_server_url()[source]

Return URL of buildservice download server in:

obs:
  • download_url: …

if no configuration exists the downloadserver from the Defaults class is returned

Returns:

URL type data

Return type:

str

get_oci_archive_tool()[source]

Return OCI archive tool which should be used on creation of container archives for OCI compliant images, e.g docker

oci:
  • archive_tool: umoci

if no configuration exists the default tool from the Defaults class is returned

Returns:

A name

Return type:

str

get_package_changes(default=True)[source]

Return boolean value to express if the image build and bundle should contain a .changes file. The .changes file contains the package changelog information from all packages installed into the image.

bundle:
  • has_package_changes: true|false

By default the creation is switched on. When building in the Open Build Service the default is switched off because obs provides a .report file containing the same information.

Parameters:

default (bool) – Default value

Returns:

True or False

Return type:

bool

get_xz_options()[source]

Return list of XZ compression options in:

xz:
  • options: …

if no configuration exists None is returned

Returns:

Contains list of options

['--option=value']

Return type:

list

is_obs_public()[source]

Check if the buildservice configuration is public or private in:

obs:
  • public: true|false

if no configuration exists we assume to be public

Returns:

True or False

Return type:

bool

kiwi.version Module

Global version information used in kiwi and the package

kiwi.xml_description Module

class kiwi.xml_description.XMLDescription(description: str = '', derived_from: str | None = None)[source]

Bases: object

Implements data management for the image description

Supported description markup languages are XML, YAML, JSON and INI. The provided input file is converted into XML, transformed to the current RelaxNG schema via XSLT and validated against this result.

  • XSLT Style Sheet processing to apply on this version of kiwi

  • Schema Validation based on RelaxNG schema

  • Loading XML data into internal data structures

Attributes

Parameters:
  • description (str) – path to description file

  • derived_from (str) – path to base description file

get_extension_xml_data(namespace_name: str) Any[source]

Return the xml etree parse result for the specified extension namespace

Parameters:

namespace_name (str) – name of the extension namespace

Returns:

result of etree.parse

Return type:

object

load() Any[source]

Read XML description, validate it against the schema and the schematron rules and pass it to the autogenerated(generateDS) parser.

Returns:

instance of XML toplevel domain (image)

Return type:

object

kiwi.xml_state Module

class kiwi.xml_state.ContainerT(name, backend, container_file, fetch_only, fetch_command, load_command)[source]

Bases: NamedTuple

backend: str

Alias for field number 1

container_file: str

Alias for field number 2

fetch_command: Callable

Alias for field number 4

fetch_only: bool

Alias for field number 3

load_command: List[str]

Alias for field number 5

name: str

Alias for field number 0

class kiwi.xml_state.FileT(target, owner, permissions)[source]

Bases: NamedTuple

owner: str

Alias for field number 1

permissions: str

Alias for field number 2

target: str

Alias for field number 0

class kiwi.xml_state.XMLState(xml_data: Any, profiles: List | None = None, build_type: Any | None = None)[source]

Bases: object

Implements methods to get stateful information from the XML data

Parameters:
  • xml_data (object) – parse result from XMLDescription.load()

  • profiles (list) – list of used profiles

  • build_type (object) – build <type> section reference

add_container_config_label(label_name: str, value: str) None[source]

Adds a new label in the containerconfig section, if a label with the same name is already defined in containerconfig it gets overwritten by this method.

Parameters:
  • label_name (str) – the string representing the label name

  • value (str) – the value of the label

add_repository(repo_source: str, repo_type: str, repo_alias: str | None = None, repo_prio: str = '', repo_imageinclude: bool = False, repo_package_gpgcheck: bool | None = None, repo_signing_keys: List[str] = [], components: str | None = None, distribution: str | None = None, repo_gpgcheck: bool | None = None) None[source]

Add a new repository section at the end of the list

Parameters:
  • repo_source (str) – repository URI

  • repo_type (str) – type name defined by schema

  • repo_alias (str) – alias name

  • repo_prio (str) – priority number, package manager specific

  • repo_imageinclude (bool) – setup repository inside of the image

  • repo_package_gpgcheck (bool) – enable/disable package gpg checks

  • repo_signing_keys (list) – list of signing key file names

  • components (str) – component names for debian repos

  • distribution (str) – base distribution name for debian repos

  • repo_gpgcheck (bool) – enable/disable repo gpg checks

btrfs_default_volume_requested() bool[source]

Check if setting a default volume for btrfs is requested

collection_matches_host_architecture(collection: Any) bool[source]

Tests if the given namedcollection section is applicable for the current host architecture. If no architecture is specified within the section it is considered as a match returning True.

Note: The XML section pointer must provide an arch attribute

Parameters:

section – XML section object

Returns:

True or False

Return type:

bool

container_matches_host_architecture(container: Any) bool[source]

Tests if the given container section is applicable for the current host architecture. If no arch attribute is provided in the section it is considered as a match and returns: True.

Parameters:

section – XML section object

Returns:

True or False

Return type:

bool

containers_matches_host_architecture(containers: Any) bool[source]

Tests if the given containers section is applicable for the current host architecture. If no arch attribute is provided in the section it is considered as a match and returns: True.

Parameters:

section – XML section object

Returns:

True or False

Return type:

bool

copy_bootdelete_packages(target_state: Any) None[source]

Copy packages marked as bootdelete to the packages type=delete section in the target xml state

Parameters:

target_state (object) – XMLState instance

copy_bootincluded_archives(target_state: Any) None[source]

Copy archives marked as bootinclude to the packages type=bootstrap section in the target xml state

Parameters:

target_state (object) – XMLState instance

copy_bootincluded_packages(target_state: Any) None[source]

Copy packages marked as bootinclude to the packages type=bootstrap section in the target xml state. The package will also be removed from the packages type=delete section in the target xml state if present there

Parameters:

target_state (object) – XMLState instance

copy_bootloader_section(target_state: Any) None[source]

Copy bootloader section from this xml state to the target xml state

Parameters:

target_state (object) – XMLState instance

copy_build_type_attributes(attribute_names: List, target_state: Any) None[source]

Copy specified attributes from this build type section to the target xml state build type section

Parameters:
  • attribute_names (list) – type section attributes

  • target_state (object) – XMLState instance

copy_displayname(target_state: Any) None[source]

Copy image displayname from this xml state to the target xml state

Parameters:

target_state (object) – XMLState instance

copy_drivers_sections(target_state: Any) None[source]

Copy drivers sections from this xml state to the target xml state

Parameters:

target_state (object) – XMLState instance

copy_machine_section(target_state: Any) None[source]

Copy machine sections from this xml state to the target xml state

Parameters:

target_state (object) – XMLState instance

copy_name(target_state: Any) None[source]

Copy image name from this xml state to the target xml state

Parameters:

target_state (object) – XMLState instance

copy_oemconfig_section(target_state: Any) None[source]

Copy oemconfig sections from this xml state to the target xml state

Parameters:

target_state (object) – XMLState instance

copy_preferences_subsections(section_names: List, target_state: Any) None[source]

Copy subsections of the preferences sections, matching given section names, from this xml state to the target xml state

Parameters:
  • section_names (list) – preferences subsection names

  • target_state (object) – XMLState instance

copy_repository_sections(target_state: Any, wipe: bool = False) None[source]

Copy repository sections from this xml state to the target xml state

Parameters:
  • target_state (object) – XMLState instance

  • wipe (bool) – delete all repos in target prior to copy

copy_strip_sections(target_state: Any) None[source]

Copy strip sections from this xml state to the target xml state

Parameters:

target_state (object) – XMLState instance

copy_systemdisk_section(target_state: Any) None[source]

Copy systemdisk sections from this xml state to the target xml state

Parameters:

target_state (object) – XMLState instance

delete_repository_sections() None[source]

Delete all repository sections matching configured profiles

delete_repository_sections_used_for_build() None[source]

Delete all repository sections used to build the image matching configured profiles

static get_archives_target_dirs(packages_sections_names: List[packages] | None) Dict[source]

Dict of archive names and target dirs for packages section(s), if any :return: archive names and its target dir :rtype: dict

get_bootloader_config_options() List[str][source]

List of custom options used in the bootloader configuration

get_bootloader_install_options() List[str][source]

List of custom options used in the bootloader installation

get_bootloader_options(option_type: str) List[str][source]

List of custom options used in the process to run bootloader setup workloads

get_bootloader_shim_options() List[str][source]

List of custom options used in the process to setup secure boot

get_bootstrap_archives() List[source]

List of archive names from the type=”bootstrap” packages section(s)

Returns:

archive names

Return type:

list

get_bootstrap_archives_target_dirs() Dict[source]

Dict of archive names and target dirs from the type=”bootstrap” packages section(s) :return: archive names and its target dir :rtype: dict

get_bootstrap_collection_type() str[source]

Collection type for packages sections matching type=”bootstrap”

Returns:

collection type name

Return type:

str

get_bootstrap_collections() List[source]

List of collection names from the packages sections matching type=”bootstrap”

Returns:

collection names

Return type:

list

get_bootstrap_files() Dict[str, FileT][source]

List of file names from the type=”bootstrap” packages section(s)

Returns:

file names

Return type:

dict

get_bootstrap_ignore_packages() List[source]

List of ignore package names from the packages sections matching type=”image” and type=build_type

Returns:

package names

Return type:

list

get_bootstrap_package_name() str[source]

bootstrap_package name from type=”bootstrap” packages section

Returns:

bootstrap_package name

Return type:

str

get_bootstrap_packages(plus_packages: List | None = None) List[source]

List of package names from the type=”bootstrap” packages section(s)

The list gets the selected package manager appended if there is a request to install packages inside of the image via a chroot operation

Parameters:

plus_packages (list) – list of additional packages

Returns:

package names

Return type:

list

get_bootstrap_packages_sections() List[source]

List of packages sections matching type=”bootstrap”

Returns:

list of <packages> section reference(s)

Return type:

list

get_bootstrap_products() List[source]

List of product names from the packages sections matching type=”bootstrap”

Returns:

product names

Return type:

list

get_build_type_bootloader_bls() bool[source]

Return bootloader bls setting for selected build type

Returns:

True or False

Return type:

bool

get_build_type_bootloader_console() List[str][source]

Return bootloader console setting for selected build type

Returns:

list of console settings for output (first element) and input (second element)

Return type:

list

get_build_type_bootloader_name() str[source]

Return bootloader name for selected build type

Returns:

bootloader name

Return type:

str

get_build_type_bootloader_section() Any[source]

First bootloader section from the build type section

Returns:

<bootloader> section reference

Return type:

xml_parse::bootloader

get_build_type_bootloader_securelinux_section() List[Any][source]

First securelinux section from the build type bootloader section

Returns:

<securelinux> section reference

Return type:

xml_parse::securelinux

get_build_type_bootloader_serial_line_setup() str | None[source]

Return bootloader serial line setup parameters for the selected build type

Returns:

serial line setup

Return type:

str

get_build_type_bootloader_settings_section() Any[source]

First bootloadersettings section from the build type bootloader section

Returns:

<bootloadersettings> section reference

Return type:

xml_parse::bootloadersettings

get_build_type_bootloader_targettype() str | None[source]

Return bootloader target type setting. Only relevant for the zipl bootloader because zipl is installed differently depending on the storage target it runs later

Returns:

target type string

Return type:

str

get_build_type_bootloader_timeout() str | None[source]

Return bootloader timeout setting for selected build type

Returns:

timeout string

Return type:

str

get_build_type_bootloader_timeout_style() str | None[source]

Return bootloader timeout style setting for selected build type

Returns:

timeout_style string

Return type:

str

get_build_type_bootloader_use_disk_password() bool[source]

Indicate whether the bootloader configuration should use the password protecting the encrypted root volume.

Returns:

True|False

Return type:

bool

get_build_type_bundle_format() str[source]

Return bundle_format for build type

The bundle_format string is validated against the available name tags from kiwi.system.result::result_name_tags.

Returns:

bundle format string

Return type:

str

get_build_type_containerconfig_section() Any[source]

First containerconfig section from the build type section

Returns:

<containerconfig> section reference

Return type:

xml_parse::containerconfig

get_build_type_format_options() Dict[source]

Disk format options returned as a dictionary

Returns:

format options

Return type:

dict

get_build_type_machine_section() Any[source]

First machine section from the build type section

Returns:

<machine> section reference

Return type:

xml_parse::machine

get_build_type_name() str[source]

Default build type name

Returns:

Content of image attribute from build type

Return type:

str

get_build_type_oemconfig_section() Any[source]

First oemconfig section from the build type section

Returns:

<oemconfig> section reference

Return type:

xml_parse::oemconfig

get_build_type_partitions_section() Any[source]

First partitions section from the build type section

Returns:

<partitions> section reference

Return type:

xml_parse::partitions

get_build_type_size(include_unpartitioned: bool = False) size_type | None[source]

Size information from the build type section. If no unit is set the value is treated as mbytes

Parameters:

include_unpartitioned (bool) – sets if the unpartitioned area should be included in the computed size or not

Returns:

mbytes

Return type:

int

get_build_type_spare_part_fs_attributes() List | None[source]

Build type specific list of filesystem attributes applied to the spare partition.

Returns:

list of strings or empty list

Return type:

list

get_build_type_spare_part_size() int | None[source]

Size information for the spare_part size from the build type. If no unit is set the value is treated as mbytes

Returns:

mbytes

Return type:

int

get_build_type_system_disk_section() Any[source]

First system disk section from the build type section

Returns:

<systemdisk> section reference

Return type:

xml_parse::systemdisk

get_build_type_unpartitioned_bytes() int[source]

Size of the unpartitioned area for image in megabytes

Returns:

mbytes

Return type:

int

get_build_type_vagrant_config_section() Any[source]

First vagrantconfig section from the build type section

Returns:

<vagrantconfig> section reference

Return type:

xml_parse::vagrantconfig

get_build_type_vmconfig_entries() List[source]

List of vmconfig-entry section values from the first machine section in the build type section

Returns:

<vmconfig_entry> section reference(s)

Return type:

list

get_build_type_vmdisk_section() Any[source]

First vmdisk section from the first machine section in the build type section

Returns:

<vmdisk> section reference

Return type:

xml_parse::vmdisk

get_build_type_vmdvd_section() Any[source]

First vmdvd section from the first machine section in the build type section

Returns:

<vmdvd> section reference

Return type:

xml_parse::vmdvd

get_build_type_vmnic_entries() List[source]

vmnic section(s) from the first machine section in the build type section

Returns:

list of <vmnic> section reference(s)

Return type:

list

get_collection_modules() Dict[str, List[str]][source]

Dict of collection modules to enable and/or disable

Returns:

Dict of the form:

{
    'enable': [
        "module:stream", "module"
    ],
    'disable': [
        "module"
    ]
}

Return type:

dict

get_collection_type(section_type: str = 'image') str[source]

Collection type from packages sections matching given section type.

If no collection type is specified the default collection type is set to: onlyRequired

Parameters:

section_type (str) – type name from packages section

Returns:

collection type name

Return type:

str

get_collections(section_type: str = 'image') List[source]

List of collection names from the packages sections matching type=section_type and type=build_type

Returns:

collection names

Return type:

list

get_container_config() Dict[source]

Dictionary of containerconfig information

Takes attributes and subsection data from the selected <containerconfig> section and stores it in a dictionary

get_containers() List[ContainerT][source]
get_containers_sections() List[source]

List of all containers sections for the selected profiles that matches the host architecture

Returns:

<containers> section reference(s)

Return type:

list

get_derived_from_image_uri() List[Uri][source]

Uri object(s) of derived image if configured

Specific image types can be based on one ore more derived images. This method returns the location of this image(s) when configured in the XML description

Returns:

List of Uri instances

Return type:

list

get_description_section() description_type[source]

The description section

Returns:

description_type tuple providing the elements author contact and specification

Return type:

tuple

get_disk_start_sector() int[source]

First disk sector number to be used by the first disk partition.

Returns:

number

Return type:

int

get_distribution_name_from_boot_attribute() str[source]

Extract the distribution name from the boot attribute of the build type section.

If no boot attribute is configured or the contents does not match the kiwi defined naming schema for boot image descriptions, an exception is thrown

Returns:

lowercase distribution name

Return type:

str

get_drivers_list() List[source]

List of driver names from all drivers sections matching configured profiles

Returns:

driver names

Return type:

list

get_fs_create_option_list() List[source]

List of root filesystem creation options

The list contains elements with the information from the fscreateoptions attribute string that got split into its substring components

Returns:

list with create options

Return type:

list

get_fs_mount_option_list() List[source]

List of root filesystem mount options

The list contains one element with the information from the fsmountoptions attribute. The value there is passed along to the -o mount option

Returns:

max one element list with mount option string

Return type:

list

get_host_key_certificates() List[Dict[str, List[str]]] | List[Dict[str, str]][source]
get_ignore_packages(section_type: str) List[source]

List of ignore package names from the packages sections matching section_type and type=build_type

Returns:

package names

Return type:

list

get_image_packages_sections() List[source]

List of packages sections matching type=”image”

Returns:

list of <packages> section reference(s)

Return type:

list

get_image_version() str[source]

Image version from preferences section.

Multiple occurences of version in preferences sections are not forbidden, however only the first version found defines the final image version

Returns:

Content of <version> section

Return type:

str

get_include_section_reference_file_names() List[str][source]

List of all <include> section file name references

Returns:

List[str]

Return type:

list

get_initrd_system() str[source]

Name of initrd system to use

Depending on the image type a specific initrd system is either pre selected or free of choice according to the XML type setup.

Returns:

‘dracut’, ‘kiwi’ or ‘none’

Return type:

str

get_installmedia_initrd_modules(action: str) List[str][source]

Gets the list of modules to append in installation initrds

Returns:

a list of dracut module names

Return type:

list

get_locale() List | None[source]

Gets list of locale names if configured. Takes the first locale setup from the existing preferences sections into account.

Returns:

List of names or None

Return type:

list|None

get_luks_credentials() str | None[source]

Return key or passphrase credentials to open the luks pool

Returns:

data

Return type:

str

get_luks_format_options() List[str][source]

Return list of luks format options

Returns:

list of options

Return type:

list

get_oemconfig_oem_multipath_scan() bool[source]

State value to activate multipath maps. Returns a boolean value if specified or False

Returns:

Content of <oem-multipath-scan> section value

Return type:

bool

get_oemconfig_oem_resize() bool[source]

State value to activate/deactivate disk resize. Returns a boolean value if specified or True to set resize on by default

Returns:

Content of <oem-resize> section value

Return type:

bool

get_oemconfig_oem_systemsize() int[source]

State value to retrieve root partition size

Returns:

Content of <oem-systemsize> section value

Return type:

int

get_oemconfig_swap_mbytes() int | None[source]

Return swapsize in MB if requested or None

Operates on the value of oem-swap and if set to true returns the given size or the default value.

Returns:

Content of <oem-swapsize> section value or default

Return type:

int

get_oemconfig_swap_name() str[source]

Return the swap space name

Operates on the value of oem-swapname and if set returns the configured name or the default name: LVSwap

The name of the swap space is used only if the image is configured to use the LVM volume manager. In this case swap is a volume and the volume takes a name. In any other case the given name will have no effect.

Returns:

Content of <oem-swapname> section value or default

Return type:

str

get_package_manager() str[source]

Get configured package manager from selected preferences section

Returns:

Content of the <packagemanager> section

Return type:

str

get_package_sections(packages_sections: List) List[package_type][source]

List of package sections from the given packages sections. Each list element contains a tuple with the <package> section reference and the <packages> section this package belongs to

If a package entry specfies an architecture, it is only taken if the host architecture matches the configured architecture

Parameters:

packages_sections (list) – <packages>

Returns:

Contains list of package_type tuples

[package_type(packages_section=object, package_section=object)]

Return type:

list

get_packages_sections(section_types: List) List[source]

List of packages sections matching given section type(s)

Parameters:

section_types (list) – type name(s) from packages sections

Returns:

list of <packages> section reference(s)

Return type:

list

get_partitions() Dict[str, ptable_entry_type][source]

Dictionary of configured partitions.

Each entry in the dict references a ptable_entry_type Each key in the dict references the name of the partition entry as handled by KIWI

Returns:

Contains dict of ptable_entry_type tuples

{
    'NAME': ptable_entry_type(
        mbsize=int,
        clone=int,
        partition_name=str,
        partition_type=str,
        mountpoint=str,
        filesystem=str
    )
}

Return type:

dict

get_preferences_sections() List[source]

All preferences sections for the selected profiles that match the host architecture

Returns:

list of <preferences> section reference(s)

Return type:

list

get_products(section_type: str = 'image') List[source]

List of product names from the packages sections matching type=section_type and type=build_type

Parameters:

section_type (str) – type name from packages section

Returns:

product names

Return type:

list

get_release_version() str[source]

Get configured release version from selected preferences section

Returns:

Content of the <release-version> section or ‘’

Return type:

str

get_repositories_signing_keys() List[str][source]

Get list of signing keys specified on the repositories

get_repository_sections() List[source]

List of all repository sections for the selected profiles that matches the host architecture

Returns:

<repository> section reference(s)

Return type:

list

get_repository_sections_used_for_build() List[source]

List of all repositorys sections used to build the image and matching configured profiles.

Returns:

<repository> section reference(s)

Return type:

list

get_repository_sections_used_in_image() List[source]

List of all repositorys sections to be configured in the resulting image matching configured profiles.

Returns:

<repository> section reference(s)

Return type:

list

get_root_filesystem_uuid() str | None[source]

Return preserved UUID

get_root_partition_uuid() str | None[source]

Return preserved PARTUUID

get_rpm_check_signatures() bool[source]

Gets the rpm-check-signatures configuration flag. Returns False if not present.

Returns:

True or False

Return type:

bool

get_rpm_excludedocs() bool[source]

Gets the rpm-excludedocs configuration flag. Returns False if not present.

Returns:

True or False

Return type:

bool

get_rpm_locale() List | None[source]

Gets list of locale names to filter out by rpm if rpm-locale-filtering is switched on the the list always contains: [POSIX, C, C.UTF-8] and is extended by the optionaly configured locale

Returns:

List of names or None

Return type:

list|None

get_rpm_locale_filtering() bool[source]

Gets the rpm-locale-filtering configuration flag. Returns False if not present.

Returns:

True or False

Return type:

bool

get_strip_files_to_delete() List[source]

Items to delete from strip section

Returns:

item names

Return type:

list

get_strip_libraries_to_keep() List[source]

Libraries to keep from strip section

Returns:

librarie names

Return type:

list

get_strip_list(section_type: str) List[source]

List of strip names matching the given section type and profiles

Parameters:

section_type (str) – type name from packages section

Returns:

strip names

Return type:

list

get_strip_tools_to_keep() List[source]

Tools to keep from strip section

Returns:

tool names

Return type:

list

get_system_archives() List[source]

List of archive names from the packages sections matching type=”image” and type=build_type

Returns:

archive names

Return type:

list

get_system_archives_target_dirs() Dict[source]

Dict of archive names and its target dir from the packages sections matching type=”image” and type=build_type :return: archive names and its target dir :rtype: dict

get_system_collection_type() str[source]

Collection type for packages sections matching type=”image”

Returns:

collection type name

Return type:

str

get_system_collections() List[source]

List of collection names from the packages sections matching type=”image”

Returns:

collection names

Return type:

list

get_system_files() Dict[str, FileT][source]

List of file names from the packages sections matching type=”image” and type=build_type

Returns:

file names

Return type:

dict

get_system_files_ignore_packages() List[str][source]

List of ignore package names from the type=”systemfiles” packages section(s)

Returns:

package names

Return type:

list

get_system_ignore_packages() List[source]

List of ignore package names from the packages sections matching type=”image” and type=build_type

Returns:

package names

Return type:

list

get_system_packages() List[source]

List of package names from the packages sections matching type=”image” and type=build_type

Returns:

package names

Return type:

list

get_system_products() List[source]

List of product names from the packages sections matching type=”image”

Returns:

product names

Return type:

list

get_to_become_deleted_packages(force: bool = True) List[source]

List of package names from the type=”delete” or type=”uninstall” packages section(s)

Parameters:

force (bool) – return “delete” type if True, “uninstall” type otherwise

Returns:

package names

Return type:

list

get_user_groups(user_name) List[str][source]

List of group names matching specified user

Each entry in the list is the name of a group and optionally its group ID separated by a colon, that the specified user belongs to. The first item in the list is the login or primary group. The list will be empty if no groups are specified in the description file.

Returns:

groups data for the given user

Return type:

list

get_users() List[source]

List of configured users.

Each entry in the list is a single xml_parse::user instance.

Returns:

list of <user> section reference(s)

Return type:

list

get_users_sections() List[source]

All users sections for the selected profiles

Returns:

list of <users> section reference(s)

Return type:

list

get_vagrant_config_virtualbox_guest_additions() bool[source]

Attribute virtualbox_guest_additions_present from the first vagrantconfig section.

Returns:

True|False

Return type:

bool

get_volume_group_name() str[source]

Volume group name from selected <systemdisk> section

Returns:

volume group name

Return type:

str

get_volume_management() str | None[source]

Provides information which volume management system is used

Returns:

name of volume manager

Return type:

str

get_volumes() List[volume_type][source]

List of configured systemdisk volumes.

Each entry in the list is a tuple with the following information

  • name: name of the volume

  • size: size of the volume

  • realpath: system path to lookup volume data. If no mountpoint is set the volume name is used as data path.

  • mountpoint: volume mount point and volume data path

  • fullsize: takes all space True|False

  • attributes: list of volume attributes handled via chattr

Returns:

Contains list of volume_type tuples

[
    volume_type(
        name=volume_name,
        parent=volume_parent,
        size=volume_size,
        realpath=path,
        mountpoint=path,
        fullsize=True,
        label=volume_label,
        attributes=['no-copy-on-write'],
        is_root_volume=True|False
    )
]

Return type:

list

is_xen_guest() bool[source]

Check if build type setup specifies a Xen Guest (domX) The check is based on the architecture, the firmware and xen_loader configuration values:

  • We only support Xen setup on the x86_64 architecture

  • Firmware pointing to ec2 means the image is targeted to run in Amazon EC2 which is a Xen guest

  • Machine setup with a xen_loader attribute also indicates a Xen guest target

Returns:

True or False

Return type:

bool

is_xen_server() bool[source]

Check if build type domain setup specifies a Xen Server (dom0)

Returns:

True or False

Return type:

bool

package_matches_host_architecture(package: Any) bool[source]

Tests if the given package section is applicable for the current host architecture. If no architecture is specified within the section it is considered as a match returning True.

Note: The XML section pointer must provide an arch attribute

Parameters:

section – XML section object

Returns:

True or False

Return type:

bool

preferences_matches_host_architecture(preferences: Any) bool[source]

Tests if the given preferences section is applicable for the current host architecture. If no architecture is specified within the section it is considered as a match returning True.

Note: The XML section pointer must provide an arch attribute

Parameters:

section – XML section object

Returns:

True or False

Return type:

bool

profile_matches_host_architecture(profile: Any) bool[source]

Tests if the given profile section is applicable for the current host architecture. If no architecture is specified within the section it is considered as a match returning True.

Note: The XML section pointer must provide an arch attribute

Parameters:

section – XML section object

Returns:

True or False

Return type:

bool

repository_matches_host_architecture(repository: Any) bool[source]

Tests if the given repository section is applicable for the current host architecture. If no architecture is specified within the section it is considered as a match returning True.

Note: The XML section pointer must provide an arch attribute

Parameters:

section – XML section object

Returns:

True or False

Return type:

bool

resolve_this_path() None[source]

Resolve any this:// repo source path into the path representing the target inside of the image description directory

set_container_config_tag(tag: str) None[source]

Set new tag name in containerconfig section

In order to set a new tag value an existing containerconfig and tag setup is required

Parameters:

tag (str) – tag name

set_derived_from_image_uri(uri: str) None[source]

Set derived_from attribute to a new value

In order to set a new value the derived_from attribute must be already present in the image configuration

Parameters:

uri (str) – URI

set_repository(repo_source: str, repo_type: str, repo_alias: str, repo_prio: str, repo_imageinclude: bool = False, repo_package_gpgcheck: bool | None = None, repo_signing_keys: List[str] = [], components: str | None = None, distribution: str | None = None, repo_gpgcheck: bool | None = None) None[source]

Overwrite repository data of the first repository

Parameters:
  • repo_source (str) – repository URI

  • repo_type (str) – type name defined by schema

  • repo_alias (str) – alias name

  • repo_prio (str) – priority number, package manager specific

  • repo_imageinclude (bool) – setup repository inside of the image

  • repo_package_gpgcheck (bool) – enable/disable package gpg checks

  • repo_signing_keys (list) – list of signing key file names

  • components (str) – component names for debian repos

  • distribution (str) – base distribution name for debian repos

  • repo_gpgcheck (bool) – enable/disable repo gpg checks

set_root_filesystem_uuid(uuid: str) None[source]

Store UUID provided in uuid as state information

Parameters:

uuid (str) – UUID

set_root_partition_uuid(uuid: str) None[source]

Store PARTUUID provided in uuid as state information

Parameters:

uuid (str) – PARTUUID

volume_matches_host_architecture(volume: Any) bool[source]

Tests if the given volume section is applicable for the current host architecture. If no architecture is specified within the section it is considered as a match returning True.

Note: The XML section pointer must provide an arch attribute

Parameters:

section – XML section object

Returns:

True or False

Return type:

bool

class kiwi.xml_state.description_type(author, contact, specification)

Bases: tuple

author: str

Alias for field number 0

contact: str

Alias for field number 1

specification: str

Alias for field number 2

class kiwi.xml_state.package_type(packages_section, package_section)

Bases: tuple

package_section: package

Alias for field number 1

packages_section: packages

Alias for field number 0

class kiwi.xml_state.size_type(mbytes, additive)

Bases: tuple

additive: str

Alias for field number 1

mbytes: int

Alias for field number 0

class kiwi.xml_state.volume_type(name, parent, size, realpath, mountpoint, fullsize, label, attributes, is_root_volume)

Bases: tuple

attributes: list

Alias for field number 7

fullsize: bool

Alias for field number 5

is_root_volume: bool

Alias for field number 8

label: str | None

Alias for field number 6

mountpoint: str | None

Alias for field number 4

name: str

Alias for field number 0

parent: str

Alias for field number 1

realpath: str

Alias for field number 3

size: str

Alias for field number 2

Module Contents