Skip to content

Commit

Permalink
modules: Report problems with switching module streams
Browse files Browse the repository at this point in the history
  • Loading branch information
pkratoch committed Mar 22, 2024
1 parent 31ee76e commit bb2a4de
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/libdnf5/base/goal_elements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ enum class GoalProblem : uint32_t {
/// Problem with latest modules during resolvement of module dependencies
MODULE_SOLVER_ERROR_LATEST = (1 << 19),
/// Error detected during resolvement of module dependencies
MODULE_SOLVER_ERROR = (1 << 20)
MODULE_SOLVER_ERROR = (1 << 20),
MODULE_CANNOT_SWITH_STREAMS = (1 << 21)
};

/// Types of Goal actions
Expand Down
18 changes: 18 additions & 0 deletions libdnf5/base/goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2319,6 +2319,24 @@ base::Transaction Goal::resolve() {

module::ModuleSack & module_sack = *p_impl->base->get_module_sack();
ret |= p_impl->add_module_specs_to_goal(transaction);

// Check for switched module streams
if (!p_impl->base->get_config().get_module_stream_switch_option().get_value()) {
auto switched_streams = module_sack.p_impl->module_db->get_all_newly_switched_streams();
if (!switched_streams.empty()) {
for (auto item : switched_streams) {
transaction.p_impl->add_resolve_log(
GoalAction::ENABLE,
GoalProblem::MODULE_CANNOT_SWITH_STREAMS,
GoalJobSettings(),
libdnf5::transaction::TransactionItemType::MODULE,
item.first,
{"0:" + item.second.first, "1:" + item.second.second},
libdnf5::Logger::Level::ERROR);
}
ret |= GoalProblem::MODULE_CANNOT_SWITH_STREAMS;
}
}
// Resolve modules
auto result = module_sack.resolve_active_module_items();
auto module_solver_problems = result.first;
Expand Down
20 changes: 20 additions & 0 deletions libdnf5/base/log_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,26 @@ std::string LogEvent::to_string(
ret.append(utils::sformat(_("Modular dependency problems with the defaults:\n")));
return ret.append(solver_problems->to_string());
}
case GoalProblem::MODULE_CANNOT_SWITH_STREAMS: {
std::string original_stream;
std::string new_stream;
for (const auto & module_stream : additional_data) {
const auto pos = module_stream.find(":");
if (module_stream.substr(0, pos) == "0") {
original_stream = module_stream.substr(pos + 1);
} else {
new_stream = module_stream.substr(pos + 1);
}
}
ret.append(utils::sformat(
_("The operation would result in switching of module '{0}' stream '{1}' to stream '{2}'\n"),
*spec,
original_stream,
new_stream));
return ret.append(
_("Error: It is not possible to switch enabled streams of a module unless explicitly enabled via "
"configuration option module_stream_switch."));
}
}
return ret;
}
Expand Down

0 comments on commit bb2a4de

Please sign in to comment.