Skip to content

Commit

Permalink
Add p_impl to libdnf5::GoalJobSettings and add getters and setters
Browse files Browse the repository at this point in the history
  • Loading branch information
kontura authored and jan-kolarik committed Jan 23, 2024
1 parent c1b9b23 commit 4859807
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 122 deletions.
2 changes: 1 addition & 1 deletion dnf5/commands/group/group_install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void GroupInstallCommand::run() {

libdnf5::GoalJobSettings settings;
if (no_packages->get_value()) {
settings.group_no_packages = true;
settings.set_group_no_packages(true);
}
if (with_optional->get_value()) {
auto group_package_types = libdnf5::comps::package_type_from_string(
Expand Down
2 changes: 1 addition & 1 deletion dnf5/commands/group/group_remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void GroupRemoveCommand::run() {

libdnf5::GoalJobSettings settings;
if (no_packages->get_value()) {
settings.group_no_packages = true;
settings.set_group_no_packages(true);
}
for (const auto & spec : group_specs->get_value()) {
goal->add_group_remove(spec, libdnf5::transaction::TransactionItemReason::USER, settings);
Expand Down
2 changes: 1 addition & 1 deletion dnf5daemon-server/services/goal/goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ sdbus::MethodReply Goal::get_transaction_problems(sdbus::MethodCall & call) {
goal_resolve_log_item["problem"] = static_cast<uint32_t>(log.get_problem());
if (log.get_job_settings()) {
dnfdaemon::KeyValueMap goal_job_settings;
goal_job_settings["to_repo_ids"] = log.get_job_settings()->to_repo_ids;
goal_job_settings["to_repo_ids"] = log.get_job_settings()->get_to_repo_ids();
goal_resolve_log_item["goal_job_settings"] = goal_job_settings;
}
if (log.get_spec()) {
Expand Down
12 changes: 6 additions & 6 deletions dnf5daemon-server/services/rpm/rpm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ sdbus::MethodReply Rpm::downgrade(sdbus::MethodCall & call) {
// fill the goal
auto & goal = session.get_goal();
libdnf5::GoalJobSettings setting;
setting.to_repo_ids = repo_ids;
setting.set_to_repo_ids(repo_ids);
for (const auto & spec : specs) {
goal.add_downgrade(spec, setting);
}
Expand Down Expand Up @@ -347,9 +347,9 @@ sdbus::MethodReply Rpm::install(sdbus::MethodCall & call) {
// fill the goal
auto & goal = session.get_goal();
libdnf5::GoalJobSettings setting;
setting.skip_broken = skip_broken;
setting.skip_unavailable = skip_unavailable;
setting.to_repo_ids = repo_ids;
setting.set_skip_broken(skip_broken);
setting.set_skip_unavailable(skip_unavailable);
setting.set_to_repo_ids(repo_ids);

for (const auto & spec : specs) {
goal.add_install(spec, setting);
Expand All @@ -371,7 +371,7 @@ sdbus::MethodReply Rpm::upgrade(sdbus::MethodCall & call) {
// fill the goal
auto & goal = session.get_goal();
libdnf5::GoalJobSettings setting;
setting.to_repo_ids = repo_ids;
setting.set_to_repo_ids(repo_ids);
if (specs.empty()) {
goal.add_rpm_upgrade(setting);
} else {
Expand All @@ -396,7 +396,7 @@ sdbus::MethodReply Rpm::reinstall(sdbus::MethodCall & call) {
// fill the goal
auto & goal = session.get_goal();
libdnf5::GoalJobSettings setting;
setting.to_repo_ids = repo_ids;
setting.set_to_repo_ids(repo_ids);
for (const auto & spec : specs) {
goal.add_reinstall(spec, setting);
}
Expand Down
110 changes: 72 additions & 38 deletions include/libdnf5/base/goal_elements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,46 +199,85 @@ struct ResolveSpecSettings {

struct GoalJobSettings : public ResolveSpecSettings {
public:
GoalJobSettings();
~GoalJobSettings();

GoalJobSettings(const GoalJobSettings & src);
GoalJobSettings(GoalJobSettings && src) noexcept;
GoalJobSettings & operator=(const GoalJobSettings & src);
GoalJobSettings & operator=(GoalJobSettings && src) noexcept;

/// Return used value for skip_broken
GoalUsedSetting get_used_skip_broken() const { return used_skip_broken; };
GoalUsedSetting get_used_skip_broken() const;
/// Return used value for skip_unavailable
GoalUsedSetting get_used_skip_unavailable() const { return used_skip_unavailable; };
GoalUsedSetting get_used_skip_unavailable() const;
/// Return used value for best
GoalUsedSetting get_used_best() const { return used_best; };
GoalUsedSetting get_used_best() const;
/// Return used value for clean_requirements_on_remove
GoalUsedSetting get_used_clean_requirements_on_remove() const { return used_clean_requirements_on_remove; };
GoalUsedSetting get_used_clean_requirements_on_remove() const;

/// Optionally assign AdvisoryQuery that is used to filter goal target packages (used for upgrade and install)
void set_advisory_filter(const libdnf5::advisory::AdvisoryQuery & filter) { advisory_filter = filter; };
const libdnf5::advisory::AdvisoryQuery * get_advisory_filter() const {
return advisory_filter ? &advisory_filter.value() : nullptr;
}
/// Optionally set AdvisoryQuery that is used to filter packages (used for upgrade).
/// Upgrades considers only packages that resolve some advisory in specified AdvisoryQuery.
///
/// By default is is empty and no packages are filtered.
void set_advisory_filter(const libdnf5::advisory::AdvisoryQuery & filter);
const libdnf5::advisory::AdvisoryQuery * get_advisory_filter() const;

// Which types of group packages are going to be installed with the group.
// If not set, default is taken from ConfigMain.group_package_types
void set_group_package_types(const libdnf5::comps::PackageType type) { group_package_types = type; }
const libdnf5::comps::PackageType * get_group_package_types() const {
return group_package_types ? &group_package_types.value() : nullptr;
}
/// Which types of group packages are going to be installed with the group.
///
/// Default is taken from ConfigMain.group_package_types
void set_group_package_types(libdnf5::comps::PackageType type);
const libdnf5::comps::PackageType * get_group_package_types() const;

/// If set to true, group operations (install / remove / upgrade) will only work
/// with the group itself, but will not add to the transaction any packages.
bool group_no_packages{false};

/// Set whether hints should be reported
bool report_hint{true};
/// Set skip_broken, AUTO means that it is handled according to the default behavior
GoalSetting skip_broken{GoalSetting::AUTO};
/// Set skip_unavailable, AUTO means that it is handled according to the default behavior
GoalSetting skip_unavailable{GoalSetting::AUTO};
/// Set best, AUTO means that it is handled according to the default behavior
GoalSetting best{GoalSetting::AUTO};
/// Set clean_requirements_on_remove, AUTO means that it is handled according to the default behavior
GoalSetting clean_requirements_on_remove{GoalSetting::AUTO};
/// Define which installed packages should be modified according to repoid from which they were installed
std::vector<std::string> from_repo_ids;
/// Reduce candidates for the operation according repository ids
std::vector<std::string> to_repo_ids;
///
/// Default: false
void set_group_no_packages(bool group_no_packages);
bool get_group_no_packages() const;

/// Set whether to report packages providing alternatives (``alternative-for(..)`` provide) and packages
/// with different letter capitalization when no matches are found.
///
/// Default: true
void set_report_hint(bool report_hint);
bool get_report_hint() const;

/// Resolve any dependency problems by removing packages that are causing problems from the transaction.
///
/// By default the value is taken from ``skip_broken`` configuration option.
void set_skip_broken(GoalSetting skip_broken);
GoalSetting get_skip_broken() const;

/// Allow skipping packages that are unavailable.
///
/// By default the value is taken from a configuration option ``skip_unavailable`` except for remove action
/// which defaults to true.
void set_skip_unavailable(GoalSetting skip_unavailable);
GoalSetting get_skip_unavailable() const;

/// Try the best available package versions in transactions.
///
/// By default the value is taken from ``best`` configuration option.
void set_best(GoalSetting best);
GoalSetting get_best() const;

/// Remove dependencies that are no longer used during ``dnf remove``.
///
/// By default the value is false except for remove action which defaults to value from
/// clean_requirements_on_remove configuration option.
void set_clean_requirements_on_remove(GoalSetting clean_requirements_on_remove);
GoalSetting get_clean_requirements_on_remove() const;

/// Not implemented yet
void set_from_repo_ids(std::vector<std::string> from_repo_ids);
std::vector<std::string> get_from_repo_ids() const;

/// Limit available packages to specified repositories.
///
/// Empty by default.
void set_to_repo_ids(std::vector<std::string> to_repo_ids);
std::vector<std::string> get_to_repo_ids() const;

private:
friend class Goal;
Expand Down Expand Up @@ -294,13 +333,8 @@ struct GoalJobSettings : public ResolveSpecSettings {
/// @exception libdnf5::AssertionError When a different value already stored or when invalid value
libdnf5::comps::PackageType resolve_group_package_types(const libdnf5::ConfigMain & cfg_main);

GoalUsedSetting used_skip_broken{GoalUsedSetting::UNUSED};
GoalUsedSetting used_skip_unavailable{GoalUsedSetting::UNUSED};
GoalUsedSetting used_best{GoalUsedSetting::UNUSED};
GoalUsedSetting used_clean_requirements_on_remove{GoalUsedSetting::UNUSED};
std::optional<libdnf5::comps::PackageType> used_group_package_types{std::nullopt};
std::optional<libdnf5::advisory::AdvisoryQuery> advisory_filter{std::nullopt};
std::optional<libdnf5::comps::PackageType> group_package_types{std::nullopt};
class Impl;
std::unique_ptr<Impl> p_impl;
};


Expand Down
Loading

0 comments on commit 4859807

Please sign in to comment.