Skip to content

Commit 294e6f4

Browse files
konturaj-mracek
authored andcommitted
Add getApplicablePackages to advisory and isApplicable to advisorymodule
Increases minimal libsolv dependency, since its needed for correct collections handling.
1 parent b14a65e commit 294e6f4

6 files changed

+71
-3
lines changed

VERSION.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set (DEFAULT_LIBDNF_MAJOR_VERSION 0)
2-
set (DEFAULT_LIBDNF_MINOR_VERSION 59)
2+
set (DEFAULT_LIBDNF_MINOR_VERSION 60)
33
set (DEFAULT_LIBDNF_MICRO_VERSION 0)
44

55
if(DEFINED LIBDNF_MAJOR_VERSION)

libdnf.spec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
%global libsolv_version 0.7.7
1+
%global libsolv_version 0.7.17
22
%global libmodulemd_version 2.11.2-2
33
%global librepo_version 1.13.0
44
%global dnf_conflict 4.3.0
55
%global swig_version 3.0.12
66
%global libdnf_major_version 0
7-
%global libdnf_minor_version 59
7+
%global libdnf_minor_version 60
88
%global libdnf_micro_version 0
99

1010
%define __cmake_in_source_build 1

libdnf/sack/advisory.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,58 @@ std::vector<AdvisoryModule> Advisory::getModules() const
154154
return moduleList;
155155
}
156156

157+
void
158+
Advisory::getApplicablePackages(std::vector<AdvisoryPkg> & pkglist, bool withFilemanes) const
159+
{
160+
Dataiterator di;
161+
Dataiterator di_inner;
162+
Pool *pool = dnf_sack_get_pool(sack);
163+
164+
dataiterator_init(&di, pool, 0, advisory, UPDATE_COLLECTIONLIST, 0, 0);
165+
while (dataiterator_step(&di)) {
166+
dataiterator_setpos(&di);
167+
168+
bool isModuleCollectionApplicable = true;
169+
dataiterator_init(&di_inner, pool, 0, SOLVID_POS, UPDATE_MODULE, 0, 0);
170+
while (dataiterator_step(&di_inner)) {
171+
dataiterator_setpos(&di_inner);
172+
Id name = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_NAME);
173+
Id stream = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_STREAM);
174+
Id version = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_VERSION);
175+
Id context = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_CONTEXT);
176+
Id arch = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_ARCH);
177+
AdvisoryModule moduleAdvisory(sack, advisory, name, stream, version, context, arch);
178+
if (moduleAdvisory.isApplicable()) {
179+
isModuleCollectionApplicable = true;
180+
break;
181+
} else {
182+
isModuleCollectionApplicable = false;
183+
}
184+
}
185+
dataiterator_free(&di_inner);
186+
187+
if (isModuleCollectionApplicable) {
188+
const char * filename = nullptr;
189+
dataiterator_setpos(&di);
190+
191+
dataiterator_init(&di_inner, pool, 0, SOLVID_POS, UPDATE_COLLECTION, 0, 0);
192+
while (dataiterator_step(&di_inner)) {
193+
dataiterator_setpos(&di_inner);
194+
Id name = pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_NAME);
195+
Id evr = pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_EVR);
196+
Id arch = pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_ARCH);
197+
if (withFilemanes) {
198+
filename = pool_lookup_str(pool, SOLVID_POS, UPDATE_COLLECTION_FILENAME);
199+
}
200+
pkglist.emplace_back(sack, advisory, name, evr, arch, filename);
201+
}
202+
dataiterator_free(&di_inner);
203+
}
204+
}
205+
206+
dataiterator_free(&di);
207+
}
208+
157209
void
158210
Advisory::getReferences(std::vector<AdvisoryRef> & reflist) const
159211
{

libdnf/sack/advisory.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct Advisory {
4444
const char *getName() const;
4545
void getPackages(std::vector<AdvisoryPkg> & pkglist, bool withFilemanes = true) const;
4646
std::vector<AdvisoryModule> getModules() const;
47+
void getApplicablePackages(std::vector<AdvisoryPkg> & pkglist, bool withFilemanes = true) const;
4748
void getReferences(std::vector<AdvisoryRef> & reflist) const;
4849
const char *getRights() const;
4950
const char *getSeverity() const;

libdnf/sack/advisorymodule.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ AdvisoryModule::nsvcaEQ(AdvisoryModule & other)
7373
other.pImpl->arch == pImpl->arch;
7474
}
7575

76+
bool
77+
AdvisoryModule::isApplicable() const {
78+
auto moduleContainer = dnf_sack_get_module_container(pImpl->sack);
79+
if (!moduleContainer) {
80+
return true;
81+
}
82+
83+
if (!moduleContainer->isEnabled(getName(), getStream())) {
84+
return false;
85+
}
86+
87+
return true;
88+
}
89+
7690
Advisory * AdvisoryModule::getAdvisory() const
7791
{
7892
return new Advisory(pImpl->sack, pImpl->advisory);

libdnf/sack/advisorymodule.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct AdvisoryModule {
4141
AdvisoryModule & operator=(const AdvisoryModule & src);
4242
AdvisoryModule & operator=(AdvisoryModule && src) noexcept;
4343
bool nsvcaEQ(AdvisoryModule & other);
44+
bool isApplicable() const;
4445
Advisory * getAdvisory() const;
4546
const char * getName() const;
4647
const char * getStream() const;

0 commit comments

Comments
 (0)