Base

class libdnf5.base.Base(*args)

Instances of libdnf5::Base are the central point of functionality supplied by libdnf5. An application will typically create a single instance of this class which it will keep for the run-time needed to accomplish its packaging tasks. Base instances are stateful objects owning various data.

get_comps()
get_config()
Return type:

ConfigMain

Returns:

a reference to configuration

get_download_callbacks()
static get_locked_base()

Returns a pointer to a locked “Base” instance or “nullptr” if no instance is locked.

get_logger()
get_module_sack()
get_repo_sack()
get_rpm_package_sack()
get_transaction_history()
get_vars()

Gets base variables. They can be used in configuration files. Syntax in the config - ${var_name} or $var_name.

get_weak_ptr()
is_initialized()

Returns true when setup() (mandatory method in many workflows) was alredy called

load_config()

Loads main configuration. The file defined in the current configuration and files in the drop-in directories are used.

load_config_from_file()

Deprecated: It is redundant. It calls load_config(). Loads main configuration.

lock()

Sets the pointer to the locked instance “Base” to “this” instance. Blocks if the pointer is already set. Pointer to a locked “Base” instance can be obtained using “get_locked_base()”.

set_download_callbacks(download_callbacks)
setup()

Loads libdnf plugins, vars from environment, varsdirs and installroot (releasever, arch). To prevent differences between configuration and internal Base settings, following configurations will be locked: installroot, varsdir. The method is supposed to be called after configuration is updated, application plugins applied their pre configuration modification in configuration, but before repositories are loaded or any Package or Advisory query created. Calling the method for the second time result in throwing an exception

thisown
unlock()

Resets the pointer to a locked “Base” instance to “nullptr”. Throws an exception if another or no instance is locked.

with_config_file_path(func)

Deprecated: Don’t use it! It will be removed in Fedora 40. It was intended for internal use only. Call a function that loads the config file, catching errors appropriately