dnf5: Support --installed-from-repo= for reinstall/remove

This commit is contained in:
Jaroslav Rohel 2025-06-16 12:29:48 +02:00
parent 2bf0cee1c1
commit 9539b22de9
6 changed files with 13 additions and 0 deletions

View File

@ -58,6 +58,7 @@ void ReinstallCommand::set_argument_parser() {
auto skip_broken = std::make_unique<SkipBrokenOption>(*this);
auto skip_unavailable = std::make_unique<SkipUnavailableOption>(*this);
create_allow_downgrade_options(*this);
create_installed_from_repo_option(*this, installed_from_repos, true);
create_from_repo_option(*this, from_repos, true);
create_downloadonly_option(*this);
create_offline_option(*this);
@ -74,6 +75,7 @@ void ReinstallCommand::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);
for (const auto & spec : pkg_specs) {
goal->add_reinstall(spec, settings);

View File

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

View File

@ -19,6 +19,8 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#include "remove.hpp"
#include "../from_repo.hpp"
#include <dnf5/shared_options.hpp>
namespace dnf5 {
@ -39,6 +41,8 @@ void RemoveCommand::set_argument_parser() {
auto & cmd = *get_argument_parser_command();
cmd.set_description(_("Remove (uninstall) software"));
create_installed_from_repo_option(*this, installed_from_repos, true);
auto noautoremove = parser.add_new_named_arg("no-autoremove");
noautoremove->set_long_name("no-autoremove");
noautoremove->set_description("Disable removal of dependencies that are no longer used");
@ -74,6 +78,7 @@ void RemoveCommand::run() {
// Limit remove spec capabity to prevent multiple matches. Remove command should not match anything after performing
// a remove action with the same spec. NEVRA and filenames are the only types that have no overlaps.
libdnf5::GoalJobSettings settings;
settings.set_from_repo_ids(installed_from_repos);
settings.set_with_nevra(true);
settings.set_with_provides(false);
settings.set_with_filenames(true);

View File

@ -38,6 +38,7 @@ public:
private:
std::vector<std::string> pkg_specs;
std::vector<std::string> installed_from_repos;
};
} // namespace dnf5

View File

@ -53,6 +53,8 @@ Options
``--no-allow-downgrade``
| Disable downgrade of dependencies when resolving the requested operation.
.. include:: ../_shared/options/installed-from-repo.rst
.. include:: ../_shared/options/from-repo.rst
``--downloadonly``

View File

@ -41,6 +41,8 @@ set the ``clean_requirements_on_remove`` configuration option to ``False``.
Options
=======
.. include:: ../_shared/options/installed-from-repo.rst
``--no-autoremove``
| Disable removal of dependencies that are no longer used.