kiwi.package_manager Package

Submodules

kiwi.package_manager.base Module

class kiwi.package_manager.base.PackageManagerBase(repository: RepositoryBase, custom_args: List = [], release_version: str = '')[source]

Bases: object

Implements base class for Package Management

Parameters:
  • repository (object) – instance of Repository

  • root_dir (str) – root directory path name

  • package_requests (list) – list of packages to install or delete

  • collection_requests (list) – list of collections to install

  • product_requests (list) – list of products to install

clean_leftovers() None[source]

Cleans package manager related data not needed in the resulting image such as custom macros

Implementation in specialized package manager class

cleanup_requests() None[source]

Cleanup request queues

database_consistent() None[source]
dump_reload_package_database(version: int = 45) None[source]
get_error_details() str[source]

Provide further error details

In case the package manager call failed this method will return package manager specific error information if there is any

Returns:

further error data as str or empty str

Return type:

str

static has_failed(returncode: int) bool[source]

Evaluate given result return code

Any returncode != 0 is considered an error unless overwritten in specialized package manager class

Parameters:

returncode (int) – return code number

Returns:

True|False

Return type:

boolean

match_package_deleted(package_name: str, package_manager_output: str) bool[source]

Match expression to indicate a package has been deleted

Implementation in specialized package manager class

Parameters:
  • package_name (str) – unused

  • package_manager_output (str) – unused

Returns:

True|False

Return type:

bool

match_package_installed(package_name: str, package_manager_output: str) bool[source]

Match expression to indicate a package has been installed

Implementation in specialized package manager class

Parameters:
  • package_name (str) – unused

  • package_manager_output (str) – unused

Returns:

True|False

Return type:

bool

post_init(custom_args: List = []) None[source]

Post initialization method

Implementation in specialized package manager class

Parameters:

custom_args (list) – unused

post_process_delete_requests(root_bind: RootBind | None = None) None[source]

Process extra code required after deleting packages

Implementation in specialized package manager class

post_process_install_requests_bootstrap(root_bind: RootBind | None = None, delta_root: bool = False) None[source]

Process extra code required after bootstrapping

Implementation in specialized package manager class

process_delete_requests(force: bool = False) CommandCallT[source]

Process package delete requests (chroot)

Implementation in specialized package manager class

Parameters:

force (bool) – unused

process_install_requests() CommandCallT[source]

Process package install requests for image phase (chroot)

Implementation in specialized package manager class

process_install_requests_bootstrap(root_bind: RootBind | None = None, bootstrap_package: str | None = None) CommandCallT[source]

Process package install requests for bootstrap phase (no chroot)

Implementation in specialized package manager class

process_only_required() None[source]

Setup package processing only for required packages

Implementation in specialized package manager class

Setup package processing to also include recommended dependencies

Implementation in specialized package manager class

request_collection(name: str) None[source]

Queue a package collection

Implementation in specialized package manager class

Parameters:

name (str) – unused

request_package(name: str) None[source]

Queue a package request

Implementation in specialized package manager class

Parameters:

name (str) – unused

request_package_exclusion(name: str) None[source]

Queue a package exclusion(skip) request

Implementation in specialized package manager class

Parameters:

name (str) – unused

request_package_lock(name: str) None[source]
request_product(name: str) None[source]

Queue a product request

Implementation in specialized package manager class

Parameters:

name (str) – unused

setup_repository_modules(collection_modules: Dict[str, List[str]]) None[source]

Setup repository modules and streams

Implementation in specialized package manager class

Parameters:

collection_modules (dict) – unused

update() CommandCallT[source]

Process package update requests (chroot)

Implementation in specialized package manager class

kiwi.package_manager.dnf4 Module

class kiwi.package_manager.dnf4.PackageManagerDnf4(repository: RepositoryBase, custom_args: List = [], release_version: str = '')[source]

Bases: PackageManagerBase

*Implements base class for installation/deletion of packages and collections using dnf*

Parameters:
  • dnf_args (doct) – dnf arguments from repository runtime configuration

  • command_env (dict) – dnf command environment from repository runtime configuration

clean_leftovers() None[source]

Cleans package manager related data not needed in the resulting image such as custom macros

match_package_deleted(package_name: str, package_manager_output: str) bool[source]

Match expression to indicate a package has been deleted

Parameters:
  • package_name (str) – package_name

  • package_manager_output (str) – dnf status line

Returns:

True|False

Return type:

bool

match_package_installed(package_name: str, package_manager_output: str) bool[source]

Match expression to indicate a package has been installed

This match for the package to be installed in the output of the dnf command is not 100% accurate. There might be false positives due to sub package names starting with the same base package name

Parameters:
  • package_name (str) – package_name

  • package_manager_output (str) – dnf status line

Returns:

True|False

Return type:

bool

post_init(custom_args: List = []) None[source]

Post initialization method

Parameters:

custom_args (list) – custom dnf arguments

post_process_install_requests_bootstrap(root_bind: RootBind | None = None, delta_root: bool = False) None[source]

Move the rpm database to the place as it is expected by the rpm package installed during bootstrap phase

Parameters:
  • root_bind (object) – unused

  • delta_root (bool) – unused

process_delete_requests(force: bool = False) CommandCallT[source]

Process package delete requests (chroot)

Parameters:

force (bool) – force deletion: true|false

Raises:

KiwiRequestError – if none of the packages to delete is installed.

Returns:

process results in command type

Return type:

namedtuple

process_install_requests() CommandCallT[source]

Process package install requests for image phase (chroot)

Returns:

process results in command type

Return type:

namedtuple

process_install_requests_bootstrap(root_bind: RootBind | None = None, bootstrap_package: str | None = None) CommandCallT[source]

Process package install requests for bootstrap phase (no chroot)

Parameters:
  • root_bind (object) – unused

  • bootstrap_package (str) – unused

Returns:

process results in command type

Return type:

namedtuple

process_only_required() None[source]

Setup package processing only for required packages

Setup package processing to also include recommended dependencies.

request_collection(name: str) None[source]

Queue a collection request

Parameters:

name (str) – dnf group ID name

request_package(name: str) None[source]

Queue a package request

Parameters:

name (str) – package name

request_package_exclusion(name: str) None[source]

Queue a package exclusion(skip) request

Parameters:

name (str) – package name

request_product(name: str) None[source]

Queue a product request

There is no product definition in the fedora repo data

Parameters:

name (str) – unused

setup_repository_modules(collection_modules: Dict[str, List[str]]) None[source]

Setup repository modules and streams

Parameters:

collection_modules (dict) –

Expect dict of the form:

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

update() CommandCallT[source]

Process package update requests (chroot)

Returns:

process results in command type

Return type:

namedtuple

kiwi.package_manager.zypper Module

class kiwi.package_manager.zypper.PackageManagerZypper(repository: RepositoryBase, custom_args: List = [], release_version: str = '')[source]

Bases: PackageManagerBase

Implements Installation/Deletion of packages/collections with zypper

Parameters:
  • zypper_args (list) – zypper arguments from repository runtime configuration

  • command_env (dict) – zypper command environment from repository runtime configuration

clean_leftovers() None[source]

Cleans package manager related data not needed in the resulting image such as custom macros

static has_failed(returncode: int) bool[source]

Evaluate given result return code

In zypper any return code == 0 or >= 100 is considered success. Any return code different from 0 and < 100 is treated as an error we care for. Return codes >= 100 indicates an issue like ‘new kernel needs reboot of the system’ or similar which we don’t care in the scope of image building

Parameters:

returncode (int) – return code number

Returns:

True|False

Return type:

boolean

match_package_deleted(package_name: str, package_manager_output: str) bool[source]

Match expression to indicate a package has been deleted

Parameters:
  • package_name (str) – package_name

  • package_manager_output (str) – zypper status line

Returns:

True|False

Return type:

bool

match_package_installed(package_name: str, package_manager_output: str) bool[source]

Match expression to indicate a package has been installed

This match for the package to be installed in the output of the zypper command is not 100% accurate. There might be false positives due to sub package names starting with the same base package name

Parameters:
  • package_name (str) – package_name

  • package_manager_output (str) – zypper status line

Returns:

True|False

Return type:

bool

post_init(custom_args: List = []) None[source]

Post initialization method

Store custom zypper arguments

Parameters:

custom_args (list) – custom zypper arguments

post_process_install_requests_bootstrap(root_bind: RootBind | None = None, delta_root: bool = False) None[source]

Move the rpm database to the place as it is expected by the rpm package installed during bootstrap phase

Parameters:
  • root_bind (object) – unused

  • delta_root (bool) – unused

process_delete_requests(force: bool = False) CommandCallT[source]

Process package delete requests (chroot)

Parameters:

force (bool) – force deletion: true|false

Raises:

KiwiRequestError – if none of the packages to delete is installed

Returns:

process results in command type

Return type:

namedtuple

process_install_requests() CommandCallT[source]

Process package install requests for image phase (chroot)

Returns:

process results in command type

Return type:

namedtuple

process_install_requests_bootstrap(root_bind: RootBind | None = None, bootstrap_package: str | None = None) CommandCallT[source]

Process package install requests for bootstrap phase (no chroot)

Parameters:
  • root_bind (object) – unused

  • bootstrap_package (str) – unused

Returns:

process results in command type

Return type:

namedtuple

process_only_required() None[source]

Setup package processing only for required packages

Setup package processing to also include recommended dependencies.

request_collection(name: str) None[source]

Queue a collection request

Parameters:

name (str) – zypper pattern name

request_package(name: str) None[source]

Queue a package request

Parameters:

name (str) – package name

request_package_exclusion(name: str) None[source]

Queue a package exclusion(skip) request

Parameters:

name (str) – package name

request_product(name: str) None[source]

Queue a product request

Parameters:

name (str) – zypper product name

setup_repository_modules(collection_modules: Dict[str, List[str]]) None[source]

Repository modules not supported for zypper. The method does nothing in this scope

Parameters:

collection_modules (dict) – unused

update() CommandCallT[source]

Process package update requests (chroot)

Returns:

process results in command type

Return type:

namedtuple

Module Contents

class kiwi.package_manager.PackageManager[source]

Bases: object

Package manager factory

Parameters:
  • repository (object) – instance of Repository

  • package_manager (str) – package manager name

  • custom_args (list) – custom package manager arguments list

Raises:

KiwiPackageManagerSetupError – if the requested package manager type is not supported

Returns:

package manager

Return type:

PackageManagerBase subclass

static new(repository: object, package_manager_name: str, custom_args: List = [], release_version: str = '')[source]