]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgcache.cc
split-up Dependency struct
[apt.git] / apt-pkg / pkgcache.cc
CommitLineData
578bfd0a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
bac2e715 3// $Id: pkgcache.cc,v 1.37 2003/02/10 01:40:58 doogie Exp $
578bfd0a
AL
4/* ######################################################################
5
6 Package Cache - Accessor code for the cache
7
094a497d 8 Please see doc/apt-pkg/cache.sgml for a more detailed description of
578bfd0a
AL
9 this format. Also be sure to keep that file up-to-date!!
10
1e3f4083 11 This is the general utility functions for cache management. They provide
578bfd0a
AL
12 a complete set of accessor functions for the cache. The cacheiterators
13 header contains the STL-like iterators that can be used to easially
14 navigate the cache as well as seemlessly dereference the mmap'd
15 indexes. Use these always.
16
17 The main class provides for ways to get package indexes and some
18 general lookup functions to start the iterators.
19
20 ##################################################################### */
21 /*}}}*/
22// Include Files /*{{{*/
ea542140
DK
23#include<config.h>
24
094a497d 25#include <apt-pkg/pkgcache.h>
af29ffb4 26#include <apt-pkg/policy.h>
094a497d
AL
27#include <apt-pkg/version.h>
28#include <apt-pkg/error.h>
231fea14 29#include <apt-pkg/strutl.h>
b2e465d6 30#include <apt-pkg/configuration.h>
45df0ad2 31#include <apt-pkg/aptconfiguration.h>
453b82a3 32#include <apt-pkg/mmap.h>
5c0d3668 33#include <apt-pkg/macros.h>
578bfd0a 34
453b82a3
DK
35#include <stddef.h>
36#include <string.h>
37#include <ostream>
38#include <vector>
578bfd0a
AL
39#include <string>
40#include <sys/stat.h>
ea542140
DK
41
42#include <apti18n.h>
578bfd0a
AL
43 /*}}}*/
44
851a45a8
AL
45using std::string;
46
012b102a 47
578bfd0a
AL
48// Cache::Header::Header - Constructor /*{{{*/
49// ---------------------------------------------------------------------
50/* Simply initialize the header */
51pkgCache::Header::Header()
52{
53 Signature = 0x98FE76DC;
54
55 /* Whenever the structures change the major version should be bumped,
56 whenever the generator changes the minor version should be bumped. */
e8a7b0b2
DK
57 MajorVersion = 10;
58 MinorVersion = 0;
b2e465d6 59 Dirty = false;
578bfd0a
AL
60
61 HeaderSz = sizeof(pkgCache::Header);
52c41485 62 GroupSz = sizeof(pkgCache::Group);
578bfd0a 63 PackageSz = sizeof(pkgCache::Package);
b07aeb1a 64 ReleaseFileSz = sizeof(pkgCache::ReleaseFile);
578bfd0a
AL
65 PackageFileSz = sizeof(pkgCache::PackageFile);
66 VersionSz = sizeof(pkgCache::Version);
a52f938b 67 DescriptionSz = sizeof(pkgCache::Description);
578bfd0a 68 DependencySz = sizeof(pkgCache::Dependency);
71c9e95b 69 DependencyDataSz = sizeof(pkgCache::DependencyData);
578bfd0a 70 ProvidesSz = sizeof(pkgCache::Provides);
dcb79bae 71 VerFileSz = sizeof(pkgCache::VerFile);
a52f938b 72 DescFileSz = sizeof(pkgCache::DescFile);
dcb79bae 73
52c41485 74 GroupCount = 0;
578bfd0a
AL
75 PackageCount = 0;
76 VersionCount = 0;
a52f938b 77 DescriptionCount = 0;
578bfd0a 78 DependsCount = 0;
71c9e95b 79 DependsDataCount = 0;
b07aeb1a 80 ReleaseFileCount = 0;
578bfd0a 81 PackageFileCount = 0;
a7e66b17 82 VerFileCount = 0;
a52f938b 83 DescFileCount = 0;
a7e66b17 84 ProvidesCount = 0;
ad00ae81 85 MaxVerFileSize = 0;
a52f938b 86 MaxDescFileSize = 0;
578bfd0a
AL
87
88 FileList = 0;
b07aeb1a 89 RlsFileList = 0;
32ab4bd0
DK
90#if APT_PKG_ABI < 413
91 APT_IGNORE_DEPRECATED(StringList = 0;)
92#endif
b2e465d6
AL
93 VerSysName = 0;
94 Architecture = 0;
32ab4bd0
DK
95 SetArchitectures(0);
96 SetHashTableSize(_config->FindI("APT::Cache-HashTableSize", 10 * 1048));
578bfd0a 97 memset(Pools,0,sizeof(Pools));
0688ccd8
JAK
98
99 CacheFileSize = 0;
578bfd0a
AL
100}
101 /*}}}*/
102// Cache::Header::CheckSizes - Check if the two headers have same *sz /*{{{*/
103// ---------------------------------------------------------------------
104/* */
105bool pkgCache::Header::CheckSizes(Header &Against) const
106{
107 if (HeaderSz == Against.HeaderSz &&
52c41485 108 GroupSz == Against.GroupSz &&
578bfd0a 109 PackageSz == Against.PackageSz &&
b07aeb1a 110 ReleaseFileSz == Against.ReleaseFileSz &&
578bfd0a
AL
111 PackageFileSz == Against.PackageFileSz &&
112 VersionSz == Against.VersionSz &&
a52f938b 113 DescriptionSz == Against.DescriptionSz &&
dcb79bae 114 DependencySz == Against.DependencySz &&
71c9e95b 115 DependencyDataSz == Against.DependencyDataSz &&
dcb79bae 116 VerFileSz == Against.VerFileSz &&
a52f938b 117 DescFileSz == Against.DescFileSz &&
578bfd0a
AL
118 ProvidesSz == Against.ProvidesSz)
119 return true;
120 return false;
121}
122 /*}}}*/
123
124// Cache::pkgCache - Constructor /*{{{*/
125// ---------------------------------------------------------------------
126/* */
32ab4bd0 127APT_IGNORE_DEPRECATED_PUSH
6c55f07a 128pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map), d(NULL)
578bfd0a 129{
4cbf323f
MV
130 // call getArchitectures() with cached=false to ensure that the
131 // architectures cache is re-evaulated. this is needed in cases
132 // when the APT::Architecture field changes between two cache creations
133 MultiArchEnabled = APT::Configuration::getArchitectures(false).size() > 1;
b2e465d6
AL
134 if (DoMap == true)
135 ReMap();
578bfd0a 136}
32ab4bd0 137APT_IGNORE_DEPRECATED_POP
578bfd0a
AL
138 /*}}}*/
139// Cache::ReMap - Reopen the cache file /*{{{*/
140// ---------------------------------------------------------------------
141/* If the file is already closed then this will open it open it. */
a9fe5928 142bool pkgCache::ReMap(bool const &Errorchecks)
578bfd0a
AL
143{
144 // Apply the typecasts.
145 HeaderP = (Header *)Map.Data();
5bf15716 146 GrpP = (Group *)Map.Data();
578bfd0a 147 PkgP = (Package *)Map.Data();
dcb79bae 148 VerFileP = (VerFile *)Map.Data();
a52f938b 149 DescFileP = (DescFile *)Map.Data();
b07aeb1a 150 RlsFileP = (ReleaseFile *)Map.Data();
578bfd0a
AL
151 PkgFileP = (PackageFile *)Map.Data();
152 VerP = (Version *)Map.Data();
a52f938b 153 DescP = (Description *)Map.Data();
578bfd0a
AL
154 ProvideP = (Provides *)Map.Data();
155 DepP = (Dependency *)Map.Data();
71c9e95b 156 DepDataP = (DependencyData *)Map.Data();
578bfd0a
AL
157 StrP = (char *)Map.Data();
158
a9fe5928
DK
159 if (Errorchecks == false)
160 return true;
161
b2e465d6
AL
162 if (Map.Size() == 0 || HeaderP == 0)
163 return _error->Error(_("Empty package cache"));
578bfd0a
AL
164
165 // Check the header
166 Header DefHeader;
167 if (HeaderP->Signature != DefHeader.Signature ||
168 HeaderP->Dirty == true)
b2e465d6 169 return _error->Error(_("The package cache file is corrupted"));
578bfd0a
AL
170
171 if (HeaderP->MajorVersion != DefHeader.MajorVersion ||
172 HeaderP->MinorVersion != DefHeader.MinorVersion ||
173 HeaderP->CheckSizes(DefHeader) == false)
b2e465d6
AL
174 return _error->Error(_("The package cache file is an incompatible version"));
175
7d79339f
JAK
176 if (Map.Size() < HeaderP->CacheFileSize)
177 return _error->Error(_("The package cache file is corrupted, it is too small"));
178
32ab4bd0 179 if (HeaderP->VerSysName == 0 || HeaderP->Architecture == 0 || HeaderP->GetArchitectures() == 0)
7a223b93
DK
180 return _error->Error(_("The package cache file is corrupted"));
181
b2e465d6 182 // Locate our VS..
7a223b93 183 if ((VS = pkgVersioningSystem::GetVS(StrP + HeaderP->VerSysName)) == 0)
db0db9fe 184 return _error->Error(_("This APT does not support the versioning system '%s'"),StrP + HeaderP->VerSysName);
b2e465d6 185
7a223b93
DK
186 // Check the architecture
187 std::vector<std::string> archs = APT::Configuration::getArchitectures();
188 std::vector<std::string>::const_iterator a = archs.begin();
189 std::string list = *a;
190 for (++a; a != archs.end(); ++a)
191 list.append(",").append(*a);
192 if (_config->Find("APT::Architecture") != StrP + HeaderP->Architecture ||
32ab4bd0
DK
193 list != StrP + HeaderP->GetArchitectures())
194 return _error->Error(_("The package cache was built for different architectures: %s vs %s"), StrP + HeaderP->GetArchitectures(), list.c_str());
7a223b93 195
578bfd0a
AL
196 return true;
197}
198 /*}}}*/
199// Cache::Hash - Hash a string /*{{{*/
200// ---------------------------------------------------------------------
201/* This is used to generate the hash entries for the HashTable. With my
202 package list from bo this function gets 94% table usage on a 512 item
203 table (480 used items) */
4ad8619b 204map_id_t pkgCache::sHash(const string &Str) const
578bfd0a
AL
205{
206 unsigned long Hash = 0;
f7f0d6c7 207 for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
aa0fe657 208 Hash = 41 * Hash + tolower_ascii(*I);
32ab4bd0 209 return Hash % HeaderP->GetHashTableSize();
578bfd0a
AL
210}
211
4ad8619b 212map_id_t pkgCache::sHash(const char *Str) const
578bfd0a 213{
aa0fe657
DK
214 unsigned long Hash = tolower_ascii(*Str);
215 for (const char *I = Str + 1; *I != 0; ++I)
216 Hash = 41 * Hash + tolower_ascii(*I);
32ab4bd0 217 return Hash % HeaderP->GetHashTableSize();
578bfd0a 218}
8d4c859d
DK
219 /*}}}*/
220// Cache::SingleArchFindPkg - Locate a package by name /*{{{*/
221// ---------------------------------------------------------------------
222/* Returns 0 on error, pointer to the package otherwise
223 The multiArch enabled methods will fallback to this one as it is (a bit)
224 faster for single arch environments and realworld is mostly singlearch… */
225pkgCache::PkgIterator pkgCache::SingleArchFindPkg(const string &Name)
226{
227 // Look at the hash bucket
32ab4bd0
DK
228 Package *Pkg = PkgP + HeaderP->PkgHashTableP()[Hash(Name)];
229 for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
8d4c859d 230 {
b59325e8 231 int const cmp = strcmp(Name.c_str(), StrP + (GrpP + Pkg->Group)->Name);
aa0fe657
DK
232 if (cmp == 0)
233 return PkgIterator(*this, Pkg);
234 else if (cmp < 0)
235 break;
8d4c859d
DK
236 }
237 return PkgIterator(*this,0);
238}
578bfd0a
AL
239 /*}}}*/
240// Cache::FindPkg - Locate a package by name /*{{{*/
241// ---------------------------------------------------------------------
242/* Returns 0 on error, pointer to the package otherwise */
25396fb0
DK
243pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
244 size_t const found = Name.find(':');
245 if (found == string::npos)
6c9937da 246 return FindPkg(Name, "native");
4d174dc8 247 string const Arch = Name.substr(found+1);
eddc9dd0
DK
248 /* Beware: This is specialcased to handle pkg:any in dependencies as
249 these are linked to virtual pkg:any named packages with all archs.
250 If you want any arch from a given pkg, use FindPkg(pkg,arch) */
4d174dc8
DK
251 if (Arch == "any")
252 return FindPkg(Name, "any");
253 return FindPkg(Name.substr(0, found), Arch);
25396fb0
DK
254}
255 /*}}}*/
256// Cache::FindPkg - Locate a package by name /*{{{*/
257// ---------------------------------------------------------------------
258/* Returns 0 on error, pointer to the package otherwise */
8d4c859d 259pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
5bf15716
DK
260 /* We make a detour via the GrpIterator here as
261 on a multi-arch environment a group is easier to
262 find than a package (less entries in the buckets) */
263 pkgCache::GrpIterator Grp = FindGrp(Name);
264 if (Grp.end() == true)
265 return PkgIterator(*this,0);
266
267 return Grp.FindPkg(Arch);
268}
269 /*}}}*/
270// Cache::FindGrp - Locate a group by name /*{{{*/
271// ---------------------------------------------------------------------
272/* Returns End-Pointer on error, pointer to the group otherwise */
273pkgCache::GrpIterator pkgCache::FindGrp(const string &Name) {
274 if (unlikely(Name.empty() == true))
275 return GrpIterator(*this,0);
276
277 // Look at the hash bucket for the group
32ab4bd0 278 Group *Grp = GrpP + HeaderP->GrpHashTableP()[sHash(Name)];
5bf15716 279 for (; Grp != GrpP; Grp = GrpP + Grp->Next) {
b59325e8 280 int const cmp = strcmp(Name.c_str(), StrP + Grp->Name);
aa0fe657 281 if (cmp == 0)
5bf15716 282 return GrpIterator(*this, Grp);
aa0fe657
DK
283 else if (cmp < 0)
284 break;
5bf15716
DK
285 }
286
287 return GrpIterator(*this,0);
578bfd0a
AL
288}
289 /*}}}*/
b2e465d6
AL
290// Cache::CompTypeDeb - Return a string describing the compare type /*{{{*/
291// ---------------------------------------------------------------------
292/* This returns a string representation of the dependency compare
293 type in the weird debian style.. */
294const char *pkgCache::CompTypeDeb(unsigned char Comp)
295{
69c2ecbd
DK
296 const char * const Ops[] = {"","<=",">=","<<",">>","=","!="};
297 if (unlikely((unsigned)(Comp & 0xF) >= sizeof(Ops)/sizeof(Ops[0])))
298 return "";
299 return Ops[Comp & 0xF];
b2e465d6
AL
300}
301 /*}}}*/
302// Cache::CompType - Return a string describing the compare type /*{{{*/
303// ---------------------------------------------------------------------
69c2ecbd 304/* This returns a string representation of the dependency compare
b2e465d6
AL
305 type */
306const char *pkgCache::CompType(unsigned char Comp)
307{
69c2ecbd
DK
308 const char * const Ops[] = {"","<=",">=","<",">","=","!="};
309 if (unlikely((unsigned)(Comp & 0xF) >= sizeof(Ops)/sizeof(Ops[0])))
310 return "";
311 return Ops[Comp & 0xF];
b2e465d6
AL
312}
313 /*}}}*/
314// Cache::DepType - Return a string describing the dep type /*{{{*/
315// ---------------------------------------------------------------------
316/* */
317const char *pkgCache::DepType(unsigned char Type)
318{
319 const char *Types[] = {"",_("Depends"),_("PreDepends"),_("Suggests"),
320 _("Recommends"),_("Conflicts"),_("Replaces"),
f8ae7e8b 321 _("Obsoletes"),_("Breaks"), _("Enhances")};
308c7d30 322 if (Type < sizeof(Types)/sizeof(*Types))
b2e465d6
AL
323 return Types[Type];
324 return "";
325}
326 /*}}}*/
0149949b
AL
327// Cache::Priority - Convert a priority value to a string /*{{{*/
328// ---------------------------------------------------------------------
329/* */
330const char *pkgCache::Priority(unsigned char Prio)
331{
b2e465d6
AL
332 const char *Mapping[] = {0,_("important"),_("required"),_("standard"),
333 _("optional"),_("extra")};
0149949b
AL
334 if (Prio < _count(Mapping))
335 return Mapping[Prio];
336 return 0;
337}
338 /*}}}*/
5bf15716
DK
339// GrpIterator::FindPkg - Locate a package by arch /*{{{*/
340// ---------------------------------------------------------------------
341/* Returns an End-Pointer on error, pointer to the package otherwise */
e841200b 342pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
5bf15716
DK
343 if (unlikely(IsGood() == false || S->FirstPackage == 0))
344 return PkgIterator(*Owner, 0);
345
60dcec6d
DK
346 /* If we accept any package we simply return the "first"
347 package in this group (the last one added). */
348 if (Arch == "any")
349 return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage);
350
959470da 351 char const* const myArch = Owner->NativeArch();
5bf15716
DK
352 /* Most of the time the package for our native architecture is
353 the one we add at first to the cache, but this would be the
354 last one we check, so we do it now. */
566046f4 355 if (Arch == "native" || Arch == myArch || Arch == "all") {
5bf15716 356 pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage;
b59325e8 357 if (strcmp(myArch, Owner->StrP + Pkg->Arch) == 0)
5bf15716 358 return PkgIterator(*Owner, Pkg);
959470da 359 Arch = myArch;
5bf15716
DK
360 }
361
5d1e330d 362 // Iterate over the list to find the matching arch
5bf15716 363 for (pkgCache::Package *Pkg = PackageList(); Pkg != Owner->PkgP;
32ab4bd0 364 Pkg = Owner->PkgP + Pkg->NextPackage) {
5d1e330d 365 if (stringcmp(Arch, Owner->StrP + Pkg->Arch) == 0)
5bf15716
DK
366 return PkgIterator(*Owner, Pkg);
367 if ((Owner->PkgP + S->LastPackage) == Pkg)
368 break;
369 }
370
bd2fb30a
DK
371 return PkgIterator(*Owner, 0);
372}
373 /*}}}*/
374// GrpIterator::FindPreferredPkg - Locate the "best" package /*{{{*/
375// ---------------------------------------------------------------------
376/* Returns an End-Pointer on error, pointer to the package otherwise */
3db58cf4 377pkgCache::PkgIterator pkgCache::GrpIterator::FindPreferredPkg(bool const &PreferNonVirtual) const {
bd2fb30a 378 pkgCache::PkgIterator Pkg = FindPkg("native");
3db58cf4 379 if (Pkg.end() == false && (PreferNonVirtual == false || Pkg->VersionList != 0))
bd2fb30a
DK
380 return Pkg;
381
382 std::vector<std::string> const archs = APT::Configuration::getArchitectures();
383 for (std::vector<std::string>::const_iterator a = archs.begin();
384 a != archs.end(); ++a) {
385 Pkg = FindPkg(*a);
3db58cf4 386 if (Pkg.end() == false && (PreferNonVirtual == false || Pkg->VersionList != 0))
bd2fb30a
DK
387 return Pkg;
388 }
c919ad6e
DK
389 // packages without an architecture
390 Pkg = FindPkg("none");
391 if (Pkg.end() == false && (PreferNonVirtual == false || Pkg->VersionList != 0))
392 return Pkg;
bd2fb30a 393
3db58cf4
DK
394 if (PreferNonVirtual == true)
395 return FindPreferredPkg(false);
5bf15716
DK
396 return PkgIterator(*Owner, 0);
397}
398 /*}}}*/
399// GrpIterator::NextPkg - Locate the next package in the group /*{{{*/
400// ---------------------------------------------------------------------
401/* Returns an End-Pointer on error, pointer to the package otherwise.
c408e01e
DK
402 We can't simply ++ to the next as the next package of the last will
403 be from a different group (with the same hash value) */
e841200b 404pkgCache::PkgIterator pkgCache::GrpIterator::NextPkg(pkgCache::PkgIterator const &LastPkg) const {
5bf15716
DK
405 if (unlikely(IsGood() == false || S->FirstPackage == 0 ||
406 LastPkg.end() == true))
407 return PkgIterator(*Owner, 0);
408
c408e01e
DK
409 if (S->LastPackage == LastPkg.Index())
410 return PkgIterator(*Owner, 0);
5bf15716 411
32ab4bd0 412 return PkgIterator(*Owner, Owner->PkgP + LastPkg->NextPackage);
5bf15716
DK
413}
414 /*}}}*/
71c9e95b 415// GrpIterator::operator++ - Prefix incr /*{{{*/
25396fb0
DK
416// ---------------------------------------------------------------------
417/* This will advance to the next logical group in the hash table. */
3707fd4f 418pkgCache::GrpIterator& pkgCache::GrpIterator::operator++()
25396fb0
DK
419{
420 // Follow the current links
421 if (S != Owner->GrpP)
422 S = Owner->GrpP + S->Next;
423
424 // Follow the hash table
32ab4bd0 425 while (S == Owner->GrpP && (HashIndex+1) < (signed)Owner->HeaderP->GetHashTableSize())
25396fb0 426 {
71c9e95b 427 ++HashIndex;
32ab4bd0 428 S = Owner->GrpP + Owner->HeaderP->GrpHashTableP()[HashIndex];
25396fb0 429 }
3707fd4f 430 return *this;
d3e8fbb3 431}
f55a958f 432 /*}}}*/
71c9e95b 433// PkgIterator::operator++ - Prefix incr /*{{{*/
578bfd0a
AL
434// ---------------------------------------------------------------------
435/* This will advance to the next logical package in the hash table. */
71c9e95b 436pkgCache::PkgIterator& pkgCache::PkgIterator::operator++()
578bfd0a
AL
437{
438 // Follow the current links
773e2c1f 439 if (S != Owner->PkgP)
32ab4bd0 440 S = Owner->PkgP + S->NextPackage;
b2e465d6 441
578bfd0a 442 // Follow the hash table
32ab4bd0 443 while (S == Owner->PkgP && (HashIndex+1) < (signed)Owner->HeaderP->GetHashTableSize())
578bfd0a 444 {
71c9e95b 445 ++HashIndex;
32ab4bd0 446 S = Owner->PkgP + Owner->HeaderP->PkgHashTableP()[HashIndex];
578bfd0a 447 }
3707fd4f 448 return *this;
d3e8fbb3 449}
578bfd0a 450 /*}}}*/
71c9e95b
DK
451pkgCache::DepIterator& pkgCache::DepIterator::operator++() /*{{{*/
452{
453 if (S == Owner->DepP)
454 return *this;
455 S = Owner->DepP + (Type == DepVer ? S->NextDepends : S->NextRevDepends);
456 if (S == Owner->DepP)
457 S2 = Owner->DepDataP;
458 else
459 S2 = Owner->DepDataP + S->DependencyData;
460 return *this;
461}
462 /*}}}*/
578bfd0a
AL
463// PkgIterator::State - Check the State of the package /*{{{*/
464// ---------------------------------------------------------------------
465/* By this we mean if it is either cleanly installed or cleanly removed. */
466pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const
d38b7b3d 467{
773e2c1f
DK
468 if (S->InstState == pkgCache::State::ReInstReq ||
469 S->InstState == pkgCache::State::HoldReInstReq)
c7c1b0f6
AL
470 return NeedsUnpack;
471
773e2c1f
DK
472 if (S->CurrentState == pkgCache::State::UnPacked ||
473 S->CurrentState == pkgCache::State::HalfConfigured)
c6aa14e4
MV
474 // we leave triggers alone complettely. dpkg deals with
475 // them in a hard-to-predict manner and if they get
476 // resolved by dpkg before apt run dpkg --configure on
477 // the TriggersPending package dpkg returns a error
09fab244 478 //Pkg->CurrentState == pkgCache::State::TriggersAwaited
c6aa14e4 479 //Pkg->CurrentState == pkgCache::State::TriggersPending)
578bfd0a
AL
480 return NeedsConfigure;
481
773e2c1f
DK
482 if (S->CurrentState == pkgCache::State::HalfInstalled ||
483 S->InstState != pkgCache::State::Ok)
578bfd0a
AL
484 return NeedsUnpack;
485
486 return NeedsNothing;
487}
488 /*}}}*/
af29ffb4
MV
489// PkgIterator::CandVersion - Returns the candidate version string /*{{{*/
490// ---------------------------------------------------------------------
491/* Return string representing of the candidate version. */
492const char *
d3e8fbb3 493pkgCache::PkgIterator::CandVersion() const
af29ffb4
MV
494{
495 //TargetVer is empty, so don't use it.
749eb4cf 496 VerIterator version = pkgPolicy(Owner).GetCandidateVer(*this);
af29ffb4
MV
497 if (version.IsGood())
498 return version.VerStr();
499 return 0;
d3e8fbb3 500}
af29ffb4
MV
501 /*}}}*/
502// PkgIterator::CurVersion - Returns the current version string /*{{{*/
503// ---------------------------------------------------------------------
504/* Return string representing of the current version. */
505const char *
d3e8fbb3 506pkgCache::PkgIterator::CurVersion() const
af29ffb4
MV
507{
508 VerIterator version = CurrentVer();
509 if (version.IsGood())
510 return CurrentVer().VerStr();
511 return 0;
d3e8fbb3 512}
af29ffb4
MV
513 /*}}}*/
514// ostream operator to handle string representation of a package /*{{{*/
515// ---------------------------------------------------------------------
516/* Output name < cur.rent.version -> candid.ate.version | new.est.version > (section)
1e3f4083 517 Note that the characters <|>() are all literal above. Versions will be omitted
af29ffb4
MV
518 if they provide no new information (e.g. there is no newer version than candidate)
519 If no version and/or section can be found "none" is used. */
520std::ostream&
8f3ba4e8 521operator<<(std::ostream& out, pkgCache::PkgIterator Pkg)
af29ffb4
MV
522{
523 if (Pkg.end() == true)
524 return out << "invalid package";
525
526 string current = string(Pkg.CurVersion() == 0 ? "none" : Pkg.CurVersion());
527 string candidate = string(Pkg.CandVersion() == 0 ? "none" : Pkg.CandVersion());
528 string newest = string(Pkg.VersionList().end() ? "none" : Pkg.VersionList().VerStr());
529
5dd4c8b8 530 out << Pkg.Name() << " [ " << Pkg.Arch() << " ] < " << current;
af29ffb4
MV
531 if (current != candidate)
532 out << " -> " << candidate;
533 if ( newest != "none" && candidate != newest)
534 out << " | " << newest;
7a669774
DK
535 if (Pkg->VersionList == 0)
536 out << " > ( none )";
537 else
538 out << " > ( " << string(Pkg.VersionList().Section()==0?"unknown":Pkg.VersionList().Section()) << " )";
af29ffb4
MV
539 return out;
540}
541 /*}}}*/
75ce2062
DK
542// PkgIterator::FullName - Returns Name and (maybe) Architecture /*{{{*/
543// ---------------------------------------------------------------------
544/* Returns a name:arch string */
545std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
546{
547 string fullname = Name();
548 if (Pretty == false ||
959470da
DK
549 (strcmp(Arch(), "all") != 0 &&
550 strcmp(Owner->NativeArch(), Arch()) != 0))
75ce2062
DK
551 return fullname.append(":").append(Arch());
552 return fullname;
553}
554 /*}}}*/
578bfd0a
AL
555// DepIterator::IsCritical - Returns true if the dep is important /*{{{*/
556// ---------------------------------------------------------------------
557/* Currently critical deps are defined as depends, predepends and
308c7d30 558 conflicts (including dpkg's Breaks fields). */
e841200b 559bool pkgCache::DepIterator::IsCritical() const
578bfd0a 560{
359e46db 561 if (IsNegative() == true ||
71c9e95b
DK
562 S2->Type == pkgCache::Dep::Depends ||
563 S2->Type == pkgCache::Dep::PreDepends)
578bfd0a
AL
564 return true;
565 return false;
566}
567 /*}}}*/
df77d8a5
DK
568// DepIterator::IsNegative - Returns true if the dep is a negative one /*{{{*/
569// ---------------------------------------------------------------------
570/* Some dependencies are positive like Depends and Recommends, others
571 are negative like Conflicts which can and should be handled differently */
572bool pkgCache::DepIterator::IsNegative() const
573{
71c9e95b
DK
574 return S2->Type == Dep::DpkgBreaks ||
575 S2->Type == Dep::Conflicts ||
576 S2->Type == Dep::Obsoletes;
df77d8a5
DK
577}
578 /*}}}*/
578bfd0a
AL
579// DepIterator::SmartTargetPkg - Resolve dep target pointers w/provides /*{{{*/
580// ---------------------------------------------------------------------
581/* This intellegently looks at dep target packages and tries to figure
582 out which package should be used. This is needed to nicely handle
583 provide mapping. If the target package has no other providing packages
584 then it returned. Otherwise the providing list is looked at to
585 see if there is one one unique providing package if so it is returned.
586 Otherwise true is returned and the target package is set. The return
b2e465d6
AL
587 result indicates whether the node should be expandable
588
589 In Conjunction with the DepCache the value of Result may not be
590 super-good since the policy may have made it uninstallable. Using
591 AllTargets is better in this case. */
e841200b 592bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result) const
578bfd0a
AL
593{
594 Result = TargetPkg();
595
596 // No provides at all
597 if (Result->ProvidesList == 0)
598 return false;
599
600 // There is the Base package and the providing ones which is at least 2
601 if (Result->VersionList != 0)
602 return true;
603
604 /* We have to skip over indirect provisions of the package that
605 owns the dependency. For instance, if libc5-dev depends on the
606 virtual package libc-dev which is provided by libc5-dev and libc6-dev
607 we must ignore libc5-dev when considering the provides list. */
608 PrvIterator PStart = Result.ProvidesList();
f7f0d6c7 609 for (; PStart.end() != true && PStart.OwnerPkg() == ParentPkg(); ++PStart);
578bfd0a
AL
610
611 // Nothing but indirect self provides
612 if (PStart.end() == true)
613 return false;
614
615 // Check for single packages in the provides list
616 PrvIterator P = PStart;
f7f0d6c7 617 for (; P.end() != true; ++P)
578bfd0a
AL
618 {
619 // Skip over self provides
620 if (P.OwnerPkg() == ParentPkg())
621 continue;
622 if (PStart.OwnerPkg() != P.OwnerPkg())
623 break;
624 }
b2e465d6
AL
625
626 Result = PStart.OwnerPkg();
578bfd0a
AL
627
628 // Check for non dups
629 if (P.end() != true)
630 return true;
b2e465d6 631
578bfd0a
AL
632 return false;
633}
634 /*}}}*/
635// DepIterator::AllTargets - Returns the set of all possible targets /*{{{*/
636// ---------------------------------------------------------------------
b2e465d6 637/* This is a more useful version of TargetPkg() that follows versioned
578bfd0a 638 provides. It includes every possible package-version that could satisfy
fbfb2a7c
AL
639 the dependency. The last item in the list has a 0. The resulting pointer
640 must be delete [] 'd */
e841200b 641pkgCache::Version **pkgCache::DepIterator::AllTargets() const
578bfd0a
AL
642{
643 Version **Res = 0;
644 unsigned long Size =0;
645 while (1)
646 {
647 Version **End = Res;
648 PkgIterator DPkg = TargetPkg();
649
650 // Walk along the actual package providing versions
f7f0d6c7 651 for (VerIterator I = DPkg.VersionList(); I.end() == false; ++I)
578bfd0a 652 {
85434114 653 if (IsIgnorable(I.ParentPkg()) == true)
578bfd0a 654 continue;
887c6940 655 if (IsSatisfied(I) == false)
578bfd0a 656 continue;
85434114 657
578bfd0a
AL
658 Size++;
659 if (Res != 0)
660 *End++ = I;
661 }
662
663 // Follow all provides
f7f0d6c7 664 for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; ++I)
578bfd0a 665 {
85434114 666 if (IsIgnorable(I) == true)
578bfd0a 667 continue;
887c6940 668 if (IsSatisfied(I) == false)
85434114 669 continue;
5f909b67 670
578bfd0a
AL
671 Size++;
672 if (Res != 0)
673 *End++ = I.OwnerVer();
674 }
675
676 // Do it again and write it into the array
677 if (Res == 0)
678 {
679 Res = new Version *[Size+1];
680 Size = 0;
681 }
682 else
683 {
684 *End = 0;
685 break;
686 }
687 }
688
689 return Res;
690}
691 /*}}}*/
43d017d6
AL
692// DepIterator::GlobOr - Compute an OR group /*{{{*/
693// ---------------------------------------------------------------------
694/* This Takes an iterator, iterates past the current dependency grouping
695 and returns Start and End so that so End is the final element
696 in the group, if End == Start then D is End++ and End is the
697 dependency D was pointing to. Use in loops to iterate sensibly. */
698void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
699{
700 // Compute a single dependency element (glob or)
701 Start = *this;
702 End = *this;
018f1533 703 for (bool LastOR = true; end() == false && LastOR == true;)
43d017d6 704 {
71c9e95b 705 LastOR = (S2->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
3707fd4f 706 ++(*this);
43d017d6
AL
707 if (LastOR == true)
708 End = (*this);
709 }
710}
711 /*}}}*/
85434114
DK
712// DepIterator::IsIgnorable - should this packag/providr be ignored? /*{{{*/
713// ---------------------------------------------------------------------
714/* Deps like self-conflicts should be ignored as well as implicit conflicts
715 on virtual packages. */
fd23676e 716bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &PT) const
85434114 717{
021626db
DK
718 if (IsNegative() == false)
719 return false;
720
fd23676e 721 pkgCache::PkgIterator const PP = ParentPkg();
021626db
DK
722 if (PP->Group != PT->Group)
723 return false;
724 // self-conflict
725 if (PP == PT)
726 return true;
fd23676e 727 pkgCache::VerIterator const PV = ParentVer();
021626db
DK
728 // ignore group-conflict on a M-A:same package - but not our implicit dependencies
729 // so that we can have M-A:same packages conflicting with their own real name
730 if ((PV->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
731 {
732 // Replaces: ${self}:other ( << ${binary:Version})
71c9e95b 733 if (S2->Type == pkgCache::Dep::Replaces)
fd23676e 734 {
71c9e95b 735 if (S2->CompareOp == pkgCache::Dep::Less && strcmp(PV.VerStr(), TargetVer()) == 0)
fd23676e
DK
736 return false;
737 }
021626db 738 // Breaks: ${self}:other (!= ${binary:Version})
71c9e95b 739 else if (S2->Type == pkgCache::Dep::DpkgBreaks)
fd23676e 740 {
71c9e95b 741 if (S2->CompareOp == pkgCache::Dep::NotEquals && strcmp(PV.VerStr(), TargetVer()) == 0)
fd23676e
DK
742 return false;
743 }
021626db
DK
744 return true;
745 }
85434114
DK
746
747 return false;
748}
749bool pkgCache::DepIterator::IsIgnorable(PrvIterator const &Prv) const
750{
751 if (IsNegative() == false)
752 return false;
753
754 PkgIterator const Pkg = ParentPkg();
755 /* Provides may never be applied against the same package (or group)
756 if it is a conflicts. See the comment above. */
757 if (Prv.OwnerPkg()->Group == Pkg->Group)
758 return true;
759 // Implicit group-conflicts should not be applied on providers of other groups
760 if (Pkg->Group == TargetPkg()->Group && Prv.OwnerPkg()->Group != Pkg->Group)
761 return true;
762
763 return false;
764}
765 /*}}}*/
d5648746
DK
766// DepIterator::IsMultiArchImplicit - added by the cache generation /*{{{*/
767// ---------------------------------------------------------------------
768/* MultiArch can be translated to SingleArch for an resolver and we did so,
769 by adding dependencies to help the resolver understand the problem, but
770 sometimes it is needed to identify these to ignore them… */
771bool pkgCache::DepIterator::IsMultiArchImplicit() const
772{
0f485ee5 773 if (ParentPkg()->Arch != TargetPkg()->Arch &&
71c9e95b
DK
774 (S2->Type == pkgCache::Dep::Replaces ||
775 S2->Type == pkgCache::Dep::DpkgBreaks ||
776 S2->Type == pkgCache::Dep::Conflicts))
d5648746
DK
777 return true;
778 return false;
779}
780 /*}}}*/
887c6940
DK
781// DepIterator::IsSatisfied - check if a version satisfied the dependency /*{{{*/
782bool pkgCache::DepIterator::IsSatisfied(VerIterator const &Ver) const
783{
71c9e95b 784 return Owner->VS->CheckDep(Ver.VerStr(),S2->CompareOp,TargetVer());
887c6940
DK
785}
786bool pkgCache::DepIterator::IsSatisfied(PrvIterator const &Prv) const
787{
71c9e95b 788 return Owner->VS->CheckDep(Prv.ProvideVersion(),S2->CompareOp,TargetVer());
887c6940
DK
789}
790 /*}}}*/
47f6d1b7
DK
791// ostream operator to handle string representation of a dependecy /*{{{*/
792// ---------------------------------------------------------------------
793/* */
8f3ba4e8 794std::ostream& operator<<(std::ostream& out, pkgCache::DepIterator D)
47f6d1b7
DK
795{
796 if (D.end() == true)
797 return out << "invalid dependency";
798
799 pkgCache::PkgIterator P = D.ParentPkg();
800 pkgCache::PkgIterator T = D.TargetPkg();
801
802 out << (P.end() ? "invalid pkg" : P.FullName(false)) << " " << D.DepType()
803 << " on ";
804 if (T.end() == true)
805 out << "invalid pkg";
806 else
807 out << T;
808
809 if (D->Version != 0)
810 out << " (" << D.CompType() << " " << D.TargetVer() << ")";
811
812 return out;
813}
814 /*}}}*/
578bfd0a
AL
815// VerIterator::CompareVer - Fast version compare for same pkgs /*{{{*/
816// ---------------------------------------------------------------------
817/* This just looks over the version list to see if B is listed before A. In
818 most cases this will return in under 4 checks, ver lists are short. */
819int pkgCache::VerIterator::CompareVer(const VerIterator &B) const
820{
821 // Check if they are equal
822 if (*this == B)
823 return 0;
824 if (end() == true)
825 return -1;
826 if (B.end() == true)
827 return 1;
828
829 /* Start at A and look for B. If B is found then A > B otherwise
830 B was before A so A < B */
831 VerIterator I = *this;
f7f0d6c7 832 for (;I.end() == false; ++I)
578bfd0a
AL
833 if (I == B)
834 return 1;
835 return -1;
836}
837 /*}}}*/
b518cca6
AL
838// VerIterator::Downloadable - Checks if the version is downloadable /*{{{*/
839// ---------------------------------------------------------------------
840/* */
0e6fe58e 841APT_PURE bool pkgCache::VerIterator::Downloadable() const
b518cca6
AL
842{
843 VerFileIterator Files = FileList();
f7f0d6c7 844 for (; Files.end() == false; ++Files)
b07aeb1a 845 if (Files.File().Flagged(pkgCache::Flag::NotSource) == false)
b518cca6
AL
846 return true;
847 return false;
848}
849 /*}}}*/
3c124dde
AL
850// VerIterator::Automatic - Check if this version is 'automatic' /*{{{*/
851// ---------------------------------------------------------------------
852/* This checks to see if any of the versions files are not NotAutomatic.
853 True if this version is selectable for automatic installation. */
0e6fe58e 854APT_PURE bool pkgCache::VerIterator::Automatic() const
3c124dde
AL
855{
856 VerFileIterator Files = FileList();
f7f0d6c7 857 for (; Files.end() == false; ++Files)
5ed56f93 858 // Do not check ButAutomaticUpgrades here as it is kind of automatic…
b07aeb1a 859 if (Files.File().Flagged(pkgCache::Flag::NotAutomatic) == false)
3c124dde
AL
860 return true;
861 return false;
862}
863 /*}}}*/
864// VerIterator::NewestFile - Return the newest file version relation /*{{{*/
865// ---------------------------------------------------------------------
866/* This looks at the version numbers associated with all of the sources
867 this version is in and returns the highest.*/
868pkgCache::VerFileIterator pkgCache::VerIterator::NewestFile() const
869{
870 VerFileIterator Files = FileList();
871 VerFileIterator Highest = Files;
f7f0d6c7 872 for (; Files.end() == false; ++Files)
3c124dde 873 {
b2e465d6 874 if (Owner->VS->CmpReleaseVer(Files.File().Version(),Highest.File().Version()) > 0)
3c124dde
AL
875 Highest = Files;
876 }
877
878 return Highest;
879}
880 /*}}}*/
b2e465d6
AL
881// VerIterator::RelStr - Release description string /*{{{*/
882// ---------------------------------------------------------------------
883/* This describes the version from a release-centric manner. The output is a
884 list of Label:Version/Archive */
d4489d49 885string pkgCache::VerIterator::RelStr() const
b2e465d6
AL
886{
887 bool First = true;
888 string Res;
f7f0d6c7 889 for (pkgCache::VerFileIterator I = this->FileList(); I.end() == false; ++I)
b2e465d6
AL
890 {
891 // Do not print 'not source' entries'
b07aeb1a
DK
892 pkgCache::PkgFileIterator const File = I.File();
893 if (File.Flagged(pkgCache::Flag::NotSource))
b2e465d6
AL
894 continue;
895
896 // See if we have already printed this out..
897 bool Seen = false;
f7f0d6c7 898 for (pkgCache::VerFileIterator J = this->FileList(); I != J; ++J)
b2e465d6 899 {
b07aeb1a
DK
900 pkgCache::PkgFileIterator const File2 = J.File();
901 if (File2.Label() == 0 || File.Label() == 0)
b2e465d6
AL
902 continue;
903
904 if (strcmp(File.Label(),File2.Label()) != 0)
905 continue;
906
b07aeb1a 907 if (File2.Version() == File.Version())
b2e465d6
AL
908 {
909 Seen = true;
910 break;
911 }
b07aeb1a 912 if (File2.Version() == 0 || File.Version() == 0)
b2e465d6
AL
913 break;
914 if (strcmp(File.Version(),File2.Version()) == 0)
915 Seen = true;
916 }
917
918 if (Seen == true)
919 continue;
920
921 if (First == false)
922 Res += ", ";
923 else
924 First = false;
925
b07aeb1a 926 if (File.Label() != 0)
b2e465d6
AL
927 Res = Res + File.Label() + ':';
928
b07aeb1a 929 if (File.Archive() != 0)
b2e465d6 930 {
b07aeb1a 931 if (File.Version() == 0)
b2e465d6
AL
932 Res += File.Archive();
933 else
934 Res = Res + File.Version() + '/' + File.Archive();
935 }
936 else
937 {
938 // No release file, print the host name that this came from
b07aeb1a 939 if (File.Site() == 0 || File.Site()[0] == 0)
b2e465d6
AL
940 Res += "localhost";
941 else
942 Res += File.Site();
943 }
5dd4c8b8 944 }
857e9c13 945 if (S->ParentPkg != 0)
5dd4c8b8 946 Res.append(" [").append(Arch()).append("]");
b2e465d6
AL
947 return Res;
948}
949 /*}}}*/
7a948ec7
DK
950// VerIterator::MultiArchType - string representing MultiArch flag /*{{{*/
951const char * pkgCache::VerIterator::MultiArchType() const
952{
953 if ((S->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
954 return "same";
955 else if ((S->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
956 return "foreign";
957 else if ((S->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
958 return "allowed";
959 return "none";
960}
961 /*}}}*/
b07aeb1a 962// RlsFileIterator::IsOk - Checks if the cache is in sync with the file /*{{{*/
578bfd0a
AL
963// ---------------------------------------------------------------------
964/* This stats the file and compares its stats with the ones that were
b07aeb1a 965 stored during generation. Date checks should probably also be
578bfd0a 966 included here. */
b07aeb1a 967bool pkgCache::RlsFileIterator::IsOk()
578bfd0a
AL
968{
969 struct stat Buf;
970 if (stat(FileName(),&Buf) != 0)
971 return false;
972
773e2c1f 973 if (Buf.st_size != (signed)S->Size || Buf.st_mtime != S->mtime)
578bfd0a
AL
974 return false;
975
976 return true;
977}
978 /*}}}*/
b07aeb1a
DK
979// RlsFileIterator::RelStr - Return the release string /*{{{*/
980string pkgCache::RlsFileIterator::RelStr()
af87ab54
AL
981{
982 string Res;
983 if (Version() != 0)
984 Res = Res + (Res.empty() == true?"v=":",v=") + Version();
985 if (Origin() != 0)
986 Res = Res + (Res.empty() == true?"o=":",o=") + Origin();
987 if (Archive() != 0)
988 Res = Res + (Res.empty() == true?"a=":",a=") + Archive();
efc487fb
DK
989 if (Codename() != 0)
990 Res = Res + (Res.empty() == true?"n=":",n=") + Codename();
af87ab54
AL
991 if (Label() != 0)
992 Res = Res + (Res.empty() == true?"l=":",l=") + Label();
b07aeb1a
DK
993 return Res;
994}
995 /*}}}*/
996// PkgFileIterator::IsOk - Checks if the cache is in sync with the file /*{{{*/
997// ---------------------------------------------------------------------
998/* This stats the file and compares its stats with the ones that were
999 stored during generation. Date checks should probably also be
1000 included here. */
1001bool pkgCache::PkgFileIterator::IsOk()
1002{
1003 struct stat Buf;
1004 if (stat(FileName(),&Buf) != 0)
1005 return false;
1006
1007 if (Buf.st_size != (signed)S->Size || Buf.st_mtime != S->mtime)
1008 return false;
1009
1010 return true;
1011}
1012 /*}}}*/
1013string pkgCache::PkgFileIterator::RelStr() /*{{{*/
1014{
1015 std::string Res;
1016 if (ReleaseFile() == 0)
1017 {
1018 if (Component() != 0)
1019 Res = Res + (Res.empty() == true?"a=":",a=") + Component();
1020 }
1021 else
1022 {
1023 Res = ReleaseFile().RelStr();
1024 if (Component() != 0)
1025 Res = Res + (Res.empty() == true?"c=":",c=") + Component();
1026 }
5dd4c8b8
DK
1027 if (Architecture() != 0)
1028 Res = Res + (Res.empty() == true?"b=":",b=") + Architecture();
af87ab54
AL
1029 return Res;
1030}
1031 /*}}}*/
012b102a
MV
1032// VerIterator::TranslatedDescription - Return the a DescIter for locale/*{{{*/
1033// ---------------------------------------------------------------------
d3e8fbb3 1034/* return a DescIter for the current locale or the default if none is
012b102a
MV
1035 * found
1036 */
1037pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
1038{
45df0ad2
DK
1039 std::vector<string> const lang = APT::Configuration::getLanguages();
1040 for (std::vector<string>::const_iterator l = lang.begin();
f7f0d6c7 1041 l != lang.end(); ++l)
45df0ad2 1042 {
4b625b95
DK
1043 pkgCache::DescIterator Desc = DescriptionList();
1044 for (; Desc.end() == false; ++Desc)
0e7c3313 1045 if (*l == Desc.LanguageCode())
45df0ad2 1046 break;
4b625b95 1047 if (Desc.end() == true)
0e7c3313
DK
1048 {
1049 if (*l == "en")
1050 {
1051 Desc = DescriptionList();
1052 for (; Desc.end() == false; ++Desc)
1053 if (strcmp(Desc.LanguageCode(), "") == 0)
1054 break;
1055 if (Desc.end() == true)
1056 continue;
1057 }
1058 else
1059 continue;
1060 }
45df0ad2
DK
1061 return Desc;
1062 }
4b625b95
DK
1063 for (pkgCache::DescIterator Desc = DescriptionList();
1064 Desc.end() == false; ++Desc)
1065 if (strcmp(Desc.LanguageCode(), "") == 0)
1066 return Desc;
45df0ad2 1067 return DescriptionList();
d3e8fbb3 1068}
012b102a
MV
1069
1070 /*}}}*/
d5648746
DK
1071// PrvIterator::IsMultiArchImplicit - added by the cache generation /*{{{*/
1072// ---------------------------------------------------------------------
1073/* MultiArch can be translated to SingleArch for an resolver and we did so,
1074 by adding provides to help the resolver understand the problem, but
1075 sometimes it is needed to identify these to ignore them… */
1076bool pkgCache::PrvIterator::IsMultiArchImplicit() const
1077{
1078 pkgCache::PkgIterator const Owner = OwnerPkg();
1079 pkgCache::PkgIterator const Parent = ParentPkg();
fe86debb 1080 if (strcmp(Owner.Arch(), Parent.Arch()) != 0 || Owner.Group()->Name == Parent.Group()->Name)
d5648746
DK
1081 return true;
1082 return false;
1083}
1084 /*}}}*/
c8a4ce6c
DK
1085
1086pkgCache::~pkgCache() {}