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.

are_repos_configured()

Returns true when notify_repos_configured() was already called (by user or automatically)

enable_disable_plugins(plugin_names, enable)

Adds a request to enable/disable plugins that match the names (glob patterns) in the list. Can be called multiple times. Requests (plugin_names and enable state) are queued. The enable state of a plugin is set according to the last matching request. Must be called before the Base::setup. :type plugin_names: std::vector< std::string,std::allocator< std::string > > :param plugin_names: Plugin names (glob patterns) to enable/disable :type enable: boolean :param enable: Request: true - enable plugins, false - disable plugins :raises: libdnf5::UserAssertionError When called after Base::setup

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_plugins_info()
Return type:

std::vector< libdnf5::plugin::PluginInfo,std::allocator< libdnf5::plugin::PluginInfo > >

Returns:

a list of information about plugins found during Base::setup

Raises:

libdnf5::UserAssertionError When called before Base::setup

get_repo_sack()
get_rpm_package_sack()
get_transaction_history()

Warning: This method is experimental/unstable and should not be relied on. It may be removed without warning

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 already called

load_config()

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

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()”.

notify_repos_configured()

Notifies the libdnf5 library that the repositories are configured. It can be called before load_repos. The libdnf5 library can then call plugins that can make final adjustments to the repositories configuration. In the case that it has not been called, it is called automatically at the beginning of the load_repos method. Calling the method for the second time result in throwing an exception.

set_download_callbacks(download_callbacks)
setup()

Loads libdnf plugins, vars from environment, varsdirs and installroot (releasever, arch) and resolves configuration of protected_packages (glob:). 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 and vars are updated, application plugins applied their pre configuration modification in configuration, but before repositories are loaded or any Package or Advisory query created. The method is recommended to be called before loading repositories, because not all variables for substitutions might be available. Caution - modification of vars after this call might be problematic, because architecture is already fixed for our solver. 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.