kiwi.system Package

Submodules

kiwi.system.identifier Module

class kiwi.system.identifier.SystemIdentifier[source]

Bases: object

Create a random ID to identify the system. The information is used to create the mbrid file as an example

Attributes

  • image_id
    Hex identifier string
calculate_id()[source]

Calculate random hex id

Using 4 tuples of rand in range from 1..0xfe

get_id()[source]

Current hex identifier

Returns:hex id
Return type:string
write(filename)[source]

Write current hex identifier to file

Parameters:filename (string) – file path name
write_to_disk(device_provider)[source]

Write current hex identifier to MBR at offset 0x1b8 on disk

Parameters:device_provider (object) – Instance based on DeviceProvider

kiwi.system.kernel Module

class kiwi.system.kernel.Kernel(root_dir)[source]

Bases: object

Implementes kernel lookup and extraction from given root tree

Attributes

  • root_dir
    root directory path name
  • kernel_names
    list of kernel names to search for functions.sh::suseStripKernel() provides a normalized file so that we do not have to search for many different names in this code
copy_kernel(target_dir, file_name=None)[source]

Copy kernel to specified target

If no file_name is given the target filename is set as kernel-<kernel.version>.kernel

Parameters:
  • target_dir (string) – target path name
  • filename (string) – base filename in target
copy_xen_hypervisor(target_dir, file_name=None)[source]

Copy xen hypervisor to specified target

If no file_name is given the target filename is set as hypervisor-<xen.name>

Parameters:
  • target_dir (string) – target path name
  • filename (string) – base filename in target
get_kernel(raise_on_not_found=False)[source]

Lookup kernel files and provide filename and version

Returns:tuple with filename, kernelname and version
Return type:namedtuple
get_xen_hypervisor()[source]

Lookup xen hypervisor and provide filename and hypervisor name

Returns:tuple with filename and hypervisor name
Return type:namedtuple

kiwi.system.prepare Module

class kiwi.system.prepare.SystemPrepare(xml_state, root_dir, allow_existing=False)[source]

Bases: object

Implements preparation and installation of a new root system

Attributes

  • xml_state
    Instance of XMLState
  • profiles
    list of configured profiles
  • root_bind
    Instance of RootBind
  • uri_list
    A list of Uri references
delete_packages(manager, packages, force=False)[source]

Delete one or more packages using the package manager inside of the new root directory

Parameters:
  • manager (object) – PackageManager
  • packages (list) – package list
  • force (bool) – force deletion true|false
install_bootstrap(manager)[source]

Install system software using the package manager from the host, also known as bootstrapping

install_packages(manager, packages)[source]

Install one or more packages using the package manager inside of the new root directory

Parameters:
  • manager (object) – PackageManager
  • packages (list) – package list
install_system(manager)[source]

Install system software using the package manager inside of the new root directory. This is done via a chroot operation and requires the desired package manager to became installed via the bootstrap phase

Parameters:manager (object) – PackageManager
pinch_system(manager, force=False)[source]

Delete packages marked for deletion in the XML description

Parameters:
  • manager (object) – PackageManager
  • force (bool) – force deletion true|false
setup_repositories()[source]

Set up repositories for software installation and return a package manager for performing software installation tasks

Returns:Instance of PackageManager
Return type:PackageManager
update_system(manager)[source]

Install package updates from the used repositories. the process uses the package manager from inside of the new root directory

Parameters:manager (object) – PackageManager

kiwi.system.profile Module

class kiwi.system.profile.Profile(xml_state)[source]

Bases: object

Create bash readable .profile environment from the XML description. The information is used by the kiwi first boot code.

Attributes

  • xml_state
    Instance of XMLState
  • dot_profile
    profile dictionary
add(key, value)[source]

Add key/value pair to profile dictionary

Parameters:
  • key (string) – profile key
  • value (string) – profile value
create()[source]

Create bash quoted profile

Returns:profile dump for bash
Return type:string
delete(key)[source]

kiwi.system.result Module

class kiwi.system.result.Result(xml_state)[source]

Bases: object

Collect image building results

Attributes

  • result_files
    List of result files
  • class_version
    Result class version
  • xml_state
    Instance of XMLState
add(key, filename, use_for_bundle=True, compress=False, shasum=True)[source]

Add result tuple to result_files list

Parameters:
  • key (string) – name
  • filename (string) – file path name
  • use_for_bundle (boot) – use when bundling results true|false
  • compress (bool) – compress when bundling true|false
  • shasum (bool) – create shasum when bundling true|false
dump(filename)[source]

Picke dump this instance to a file

Parameters:filename (string) – file path name
get_results()[source]

Current list of result tuples

classmethod load(filename)[source]

Load pickle dumped filename into a Result instance

Parameters:filename (string) – file path name
print_results()[source]

Print results human readable

class kiwi.system.result.result_file_type(filename, use_for_bundle, compress, shasum)

Bases: tuple

compress

Alias for field number 2

filename

Alias for field number 0

shasum

Alias for field number 3

use_for_bundle

Alias for field number 1

kiwi.system.root_bind Module

class kiwi.system.root_bind.RootBind(root_init)[source]

Bases: object

Implements binding/copying of host system paths into the new root directory

Attributes

  • root_dir
    root directory path name
  • cleanup_files
    list of files to cleanup, delete
  • mount_stack
    list of mounted directories for cleanup
  • dir_stack
    list of directories for cleanup
  • config_files
    list of initial config files
  • bind_locations
    list of kernel filesystems to bind mount
  • shared_location
    shared directory between image root and build system root
cleanup()[source]

Cleanup mounted locations, directories and intermediate config files

mount_kernel_file_systems()[source]

Bind mount kernel filesystems

mount_shared_directory(host_dir=None)[source]

Bind mount shared location

The shared location is a directory which shares data from the image buildsystem host with the image root system. It is used for the repository setup and the package manager cache to allow chroot operations without being forced to duplicate this data

move_to_root(elements)[source]

Change the given path elements to a new root directory

Parameters:elements (list) – list of path names
Returns:changed elements
Return type:list
setup_intermediate_config()[source]

Create intermediate config files

Some config files e.g etc/hosts needs to be temporarly copied from the buildsystem host to the image root system in order to allow e.g DNS resolution in the way as it is configured on the buildsystem host. These config files only exists during the image build process and are not part of the final image

kiwi.system.root_init Module

class kiwi.system.root_init.RootInit(root_dir, allow_existing=False)[source]

Bases: object

Implements creation of new root directory for a linux system. Host system independent static default files and device nodes are created to initialize a new base system

Attributes

  • root_dir
    root directory path name
create()[source]

Create new system root directory

The method creates a temporary directory and initializes it for the purpose of building a system image from it. This includes the following setup:

  • create static core device nodes
  • create core system paths

On success the contents of the temporary location are synced to the specified root_dir and the temporary location will be deleted. That way we never work on an incomplete initial setup

delete()[source]

Force delete root directory and its contents

kiwi.system.setup Module

class kiwi.system.setup.SystemSetup(xml_state, root_dir)[source]

Bases: object

Implementation of system setup steps supported by kiwi. kiwi is not responsible for the system configuration, however some setup steps needs to be performed in order to provide a minimal work environment inside of the image according to the desired image type.

Attributes

  • arch
    platform.machine The 32bit x86 platform is handled as ‘ix86’
  • xml_state
    Instance of XMLState
  • description_dir
    path to image description directory
  • derived_description_dir
    path to derived_description_dir boot image descriptions inherits data from the system image description, thus they are derived from another image description directory which is needed to e.g find system image archives, overlay files
  • root_dir
    root directory path name
call_config_script()[source]

Call config.sh script chrooted

call_edit_boot_config_script(filesystem, boot_part_id)[source]

Call configured editbootconfig script _NON_ chrooted

Pass the boot filesystem name and the partition number of the boot partition as parameters to the call

Parameters:
  • filesystem (string) – boot filesystem name
  • boot_part_id (int) – boot partition number
call_edit_boot_install_script(diskname, boot_device_node)[source]

Call configured editbootinstall script _NON_ chrooted

Pass the disk file name and the device node of the boot partition as parameters to the call

Parameters:
  • diskname (string) – file path name
  • boot_device_node (string) – boot device node name
call_image_script()[source]

Call images.sh script chrooted

cleanup()[source]

Delete all traces of a kiwi description which are not required in the later image

create_fstab(entries)[source]

Create etc/fstab from given list of entries

kiwi boot images provides the linuxrc script, however the kernel also expects an init executable to be present. This method creates a hard link to the linuxrc file

create_recovery_archive()[source]

Create a compressed recovery archive from the root tree for use with kiwi’s recvoery system. The method creates additional data into the image root filesystem which is deleted prior to the creation of a new recovery data set

export_modprobe_setup(target_root_dir)[source]

Export etc/modprobe.d to given root_dir

Parameters:target_root_dir (string) – path name
export_rpm_package_list(target_dir)[source]

Export image rpm package list as metadata reference used by the open buildservice

Parameters:target_dir (string) – path name
export_rpm_package_verification(target_dir)[source]

Export rpm package verification result as metadata reference used by the open buildservice

Parameters:target_dir (string) – path name
import_description()[source]

Import XML descriptions, custom scripts, archives and script helper methods

import_image_identifier()[source]

Create etc/ImageID identifier file

import_overlay_files(follow_links=False, preserve_owner_group=False)[source]

Copy overlay files from the image description to the image root tree. Supported are a root/ directory or a root.tar.gz tarball. The root/ directory takes precedence over the tarball

Parameters:
  • follow_links (bool) – follow symlinks true|false
  • preserve_owner_group (bool) – preserve permissions true|false
import_repositories_marked_as_imageinclude()[source]

Those <repository> sections which are marked with the imageinclude attribute should be permanently added to the image repository configuration

import_shell_environment(profile)[source]

Create profile environment to let scripts consume information from the XML description.

Parameters:profile (object) – Instance of Profile
set_selinux_file_contexts(security_context_file)[source]

Initialize the security context fields (extended attributes) on the files matching the security_context_file

Parameters:security_context_file (string) – path file name
setup_groups()[source]

Add groups for configured users

setup_hardware_clock()[source]

Setup etc/adjtime by running hwclock

setup_keyboard_map()[source]

Setup etc/sysconfig/keyboard console keyboard

setup_locale()[source]

Setup etc/sysconfig/language UTF8 locale

setup_timezone()[source]

Setup timezone symlink

setup_users()[source]

Add/Modify configured users

kiwi.system.shell Module

class kiwi.system.shell.Shell[source]

Bases: object

Special character handling for shell evaluated code

classmethod quote(message)[source]

Quote characters which have a special meaning for bash but should be used as normal characters. actually I had planned to use pipes.quote but it does not quote as I had expected it. e.g ‘name_wit_a_$’ does not quote the $ so we do it on our own for the scope of kiwi

Parameters:message (string) – message text
Returns:quoted text
Return type:string
classmethod quote_key_value_file(filename)[source]

Quote given input file which has to be of the form key=value to be able to become sourced by the shell

Parameters:filename (string) – file path name
Returns:quoted text
Return type:string
classmethod run_common_function(name, parameters)[source]

Run a function implemented in boot/functions.sh

Parameters:
  • name (string) – function name
  • parameters (list) – function arguments

kiwi.system.size Module

class kiwi.system.size.SystemSize(source_dir)[source]

Bases: object

Provide source tree size information

Attributes

  • source_dir
    source directory path name
accumulate_files()[source]

Calculate sum of all files in the source tree

Returns:number of files
Return type:int
accumulate_mbyte_file_sizes()[source]

Calculate data size of all data in the source tree

Returns:mbytes
Return type:int
customize(size, requested_filesystem)[source]

Increase the sum of all file sizes by an empiric factor

Each filesystem has some overhead it needs to manage itself. Thus the plain data size is always smaller as the size of the container which embeds it. This method increases the given size by a filesystem specific empiric factor to ensure the given data size can be stored in a filesystem of the customized size

Parameters:
  • size (int) – mbsize to update
  • requested_filesystem (string) – filesystem name
Returns:

mbytes

Return type:

int

kiwi.system.uri Module

class kiwi.system.uri.Uri(uri, repo_type=None)[source]

Bases: object

Normalize url types available in a kiwi configuration into standard mime types.

Attributes

  • repo_type
    Repository type name. Only needed if the uri is not enough to determine the repository type e.g for yast2 vs. rpm-md obs repositories
  • uri
    URI, repository location, file
  • repo_type
    repository type name, rpm-dir, rpm-md, yast2
  • mount_stack
    list of mounted locations
  • remote_uri_types
    dictionary of remote uri type names
  • local_uri_type
    dictionary of local uri type names
alias()[source]

Create hexdigest from URI as alias

If the repository definition from the XML description does not provide an alias, kiwi creates one for you. However it’s better to assign a human readable alias in the XML configuration

Returns:alias name as hexdigest
Return type:string
credentials_file_name()[source]

Filename to store repository credentials

get_fragment()[source]

Returns the fragment part of the URI.

is_remote()[source]

Check if URI is a remote or local location

Return type:bool
translate()[source]

Translate repository location according to their URI type

Depending on the URI type the provided location needs to be adapted e.g loop mounted in case of an ISO or updated by the service URL in case of an open buildservice project name

kiwi.system.users Module

class kiwi.system.users.Users(root_dir)[source]

Bases: object

Operations on users and groups in a root directory

Attributes

  • root_dir
    root directory path name
group_add(group_name, options)[source]

Add group with options

Parameters:
  • group_name (string) – group name
  • options (list) – groupadd options
group_exists(group_name)[source]

Check if group exists

Parameters:group_name (string) – group name
Return type:bool
setup_home_for_user(user_name, group_name, home_path)[source]

Setup user home directory

Parameters:
  • user_name (string) – user name
  • group_name (string) – group name
  • home_path (string) – path name
user_add(user_name, options)[source]

Add user with options

Parameters:
  • user_name (string) – user name
  • options (list) – useradd options
user_exists(user_name)[source]

Check if user exists

Parameters:user_name (string) – user name
Return type:bool
user_modify(user_name, options)[source]

Modify user with options

Parameters:
  • user_name (string) – user name
  • options (list) – usermod options

Module Contents