class Transaction

Public Types

enum class TransactionRunResult

enum representing Transaction run result


enumerator SUCCESS
enumerator ERROR_RERUN
enumerator ERROR_RESOLVE
enumerator ERROR_LOCK
enumerator ERROR_CHECK
enumerator ERROR_RPM_RUN
enumerator ERROR_GPG_CHECK

Public Functions

Transaction(const Transaction &transaction)
Transaction(Transaction &&transaction)
libdnf5::GoalProblem get_problems()

Return basic overview about result of resolving transaction. To get complete information, use get_resolve_logs().

const std::vector<libdnf5::base::LogEvent> &get_resolve_logs() const

Returns information about resolvement of Goal.


A vector of LogEvent instances.

std::vector<std::string> get_resolve_logs_as_strings() const

Returns information about resolvement of Goal as a list of printable messages


A vector of string representations of problems.

std::vector<libdnf5::base::TransactionPackage> get_transaction_packages() const

the transaction packages.

std::size_t get_transaction_packages_count() const

the number of transaction packages.

std::vector<libdnf5::base::TransactionGroup> &get_transaction_groups() const

the transaction groups.

std::vector<libdnf5::base::TransactionModule> &get_transaction_modules() const

the transaction modules.

std::vector<libdnf5::base::TransactionEnvironment> &get_transaction_environments() const

environmental groups that are part of the transaction.

std::vector<libdnf5::rpm::Package> get_broken_dependency_packages() const

list of packages skipped due to broken dependencies

std::vector<libdnf5::rpm::Package> get_conflicting_packages() const

list of packages skipped due to conflicts

bool empty() const

true if the transaction is empty.

void download()

Download all inbound packages (packages that are being installed on the system). Fails immediately on the first package download failure. Will try to resume downloads of any partially-downloaded RPMs.

The destination directory for downloaded RPMs is taken from the destdir configuration option. If it’s not specified, the standard location of repo cachedir/packages is used.

TransactionRunResult test()

Check the transaction by running it with RPMTRANS_FLAG_TEST. The import of any necessary public keys will be requested, and transaction checks will be performed, but no changes to the installed package set will be made. These checks are performed automatically by run(); it is redundant to call test() before calling run().


An enum describing the result of the transaction

TransactionRunResult run()

Prepare, check and run the transaction.

All the transaction metadata that was set (description, user_id or comment) is stored in the history database.

To watch progress or trigger actions during specific transactions events, setup the callbacks object.

After a successful transaction, any temporarily downloaded packages are removed if the ‘keepcache’ option is set to ‘false’ and the transaction involved an inbound action. Otherwise, the packages are preserved on the disk.


An enum describing the result of running the transaction.

void set_callbacks(std::unique_ptr<libdnf5::rpm::TransactionCallbacks> &&callbacks)

Setup callbacks to be called during rpm transaction.


callbacks – Implemented callbacks object.

void set_description(const std::string &description)

Setup a description of the transaction.


description – Value could be the console command for CLI or verbose description for API usage.

void set_user_id(const uint32_t user_id)

Setup the id of the user that started the transaction. If not set, current login user UID is used.


user_id – UID value.

void set_comment(const std::string &comment)

Setup a comment to store in the history database along with the transaction.


comment – Any string value.

std::vector<std::string> get_transaction_problems() const noexcept

Retrieve list of problems that occurred during transaction run attempt.

bool check_gpg_signatures()

Check signatures of packages in the resolved transaction.


True if all packages have correct signatures or checking is turned off with gpgcheck option, otherwise false. More info about occurred problems can be retrieved using the get_gpg_signature_problems method.

std::vector<std::string> get_gpg_signature_problems() const noexcept

Retrieve a list of the problems that occurred during check_gpg_signatures procedure.

std::string serialize(const std::filesystem::path &packages_path = "", const std::filesystem::path &comps_path = "") const


This method is experimental/unstable and should not be relied on. It may be removed without warning Serialize the transaction into a json data format which can be later loaded into a libdnf5::Goal and replayed. If packages_path is provided it is assumed all packages in this transaction are present there and the serialized transaction contains paths those packages. The same applies for comps paths (they can be stored using the store_comps method).

void store_comps(const std::filesystem::path &comps_path) const


This method is experimental/unstable and should not be relied on. It may be removed without warning Store each group and environment in this transaction as a separate xml file in the specified path.

Public Static Functions

static std::string transaction_result_to_string(const TransactionRunResult result)

Return string representation of the TransactionRunResult enum.


friend class libdnf5::Goal
class TransactionError : public libdnf5::Error

Error related to processing transaction.

Public Functions

inline virtual const char *get_domain_name() const noexcept override

Error class’ domain name”

inline virtual const char *get_name() const noexcept override

Error class’ name”

template<AllowedErrorArgTypes... Args>
inline explicit Error(BgettextMessage format, Args... args)

A constructor that supports formatting the error message.

  • format – The format string for the message.

  • args – The format arguments.

Error(const Error &e) noexcept