dnf5: Support --installed-from-repo= for swap

This commit is contained in:
Jaroslav Rohel 2025-07-14 15:00:26 +02:00
parent 6d7a798446
commit beb04fab89
3 changed files with 6 additions and 1 deletions

View File

@ -71,6 +71,7 @@ void SwapCommand::set_argument_parser() {
allow_erasing = std::make_unique<AllowErasingOption>(*this);
create_installed_from_repo_option(*this, installed_from_repos, true);
create_from_repo_option(*this, from_repos, true);
create_offline_option(*this);
@ -87,9 +88,10 @@ void SwapCommand::run() {
auto goal = get_context().get_goal();
goal->set_allow_erasing(allow_erasing->get_value());
auto settings = libdnf5::GoalJobSettings();
settings.set_from_repo_ids(installed_from_repos);
settings.set_to_repo_ids(from_repos);
goal->add_install(install_pkg_spec, settings);
goal->add_rpm_remove(remove_pkg_spec);
goal->add_rpm_remove(remove_pkg_spec, settings);
}
} // namespace dnf5

View File

@ -43,6 +43,7 @@ private:
std::unique_ptr<AllowErasingOption> allow_erasing;
std::vector<std::string> installed_from_repos;
std::vector<std::string> from_repos;
};

View File

@ -42,6 +42,8 @@ Options
``--allowerasing``
| Allow removing of installed packages to resolve any potential dependency problems.
.. include:: ../_shared/options/installed-from-repo.rst
.. include:: ../_shared/options/from-repo.rst
``--offline``