dnf5: upgrade/distro-sync: Apply --from-repo only if pkgs are specified
This change ensures that `--from-repo` is applied only when specific packages are provided on the command line. I am preparing support for filtering from-repo in the DISTRO_SYNC_ALL, UPGRADE_ALL, and UPGRADE_ALL_MINILMAL actions in libdnf5. This adjustment in the dnf5 application ensures its behavior won't change unexpectedly once the full support is added.
This commit is contained in:
parent
9a5bd317e6
commit
257d985d08
|
@ -71,10 +71,13 @@ void DistroSyncCommand::run() {
|
|||
auto goal = get_context().get_goal();
|
||||
goal->set_allow_erasing(allow_erasing->get_value());
|
||||
auto settings = libdnf5::GoalJobSettings();
|
||||
settings.set_to_repo_ids(from_repos);
|
||||
if (patterns_to_distro_sync_options->empty()) {
|
||||
goal->add_rpm_distro_sync(settings);
|
||||
} else {
|
||||
// The "--from-repo" option only applies to packages explicitly listed on the command line.
|
||||
// Other packages can be used from any enabled repository.
|
||||
settings.set_to_repo_ids(from_repos);
|
||||
|
||||
for (auto & pattern : *patterns_to_distro_sync_options) {
|
||||
auto option = dynamic_cast<libdnf5::OptionString *>(pattern.get());
|
||||
goal->add_rpm_distro_sync(option->get_value(), settings);
|
||||
|
|
|
@ -126,7 +126,6 @@ void UpgradeCommand::run() {
|
|||
}
|
||||
}
|
||||
|
||||
settings.set_to_repo_ids(from_repos);
|
||||
|
||||
auto advisories = advisory_query_from_cli_input(
|
||||
ctx.get_base(),
|
||||
|
@ -146,6 +145,10 @@ void UpgradeCommand::run() {
|
|||
if (pkg_specs.empty()) {
|
||||
goal->add_rpm_upgrade(settings, minimal->get_value());
|
||||
} else {
|
||||
// The "--from-repo" option only applies to packages explicitly listed on the command line.
|
||||
// Other packages can be used from any enabled repository.
|
||||
settings.set_to_repo_ids(from_repos);
|
||||
|
||||
for (const auto & spec : pkg_specs) {
|
||||
goal->add_upgrade(spec, settings, minimal->get_value());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue