Skip to content

Commit

Permalink
transaction_callbacks: Deprecate libnf5::rpm::TransactionItem alias
Browse files Browse the repository at this point in the history
Given that there is another TransactionItem class in
libdnf5::transaction namespace, the alias libnf5::rpm::TransactionItem ->
libdnf5::base::TransactionPackage is confusing and does not add any
value to the user.
This patch deprecates it and uses directly TransactionPackage in all
places.
  • Loading branch information
m-blaha authored and ppisar committed Sep 13, 2024
1 parent 13293cf commit cb76d52
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 103 deletions.
14 changes: 7 additions & 7 deletions dnf5-plugins/automatic_plugin/transaction_callbacks_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void TransactionCallbacksSimple::transaction_start([[maybe_unused]] uint64_t tot


void TransactionCallbacksSimple::install_start(
const libdnf5::rpm::TransactionItem & item, [[maybe_unused]] uint64_t total) {
const libdnf5::base::TransactionPackage & item, [[maybe_unused]] uint64_t total) {
switch (item.get_action()) {
case libdnf5::transaction::TransactionItemAction::UPGRADE:
output_stream << " Upgrading ";
Expand Down Expand Up @@ -66,7 +66,7 @@ void TransactionCallbacksSimple::install_start(
}

void TransactionCallbacksSimple::uninstall_start(
const libdnf5::rpm::TransactionItem & item, [[maybe_unused]] uint64_t total) {
const libdnf5::base::TransactionPackage & item, [[maybe_unused]] uint64_t total) {
if (item.get_action() == libdnf5::transaction::TransactionItemAction::REMOVE) {
output_stream << " Erasing ";
} else {
Expand All @@ -75,16 +75,16 @@ void TransactionCallbacksSimple::uninstall_start(
output_stream << item.get_package().get_full_nevra() << std::endl;
}

void TransactionCallbacksSimple::unpack_error(const libdnf5::rpm::TransactionItem & item) {
void TransactionCallbacksSimple::unpack_error(const libdnf5::base::TransactionPackage & item) {
output_stream << " Unpack error: " << item.get_package().get_full_nevra() << std::endl;
}

void TransactionCallbacksSimple::cpio_error(const libdnf5::rpm::TransactionItem & item) {
void TransactionCallbacksSimple::cpio_error(const libdnf5::base::TransactionPackage & item) {
output_stream << " Cpio error: " << item.get_package().get_full_nevra() << std::endl;
}

void TransactionCallbacksSimple::script_error(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) {
Expand All @@ -93,15 +93,15 @@ void TransactionCallbacksSimple::script_error(
}

void TransactionCallbacksSimple::script_start(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type) {
output_stream << " Running " << script_type_to_string(type) << " scriptlet: " << to_full_nevra_string(nevra)
<< std::endl;
}

void TransactionCallbacksSimple::script_stop(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
[[maybe_unused]] uint64_t return_code) {
Expand Down
14 changes: 7 additions & 7 deletions dnf5-plugins/automatic_plugin/transaction_callbacks_simple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ class TransactionCallbacksSimple : public libdnf5::rpm::TransactionCallbacks {
output_stream(output_stream) {}

void transaction_start(uint64_t total) override;
void install_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) override;
void uninstall_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) override;
void unpack_error(const libdnf5::rpm::TransactionItem & item) override;
void cpio_error(const libdnf5::rpm::TransactionItem & item) override;
void install_start(const libdnf5::base::TransactionPackage & item, uint64_t total) override;
void uninstall_start(const libdnf5::base::TransactionPackage & item, uint64_t total) override;
void unpack_error(const libdnf5::base::TransactionPackage & item) override;
void cpio_error(const libdnf5::base::TransactionPackage & item) override;
void script_error(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) override;
void script_start(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type) override;
void script_stop(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
[[maybe_unused]] uint64_t return_code) override;
Expand Down
2 changes: 1 addition & 1 deletion dnf5/commands/offline/offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class PlymouthTransCB : public RpmTransCB {
public:
PlymouthTransCB(Context & context, PlymouthOutput plymouth) : RpmTransCB(context), plymouth(std::move(plymouth)) {}
void elem_progress(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
[[maybe_unused]] uint64_t amount,
[[maybe_unused]] uint64_t total) override {
RpmTransCB::elem_progress(item, amount, total);
Expand Down
24 changes: 12 additions & 12 deletions dnf5/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,14 @@ libdnf5::cli::progressbar::MultiProgressBar * RpmTransCB::get_multi_progress_bar
}

void RpmTransCB::install_progress(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item, uint64_t amount, [[maybe_unused]] uint64_t total) {
[[maybe_unused]] const libdnf5::base::TransactionPackage & item, uint64_t amount, [[maybe_unused]] uint64_t total) {
active_progress_bar->set_ticks(static_cast<int64_t>(amount));
if (is_time_to_print()) {
multi_progress_bar.print();
}
}

void RpmTransCB::install_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) {
void RpmTransCB::install_start(const libdnf5::base::TransactionPackage & item, uint64_t total) {
const char * msg{nullptr};
switch (item.get_action()) {
case libdnf5::transaction::TransactionItemAction::UPGRADE:
Expand Down Expand Up @@ -798,7 +798,7 @@ void RpmTransCB::install_start(const libdnf5::rpm::TransactionItem & item, uint6
}

void RpmTransCB::install_stop(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
[[maybe_unused]] uint64_t amount,
[[maybe_unused]] uint64_t total) {
multi_progress_bar.print();
Expand All @@ -821,14 +821,14 @@ void RpmTransCB::transaction_stop([[maybe_unused]] uint64_t total) {
}

void RpmTransCB::uninstall_progress(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item, uint64_t amount, [[maybe_unused]] uint64_t total) {
[[maybe_unused]] const libdnf5::base::TransactionPackage & item, uint64_t amount, [[maybe_unused]] uint64_t total) {
active_progress_bar->set_ticks(static_cast<int64_t>(amount));
if (is_time_to_print()) {
multi_progress_bar.print();
}
}

void RpmTransCB::uninstall_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) {
void RpmTransCB::uninstall_start(const libdnf5::base::TransactionPackage & item, uint64_t total) {
const char * msg{nullptr};
if (item.get_action() == libdnf5::transaction::TransactionItemAction::REMOVE ||
item.get_action() == libdnf5::transaction::TransactionItemAction::REPLACED) {
Expand All @@ -841,21 +841,21 @@ void RpmTransCB::uninstall_start(const libdnf5::rpm::TransactionItem & item, uin
}

void RpmTransCB::uninstall_stop(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
[[maybe_unused]] uint64_t amount,
[[maybe_unused]] uint64_t total) {
multi_progress_bar.print();
}


void RpmTransCB::unpack_error(const libdnf5::rpm::TransactionItem & item) {
void RpmTransCB::unpack_error(const libdnf5::base::TransactionPackage & item) {
active_progress_bar->add_message(
libdnf5::cli::progressbar::MessageType::ERROR, "Unpack error: " + item.get_package().get_full_nevra());
active_progress_bar->set_state(libdnf5::cli::progressbar::ProgressBarState::ERROR);
multi_progress_bar.print();
}

void RpmTransCB::cpio_error(const libdnf5::rpm::TransactionItem & item) {
void RpmTransCB::cpio_error(const libdnf5::base::TransactionPackage & item) {
active_progress_bar->add_message(
libdnf5::cli::progressbar::MessageType::ERROR, "Cpio error: " + item.get_package().get_full_nevra());
active_progress_bar->set_state(libdnf5::cli::progressbar::ProgressBarState::ERROR);
Expand All @@ -874,7 +874,7 @@ void RpmTransCB::script_output_to_progress(const libdnf5::cli::progressbar::Mess
}

void RpmTransCB::script_error(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) {
Expand All @@ -890,7 +890,7 @@ void RpmTransCB::script_error(
}

void RpmTransCB::script_start(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type) {
active_progress_bar->add_message(
Expand All @@ -900,7 +900,7 @@ void RpmTransCB::script_start(
}

void RpmTransCB::script_stop(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) {
Expand Down Expand Up @@ -929,7 +929,7 @@ void RpmTransCB::script_stop(
}

void RpmTransCB::elem_progress(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
[[maybe_unused]] uint64_t amount,
[[maybe_unused]] uint64_t total) {
//std::cout << "Element progress: " << header.get_full_nevra() << " " << amount << '/' << total << std::endl;
Expand Down
24 changes: 12 additions & 12 deletions dnf5/include/dnf5/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ class DNF_API RpmTransCB : public libdnf5::rpm::TransactionCallbacks {
libdnf5::cli::progressbar::MultiProgressBar * get_multi_progress_bar();

void install_progress(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
uint64_t amount,
[[maybe_unused]] uint64_t total) override;

void install_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) override;
void install_start(const libdnf5::base::TransactionPackage & item, uint64_t total) override;
void install_stop(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
[[maybe_unused]] uint64_t amount,
[[maybe_unused]] uint64_t total) override;

Expand All @@ -216,41 +216,41 @@ class DNF_API RpmTransCB : public libdnf5::rpm::TransactionCallbacks {
void transaction_stop([[maybe_unused]] uint64_t total) override;

void uninstall_progress(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
uint64_t amount,
[[maybe_unused]] uint64_t total) override;

void uninstall_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) override;
void uninstall_start(const libdnf5::base::TransactionPackage & item, uint64_t total) override;

void uninstall_stop(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
[[maybe_unused]] uint64_t amount,
[[maybe_unused]] uint64_t total) override;


void unpack_error(const libdnf5::rpm::TransactionItem & item) override;
void unpack_error(const libdnf5::base::TransactionPackage & item) override;

void cpio_error(const libdnf5::rpm::TransactionItem & item) override;
void cpio_error(const libdnf5::base::TransactionPackage & item) override;

void script_error(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) override;

void script_start(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type) override;

void script_stop(
[[maybe_unused]] const libdnf5::rpm::TransactionItem * item,
[[maybe_unused]] const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
[[maybe_unused]] uint64_t return_code) override;

void elem_progress(
[[maybe_unused]] const libdnf5::rpm::TransactionItem & item,
[[maybe_unused]] const libdnf5::base::TransactionPackage & item,
[[maybe_unused]] uint64_t amount,
[[maybe_unused]] uint64_t total) override;

Expand Down
18 changes: 10 additions & 8 deletions dnf5daemon-server/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void DbusTransactionCB::after_complete(bool success) {
}
}

void DbusTransactionCB::install_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) {
void DbusTransactionCB::install_start(const libdnf5::base::TransactionPackage & item, uint64_t total) {
try {
dnfdaemon::RpmTransactionItemActions action;
action = dnfdaemon::transaction_package_to_action(item);
Expand All @@ -159,7 +159,8 @@ void DbusTransactionCB::install_start(const libdnf5::rpm::TransactionItem & item
}
}

void DbusTransactionCB::install_progress(const libdnf5::rpm::TransactionItem & item, uint64_t amount, uint64_t total) {
void DbusTransactionCB::install_progress(
const libdnf5::base::TransactionPackage & item, uint64_t amount, uint64_t total) {
try {
if (is_time_to_print()) {
auto signal = create_signal_pkg(
Expand All @@ -174,7 +175,8 @@ void DbusTransactionCB::install_progress(const libdnf5::rpm::TransactionItem & i
}
}

void DbusTransactionCB::install_stop(const libdnf5::rpm::TransactionItem & item, uint64_t /*amount*/, uint64_t total) {
void DbusTransactionCB::install_stop(
const libdnf5::base::TransactionPackage & item, uint64_t /*amount*/, uint64_t total) {
try {
auto signal = create_signal_pkg(
dnfdaemon::INTERFACE_RPM, dnfdaemon::SIGNAL_TRANSACTION_ACTION_STOP, item.get_package().get_full_nevra());
Expand All @@ -186,7 +188,7 @@ void DbusTransactionCB::install_stop(const libdnf5::rpm::TransactionItem & item,


void DbusTransactionCB::script_start(
const libdnf5::rpm::TransactionItem * /*item*/,
const libdnf5::base::TransactionPackage * /*item*/,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type) {
try {
Expand All @@ -199,7 +201,7 @@ void DbusTransactionCB::script_start(
}

void DbusTransactionCB::script_stop(
const libdnf5::rpm::TransactionItem * /*item*/,
const libdnf5::base::TransactionPackage * /*item*/,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) {
Expand All @@ -213,7 +215,7 @@ void DbusTransactionCB::script_stop(
}
}

void DbusTransactionCB::elem_progress(const libdnf5::rpm::TransactionItem & item, uint64_t amount, uint64_t total) {
void DbusTransactionCB::elem_progress(const libdnf5::base::TransactionPackage & item, uint64_t amount, uint64_t total) {
try {
auto signal = create_signal_pkg(
dnfdaemon::INTERFACE_RPM, dnfdaemon::SIGNAL_TRANSACTION_ELEM_PROGRESS, item.get_package().get_full_nevra());
Expand All @@ -225,7 +227,7 @@ void DbusTransactionCB::elem_progress(const libdnf5::rpm::TransactionItem & item
}

void DbusTransactionCB::script_error(
const libdnf5::rpm::TransactionItem * /*item*/,
const libdnf5::base::TransactionPackage * /*item*/,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) {
Expand Down Expand Up @@ -298,7 +300,7 @@ void DbusTransactionCB::verify_stop(uint64_t total) {
}


void DbusTransactionCB::unpack_error(const libdnf5::rpm::TransactionItem & item) {
void DbusTransactionCB::unpack_error(const libdnf5::base::TransactionPackage & item) {
try {
auto signal = create_signal_pkg(
dnfdaemon::INTERFACE_RPM, dnfdaemon::SIGNAL_TRANSACTION_UNPACK_ERROR, item.get_package().get_full_nevra());
Expand Down
24 changes: 12 additions & 12 deletions dnf5daemon-server/callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,44 +103,44 @@ class DbusTransactionCB : public libdnf5::rpm::TransactionCallbacks, public Dbus
void transaction_stop(uint64_t total) override;

// install a package
void install_start(const libdnf5::rpm::TransactionItem & item, uint64_t) override;
void install_progress(const libdnf5::rpm::TransactionItem & item, uint64_t amount, uint64_t total) override;
void install_stop(const libdnf5::rpm::TransactionItem & item, uint64_t amount, uint64_t total) override;
void install_start(const libdnf5::base::TransactionPackage & item, uint64_t) override;
void install_progress(const libdnf5::base::TransactionPackage & item, uint64_t amount, uint64_t total) override;
void install_stop(const libdnf5::base::TransactionPackage & item, uint64_t amount, uint64_t total) override;

// uninstall a package (the same messages as for install are used)
void uninstall_start(const libdnf5::rpm::TransactionItem & item, uint64_t total) override {
void uninstall_start(const libdnf5::base::TransactionPackage & item, uint64_t total) override {
install_start(item, total);
}
void uninstall_progress(const libdnf5::rpm::TransactionItem & item, uint64_t amount, uint64_t total) override {
void uninstall_progress(const libdnf5::base::TransactionPackage & item, uint64_t amount, uint64_t total) override {
install_progress(item, amount, total);
}
void uninstall_stop(const libdnf5::rpm::TransactionItem & item, uint64_t amount, uint64_t total) override {
void uninstall_stop(const libdnf5::base::TransactionPackage & item, uint64_t amount, uint64_t total) override {
install_stop(item, amount, total);
}

void script_start(
const libdnf5::rpm::TransactionItem * item,
const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type) override;
void script_stop(
const libdnf5::rpm::TransactionItem * item,
const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) override;
void script_error(
const libdnf5::rpm::TransactionItem * item,
const libdnf5::base::TransactionPackage * item,
libdnf5::rpm::Nevra nevra,
libdnf5::rpm::TransactionCallbacks::ScriptType type,
uint64_t return_code) override;

void elem_progress(const libdnf5::rpm::TransactionItem & item, uint64_t amount, uint64_t total) override;
void elem_progress(const libdnf5::base::TransactionPackage & item, uint64_t amount, uint64_t total) override;

void verify_start(uint64_t total) override;
void verify_progress(uint64_t amount, uint64_t total) override;
void verify_stop(uint64_t total) override;

void unpack_error(const libdnf5::rpm::TransactionItem & item) override;
void cpio_error(const libdnf5::rpm::TransactionItem & /*item*/) override{};
void unpack_error(const libdnf5::base::TransactionPackage & item) override;
void cpio_error(const libdnf5::base::TransactionPackage & /*item*/) override{};

// whole rpm transaction is finished
void finish();
Expand Down
Loading

0 comments on commit cb76d52

Please sign in to comment.