diff --git a/dnf5-plugins/automatic_plugin/transaction_callbacks_simple.cpp b/dnf5-plugins/automatic_plugin/transaction_callbacks_simple.cpp index bce0223f07..1dc8d99e45 100644 --- a/dnf5-plugins/automatic_plugin/transaction_callbacks_simple.cpp +++ b/dnf5-plugins/automatic_plugin/transaction_callbacks_simple.cpp @@ -54,6 +54,7 @@ void TransactionCallbacksSimple::install_start( case libdnf5::transaction::TransactionItemAction::ENABLE: case libdnf5::transaction::TransactionItemAction::DISABLE: case libdnf5::transaction::TransactionItemAction::RESET: + case libdnf5::transaction::TransactionItemAction::SWITCH: auto & logger = *context.base.get_logger(); logger.warning( "Unexpected action in TransactionPackage: {}", diff --git a/dnf5/context.cpp b/dnf5/context.cpp index ea15430965..8dd8db4255 100644 --- a/dnf5/context.cpp +++ b/dnf5/context.cpp @@ -235,6 +235,7 @@ class RpmTransCB : public libdnf5::rpm::TransactionCallbacks { case libdnf5::transaction::TransactionItemAction::ENABLE: case libdnf5::transaction::TransactionItemAction::DISABLE: case libdnf5::transaction::TransactionItemAction::RESET: + case libdnf5::transaction::TransactionItemAction::SWITCH: auto & logger = *context.base.get_logger(); logger.warning( "Unexpected action in TransactionPackage: {}", diff --git a/dnf5daemon-server/transaction.cpp b/dnf5daemon-server/transaction.cpp index 547f2068a1..859f39e3fb 100644 --- a/dnf5daemon-server/transaction.cpp +++ b/dnf5daemon-server/transaction.cpp @@ -44,6 +44,7 @@ RpmTransactionItemActions transaction_package_to_action(const libdnf5::base::Tra case libdnf5::base::TransactionPackage::Action::ENABLE: case libdnf5::base::TransactionPackage::Action::DISABLE: case libdnf5::base::TransactionPackage::Action::RESET: + case libdnf5::base::TransactionPackage::Action::SWITCH: // TODO(lukash) handle cases libdnf_throw_assertion( "Unexpected action in RpmTransactionItem: {}", diff --git a/include/libdnf5-cli/output/transaction_table.hpp b/include/libdnf5-cli/output/transaction_table.hpp index 3f902e9ca4..0fa289e154 100644 --- a/include/libdnf5-cli/output/transaction_table.hpp +++ b/include/libdnf5-cli/output/transaction_table.hpp @@ -50,6 +50,7 @@ static const char * action_color(libdnf5::transaction::TransactionItemAction act case libdnf5::transaction::TransactionItemAction::REINSTALL: case libdnf5::transaction::TransactionItemAction::REASON_CHANGE: case libdnf5::transaction::TransactionItemAction::ENABLE: + case libdnf5::transaction::TransactionItemAction::SWITCH: return "green"; case libdnf5::transaction::TransactionItemAction::DOWNGRADE: case libdnf5::transaction::TransactionItemAction::RESET: @@ -121,6 +122,7 @@ class ActionHeaderPrinter { case libdnf5::transaction::TransactionItemAction::ENABLE: case libdnf5::transaction::TransactionItemAction::DISABLE: case libdnf5::transaction::TransactionItemAction::RESET: + case libdnf5::transaction::TransactionItemAction::SWITCH: libdnf_throw_assertion( "Unexpected action in print_transaction_table: {}", libdnf5::utils::to_underlying(action)); } @@ -271,6 +273,9 @@ class ActionHeaderPrinterModule { case libdnf5::transaction::TransactionItemAction::RESET: text = "Resetting modules"; break; + case libdnf5::transaction::TransactionItemAction::SWITCH: + text = "Switching module streams"; + break; default: libdnf_throw_assertion( "Unexpected action in print_transaction_table: {}", libdnf5::utils::to_underlying(action)); @@ -323,6 +328,7 @@ class TransactionSummary { case libdnf5::transaction::TransactionItemAction::ENABLE: case libdnf5::transaction::TransactionItemAction::DISABLE: case libdnf5::transaction::TransactionItemAction::RESET: + case libdnf5::transaction::TransactionItemAction::SWITCH: // Only package change counts are reported. break; } diff --git a/include/libdnf5/transaction/transaction_item_action.hpp b/include/libdnf5/transaction/transaction_item_action.hpp index ab15a08a91..2265e81f85 100644 --- a/include/libdnf5/transaction/transaction_item_action.hpp +++ b/include/libdnf5/transaction/transaction_item_action.hpp @@ -42,7 +42,8 @@ enum class TransactionItemAction : int { REASON_CHANGE = 7, // a package is being kept on the system but its reason is changing ENABLE = 8, // module enable DISABLE = 9, // module disable - RESET = 10 // module reset + RESET = 10, // module reset + SWITCH = 11 // module switch }; diff --git a/libdnf5/base/transaction.cpp b/libdnf5/base/transaction.cpp index dc0df9f5ce..d541c9d49d 100644 --- a/libdnf5/base/transaction.cpp +++ b/libdnf5/base/transaction.cpp @@ -474,6 +474,15 @@ void Transaction::Impl::set_transaction( name, "", "", transaction::TransactionItemAction::RESET, transaction::TransactionItemReason::USER); modules.emplace_back(std::move(tsmodule)); } + for (auto & name_streams : module_db->get_all_newly_switched_streams()) { + TransactionModule tsmodule( + name_streams.first, + name_streams.second.second, + name_streams.second.first, + transaction::TransactionItemAction::SWITCH, + transaction::TransactionItemReason::USER); + modules.emplace_back(std::move(tsmodule)); + } // Add reason change actions to the transaction for (auto & [pkg, reason, group_id] : solved_goal.list_reason_changes()) { diff --git a/libdnf5/rpm/transaction.cpp b/libdnf5/rpm/transaction.cpp index e5ce31e43a..a4e8053c49 100644 --- a/libdnf5/rpm/transaction.cpp +++ b/libdnf5/rpm/transaction.cpp @@ -190,6 +190,7 @@ void Transaction::fill(const base::Transaction & transaction) { case libdnf5::transaction::TransactionItemAction::ENABLE: case libdnf5::transaction::TransactionItemAction::DISABLE: case libdnf5::transaction::TransactionItemAction::RESET: + case libdnf5::transaction::TransactionItemAction::SWITCH: break; } } diff --git a/libdnf5/transaction/transaction_item_action.cpp b/libdnf5/transaction/transaction_item_action.cpp index 737986fdc0..114816f4f2 100644 --- a/libdnf5/transaction/transaction_item_action.cpp +++ b/libdnf5/transaction/transaction_item_action.cpp @@ -50,6 +50,8 @@ std::string transaction_item_action_to_string(TransactionItemAction action) { return "Disable"; case TransactionItemAction::RESET: return "Reset"; + case TransactionItemAction::SWITCH: + return "Switch"; } return ""; } @@ -76,6 +78,8 @@ TransactionItemAction transaction_item_action_from_string(const std::string & ac return TransactionItemAction::DISABLE; } else if (action == "Reset") { return TransactionItemAction::RESET; + } else if (action == "Switch") { + return TransactionItemAction::SWITCH; } throw InvalidTransactionItemAction(action); @@ -104,6 +108,7 @@ std::string transaction_item_action_to_letter(TransactionItemAction action) { case TransactionItemAction::ENABLE: case TransactionItemAction::DISABLE: case TransactionItemAction::RESET: + case TransactionItemAction::SWITCH: // TODO(pkratoch): Add letters for ENABLE, DISABLE and RESET return ""; }