Skip to content

Commit c48791a

Browse files
jrohelj-mracek
authored andcommitted
[context] Support config file option "protected_packages"
The "protected_packages" were ignored. Now dnf_goal_depsolve() takes into account the "protected_packages" configuration. = changelog = msg: Support main config file option "protected_packages". Changes behaviour of microdnf and PackageKit. type: bugfix
1 parent 3889d69 commit c48791a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

libdnf/dnf-goal.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@
4040
#include "dnf-package.h"
4141
#include "hy-packageset-private.hpp"
4242
#include "hy-iutil-private.hpp"
43+
#include "dnf-context.hpp"
4344
#include "dnf-sack-private.hpp"
4445
#include "dnf-utils.h"
4546
#include "utils/bgettext/bgettext-lib.h"
4647
#include "../goal/Goal.hpp"
4748

49+
#include <vector>
50+
4851
/**
4952
* dnf_goal_depsolve:
5053
* @goal: a #HyGoal.
@@ -63,6 +66,20 @@ dnf_goal_depsolve(HyGoal goal, DnfGoalActions flags, GError **error) try
6366
gint rc;
6467
g_autoptr(GString) string = NULL;
6568

69+
DnfSack * sack = hy_goal_get_sack(goal);
70+
71+
libdnf::Query query(sack);
72+
const auto & protected_packages = libdnf::getGlobalMainConfig().protected_packages().getValue();
73+
std::vector<const char *> cprotected_packages;
74+
cprotected_packages.reserve(protected_packages.size() + 1);
75+
for (const auto & package : protected_packages) {
76+
cprotected_packages.push_back(package.c_str());
77+
}
78+
cprotected_packages.push_back(nullptr);
79+
query.addFilter(HY_PKG_NAME, HY_EQ, cprotected_packages.data());
80+
auto pkgset = *query.runSet();
81+
goal->addProtected(pkgset);
82+
6683
rc = hy_goal_run_flags(goal, flags);
6784
if (rc) {
6885
string = g_string_new(_("Could not depsolve transaction; "));
@@ -101,7 +118,6 @@ dnf_goal_depsolve(HyGoal goal, DnfGoalActions flags, GError **error) try
101118
"The transaction was empty");
102119
return FALSE;
103120
}
104-
DnfSack * sack = hy_goal_get_sack(goal);
105121
auto moduleContainer = dnf_sack_get_module_container(sack);
106122
if (moduleContainer) {
107123
auto installSet = goal->listInstalls();

0 commit comments

Comments
 (0)