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