Skip to content

Commit

Permalink
Add basic support of exclude_from_weak to context part
Browse files Browse the repository at this point in the history
It will unify behaviour of dnf, microdnf, and PackageKit.
  • Loading branch information
j-mracek authored and pkratoch committed Sep 30, 2021
1 parent 471147f commit 8655c99
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set (DEFAULT_LIBDNF_MAJOR_VERSION 0)
set (DEFAULT_LIBDNF_MINOR_VERSION 64)
set (DEFAULT_LIBDNF_MINOR_VERSION 65)
set (DEFAULT_LIBDNF_MICRO_VERSION 0)

if(DEFINED LIBDNF_MAJOR_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion libdnf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%global dnf_conflict 4.3.0
%global swig_version 3.0.12
%global libdnf_major_version 0
%global libdnf_minor_version 64
%global libdnf_minor_version 65
%global libdnf_micro_version 0

%define __cmake_in_source_build 1
Expand Down
22 changes: 22 additions & 0 deletions libdnf/dnf-goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@

#include <vector>

static void set_excludes_from_weak_to_goal(HyGoal goal)
{
DnfSack * sack = hy_goal_get_sack(goal);

goal->reset_exclude_from_weak();

const auto & exclude_from_weak_autodetect = libdnf::getGlobalMainConfig().exclude_from_weak_autodetect().getValue();
if (exclude_from_weak_autodetect) {
goal->exclude_from_weak_autodetect();
}

const auto & exclude_from_weak = libdnf::getGlobalMainConfig().exclude_from_weak().getValue();

for (auto & exclude : exclude_from_weak) {
libdnf::Query query(sack);
auto ret = query.filterSubject(exclude.c_str(), nullptr, false, true, false, false);
goal->add_exclude_from_weak(*query.getResultPset());
}
}

/**
* dnf_goal_depsolve:
* @goal: a #HyGoal.
Expand Down Expand Up @@ -80,6 +100,8 @@ dnf_goal_depsolve(HyGoal goal, DnfGoalActions flags, GError **error) try
auto pkgset = *query.runSet();
goal->addProtected(pkgset);

set_excludes_from_weak_to_goal(goal);

rc = hy_goal_run_flags(goal, flags);
if (rc) {
string = g_string_new(_("Could not depsolve transaction; "));
Expand Down
1 change: 1 addition & 0 deletions libdnf/sack/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "../hy-types.h"
#include "../hy-query.h"
#include "../hy-subject.h"
#include "../nevra.hpp"
#include "../repo/solvable/Dependency.hpp"
#include "../repo/solvable/DependencyContainer.hpp"
#include "../transaction/Swdb.hpp"
Expand Down

0 comments on commit 8655c99

Please sign in to comment.