]>
git.saurik.com Git - apt.git/blob - apt-pkg/pkgcache.cc
c945c59bf758f568e87b10ef506fd95254e50e18
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgcache.cc,v 1.37 2003/02/10 01:40:58 doogie Exp $
4 /* ######################################################################
6 Package Cache - Accessor code for the cache
8 Please see doc/apt-pkg/cache.sgml for a more detailed description of
9 this format. Also be sure to keep that file up-to-date!!
11 This is the general utility functions for cache managment. They provide
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.
17 The main class provides for ways to get package indexes and some
18 general lookup functions to start the iterators.
20 ##################################################################### */
22 // Include Files /*{{{*/
23 #include <apt-pkg/pkgcache.h>
24 #include <apt-pkg/policy.h>
25 #include <apt-pkg/version.h>
26 #include <apt-pkg/error.h>
27 #include <apt-pkg/strutl.h>
28 #include <apt-pkg/configuration.h>
29 #include <apt-pkg/aptconfiguration.h>
44 // Cache::Header::Header - Constructor /*{{{*/
45 // ---------------------------------------------------------------------
46 /* Simply initialize the header */
47 pkgCache::Header::Header()
49 Signature
= 0x98FE76DC;
51 /* Whenever the structures change the major version should be bumped,
52 whenever the generator changes the minor version should be bumped. */
57 HeaderSz
= sizeof(pkgCache::Header
);
58 PackageSz
= sizeof(pkgCache::Package
);
59 PackageFileSz
= sizeof(pkgCache::PackageFile
);
60 VersionSz
= sizeof(pkgCache::Version
);
61 DescriptionSz
= sizeof(pkgCache::Description
);
62 DependencySz
= sizeof(pkgCache::Dependency
);
63 ProvidesSz
= sizeof(pkgCache::Provides
);
64 VerFileSz
= sizeof(pkgCache::VerFile
);
65 DescFileSz
= sizeof(pkgCache::DescFile
);
82 memset(PkgHashTable
,0,sizeof(PkgHashTable
));
83 memset(GrpHashTable
,0,sizeof(GrpHashTable
));
84 memset(Pools
,0,sizeof(Pools
));
87 // Cache::Header::CheckSizes - Check if the two headers have same *sz /*{{{*/
88 // ---------------------------------------------------------------------
90 bool pkgCache::Header::CheckSizes(Header
&Against
) const
92 if (HeaderSz
== Against
.HeaderSz
&&
93 PackageSz
== Against
.PackageSz
&&
94 PackageFileSz
== Against
.PackageFileSz
&&
95 VersionSz
== Against
.VersionSz
&&
96 DescriptionSz
== Against
.DescriptionSz
&&
97 DependencySz
== Against
.DependencySz
&&
98 VerFileSz
== Against
.VerFileSz
&&
99 DescFileSz
== Against
.DescFileSz
&&
100 ProvidesSz
== Against
.ProvidesSz
)
106 // Cache::pkgCache - Constructor /*{{{*/
107 // ---------------------------------------------------------------------
109 pkgCache::pkgCache(MMap
*Map
, bool DoMap
) : Map(*Map
)
115 // Cache::ReMap - Reopen the cache file /*{{{*/
116 // ---------------------------------------------------------------------
117 /* If the file is already closed then this will open it open it. */
118 bool pkgCache::ReMap()
120 // Apply the typecasts.
121 HeaderP
= (Header
*)Map
.Data();
122 GrpP
= (Group
*)Map
.Data();
123 PkgP
= (Package
*)Map
.Data();
124 VerFileP
= (VerFile
*)Map
.Data();
125 DescFileP
= (DescFile
*)Map
.Data();
126 PkgFileP
= (PackageFile
*)Map
.Data();
127 VerP
= (Version
*)Map
.Data();
128 DescP
= (Description
*)Map
.Data();
129 ProvideP
= (Provides
*)Map
.Data();
130 DepP
= (Dependency
*)Map
.Data();
131 StringItemP
= (StringItem
*)Map
.Data();
132 StrP
= (char *)Map
.Data();
134 if (Map
.Size() == 0 || HeaderP
== 0)
135 return _error
->Error(_("Empty package cache"));
139 if (HeaderP
->Signature
!= DefHeader
.Signature
||
140 HeaderP
->Dirty
== true)
141 return _error
->Error(_("The package cache file is corrupted"));
143 if (HeaderP
->MajorVersion
!= DefHeader
.MajorVersion
||
144 HeaderP
->MinorVersion
!= DefHeader
.MinorVersion
||
145 HeaderP
->CheckSizes(DefHeader
) == false)
146 return _error
->Error(_("The package cache file is an incompatible version"));
149 if (HeaderP
->VerSysName
== 0 ||
150 (VS
= pkgVersioningSystem::GetVS(StrP
+ HeaderP
->VerSysName
)) == 0)
151 return _error
->Error(_("This APT does not support the versioning system '%s'"),StrP
+ HeaderP
->VerSysName
);
153 // Chcek the arhcitecture
154 if (HeaderP
->Architecture
== 0 ||
155 _config
->Find("APT::Architecture") != StrP
+ HeaderP
->Architecture
)
156 return _error
->Error(_("The package cache was built for a different architecture"));
160 // Cache::Hash - Hash a string /*{{{*/
161 // ---------------------------------------------------------------------
162 /* This is used to generate the hash entries for the HashTable. With my
163 package list from bo this function gets 94% table usage on a 512 item
164 table (480 used items) */
165 unsigned long pkgCache::sHash(const string
&Str
) const
167 unsigned long Hash
= 0;
168 for (string::const_iterator I
= Str
.begin(); I
!= Str
.end(); I
++)
169 Hash
= 5*Hash
+ tolower_ascii(*I
);
170 return Hash
% _count(HeaderP
->PkgHashTable
);
173 unsigned long pkgCache::sHash(const char *Str
) const
175 unsigned long Hash
= 0;
176 for (const char *I
= Str
; *I
!= 0; I
++)
177 Hash
= 5*Hash
+ tolower_ascii(*I
);
178 return Hash
% _count(HeaderP
->PkgHashTable
);
182 // Cache::FindPkg - Locate a package by name /*{{{*/
183 // ---------------------------------------------------------------------
184 /* Returns 0 on error, pointer to the package otherwise */
185 pkgCache::PkgIterator
pkgCache::FindPkg(const string
&Name
, string Arch
) {
186 /* We make a detour via the GrpIterator here as
187 on a multi-arch environment a group is easier to
188 find than a package (less entries in the buckets) */
189 pkgCache::GrpIterator Grp
= FindGrp(Name
);
190 if (Grp
.end() == true)
191 return PkgIterator(*this,0);
193 return Grp
.FindPkg(Arch
);
196 // Cache::FindGrp - Locate a group by name /*{{{*/
197 // ---------------------------------------------------------------------
198 /* Returns End-Pointer on error, pointer to the group otherwise */
199 pkgCache::GrpIterator
pkgCache::FindGrp(const string
&Name
) {
200 if (unlikely(Name
.empty() == true))
201 return GrpIterator(*this,0);
203 // Look at the hash bucket for the group
204 Group
*Grp
= GrpP
+ HeaderP
->GrpHashTable
[sHash(Name
)];
205 for (; Grp
!= GrpP
; Grp
= GrpP
+ Grp
->Next
) {
206 if (Grp
->Name
!= 0 && StrP
[Grp
->Name
] == Name
[0] &&
207 stringcasecmp(Name
, StrP
+ Grp
->Name
) == 0)
208 return GrpIterator(*this, Grp
);
211 return GrpIterator(*this,0);
214 // Cache::CompTypeDeb - Return a string describing the compare type /*{{{*/
215 // ---------------------------------------------------------------------
216 /* This returns a string representation of the dependency compare
217 type in the weird debian style.. */
218 const char *pkgCache::CompTypeDeb(unsigned char Comp
)
220 const char *Ops
[] = {"","<=",">=","<<",">>","=","!="};
221 if ((unsigned)(Comp
& 0xF) < 7)
222 return Ops
[Comp
& 0xF];
226 // Cache::CompType - Return a string describing the compare type /*{{{*/
227 // ---------------------------------------------------------------------
228 /* This returns a string representation of the dependency compare
230 const char *pkgCache::CompType(unsigned char Comp
)
232 const char *Ops
[] = {"","<=",">=","<",">","=","!="};
233 if ((unsigned)(Comp
& 0xF) < 7)
234 return Ops
[Comp
& 0xF];
238 // Cache::DepType - Return a string describing the dep type /*{{{*/
239 // ---------------------------------------------------------------------
241 const char *pkgCache::DepType(unsigned char Type
)
243 const char *Types
[] = {"",_("Depends"),_("PreDepends"),_("Suggests"),
244 _("Recommends"),_("Conflicts"),_("Replaces"),
245 _("Obsoletes"),_("Breaks"), _("Enhances")};
246 if (Type
< sizeof(Types
)/sizeof(*Types
))
251 // Cache::Priority - Convert a priority value to a string /*{{{*/
252 // ---------------------------------------------------------------------
254 const char *pkgCache::Priority(unsigned char Prio
)
256 const char *Mapping
[] = {0,_("important"),_("required"),_("standard"),
257 _("optional"),_("extra")};
258 if (Prio
< _count(Mapping
))
259 return Mapping
[Prio
];
263 // GrpIterator::FindPkg - Locate a package by arch /*{{{*/
264 // ---------------------------------------------------------------------
265 /* Returns an End-Pointer on error, pointer to the package otherwise */
266 pkgCache::PkgIterator
pkgCache::GrpIterator::FindPkg(string Arch
) {
267 if (unlikely(IsGood() == false || S
->FirstPackage
== 0))
268 return PkgIterator(*Owner
, 0);
270 static string
const myArch
= _config
->Find("APT::Architecture");
271 /* Most of the time the package for our native architecture is
272 the one we add at first to the cache, but this would be the
273 last one we check, so we do it now. */
274 if (Arch
== "native" || Arch
== myArch
) {
276 pkgCache::Package
*Pkg
= Owner
->PkgP
+ S
->LastPackage
;
277 if (stringcasecmp(Arch
, Owner
->StrP
+ Pkg
->Arch
) == 0)
278 return PkgIterator(*Owner
, Pkg
);
281 /* If we accept any package we simply return the "first"
282 package in this group (the last one added). */
284 return PkgIterator(*Owner
, Owner
->PkgP
+ S
->FirstPackage
);
286 /* Iterate over the list to find the matching arch
287 unfortunately this list includes "package noise"
288 (= different packages with same calculated hash),
289 so we need to check the name also */
290 for (pkgCache::Package
*Pkg
= PackageList(); Pkg
!= Owner
->PkgP
;
291 Pkg
= Owner
->PkgP
+ Pkg
->NextPackage
) {
292 if (S
->Name
== Pkg
->Name
&&
293 stringcasecmp(Arch
, Owner
->StrP
+ Pkg
->Arch
) == 0)
294 return PkgIterator(*Owner
, Pkg
);
295 if ((Owner
->PkgP
+ S
->LastPackage
) == Pkg
)
299 return PkgIterator(*Owner
, 0);
302 // GrpIterator::NextPkg - Locate the next package in the group /*{{{*/
303 // ---------------------------------------------------------------------
304 /* Returns an End-Pointer on error, pointer to the package otherwise.
305 We can't simply ++ to the next as the list of packages includes
306 "package noise" (= packages with the same hash value but different name) */
307 pkgCache::PkgIterator
pkgCache::GrpIterator::NextPkg(pkgCache::PkgIterator
const &LastPkg
) {
308 if (unlikely(IsGood() == false || S
->FirstPackage
== 0 ||
309 LastPkg
.end() == true))
310 return PkgIterator(*Owner
, 0);
312 // Iterate over the list to find the next package
313 pkgCache::Package
*Pkg
= Owner
->PkgP
+ LastPkg
.Index();
314 Pkg
= Owner
->PkgP
+ Pkg
->NextPackage
;
315 for (; Pkg
!= Owner
->PkgP
; Pkg
= Owner
->PkgP
+ Pkg
->NextPackage
) {
316 if (S
->Name
== Pkg
->Name
)
317 return PkgIterator(*Owner
, Pkg
);
318 if ((Owner
->PkgP
+ S
->LastPackage
) == Pkg
)
322 return PkgIterator(*Owner
, 0);
325 // PkgIterator::operator ++ - Postfix incr /*{{{*/
326 // ---------------------------------------------------------------------
327 /* This will advance to the next logical package in the hash table. */
328 void pkgCache::PkgIterator::operator ++(int)
330 // Follow the current links
331 if (S
!= Owner
->PkgP
)
332 S
= Owner
->PkgP
+ S
->NextPackage
;
334 // Follow the hash table
335 while (S
== Owner
->PkgP
&& (HashIndex
+1) < (signed)_count(Owner
->HeaderP
->PkgHashTable
))
338 S
= Owner
->PkgP
+ Owner
->HeaderP
->PkgHashTable
[HashIndex
];
342 // PkgIterator::State - Check the State of the package /*{{{*/
343 // ---------------------------------------------------------------------
344 /* By this we mean if it is either cleanly installed or cleanly removed. */
345 pkgCache::PkgIterator::OkState
pkgCache::PkgIterator::State() const
347 if (S
->InstState
== pkgCache::State::ReInstReq
||
348 S
->InstState
== pkgCache::State::HoldReInstReq
)
351 if (S
->CurrentState
== pkgCache::State::UnPacked
||
352 S
->CurrentState
== pkgCache::State::HalfConfigured
)
353 // we leave triggers alone complettely. dpkg deals with
354 // them in a hard-to-predict manner and if they get
355 // resolved by dpkg before apt run dpkg --configure on
356 // the TriggersPending package dpkg returns a error
357 //Pkg->CurrentState == pkgCache::State::TriggersAwaited
358 //Pkg->CurrentState == pkgCache::State::TriggersPending)
359 return NeedsConfigure
;
361 if (S
->CurrentState
== pkgCache::State::HalfInstalled
||
362 S
->InstState
!= pkgCache::State::Ok
)
368 // PkgIterator::CandVersion - Returns the candidate version string /*{{{*/
369 // ---------------------------------------------------------------------
370 /* Return string representing of the candidate version. */
372 pkgCache::PkgIterator::CandVersion() const
374 //TargetVer is empty, so don't use it.
375 VerIterator version
= pkgPolicy::pkgPolicy(Owner
).GetCandidateVer(*this);
376 if (version
.IsGood())
377 return version
.VerStr();
381 // PkgIterator::CurVersion - Returns the current version string /*{{{*/
382 // ---------------------------------------------------------------------
383 /* Return string representing of the current version. */
385 pkgCache::PkgIterator::CurVersion() const
387 VerIterator version
= CurrentVer();
388 if (version
.IsGood())
389 return CurrentVer().VerStr();
393 // ostream operator to handle string representation of a package /*{{{*/
394 // ---------------------------------------------------------------------
395 /* Output name < cur.rent.version -> candid.ate.version | new.est.version > (section)
396 Note that the characters <|>() are all literal above. Versions will be ommited
397 if they provide no new information (e.g. there is no newer version than candidate)
398 If no version and/or section can be found "none" is used. */
400 operator<<(ostream
& out
, pkgCache::PkgIterator Pkg
)
402 if (Pkg
.end() == true)
403 return out
<< "invalid package";
405 string current
= string(Pkg
.CurVersion() == 0 ? "none" : Pkg
.CurVersion());
406 string candidate
= string(Pkg
.CandVersion() == 0 ? "none" : Pkg
.CandVersion());
407 string newest
= string(Pkg
.VersionList().end() ? "none" : Pkg
.VersionList().VerStr());
409 out
<< Pkg
.Name() << " [ " << Pkg
.Arch() << " ] < " << current
;
410 if (current
!= candidate
)
411 out
<< " -> " << candidate
;
412 if ( newest
!= "none" && candidate
!= newest
)
413 out
<< " | " << newest
;
414 out
<< " > ( " << string(Pkg
.Section()==0?"none":Pkg
.Section()) << " )";
418 // DepIterator::IsCritical - Returns true if the dep is important /*{{{*/
419 // ---------------------------------------------------------------------
420 /* Currently critical deps are defined as depends, predepends and
421 conflicts (including dpkg's Breaks fields). */
422 bool pkgCache::DepIterator::IsCritical()
424 if (S
->Type
== pkgCache::Dep::Conflicts
||
425 S
->Type
== pkgCache::Dep::DpkgBreaks
||
426 S
->Type
== pkgCache::Dep::Obsoletes
||
427 S
->Type
== pkgCache::Dep::Depends
||
428 S
->Type
== pkgCache::Dep::PreDepends
)
433 // DepIterator::SmartTargetPkg - Resolve dep target pointers w/provides /*{{{*/
434 // ---------------------------------------------------------------------
435 /* This intellegently looks at dep target packages and tries to figure
436 out which package should be used. This is needed to nicely handle
437 provide mapping. If the target package has no other providing packages
438 then it returned. Otherwise the providing list is looked at to
439 see if there is one one unique providing package if so it is returned.
440 Otherwise true is returned and the target package is set. The return
441 result indicates whether the node should be expandable
443 In Conjunction with the DepCache the value of Result may not be
444 super-good since the policy may have made it uninstallable. Using
445 AllTargets is better in this case. */
446 bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator
&Result
)
448 Result
= TargetPkg();
450 // No provides at all
451 if (Result
->ProvidesList
== 0)
454 // There is the Base package and the providing ones which is at least 2
455 if (Result
->VersionList
!= 0)
458 /* We have to skip over indirect provisions of the package that
459 owns the dependency. For instance, if libc5-dev depends on the
460 virtual package libc-dev which is provided by libc5-dev and libc6-dev
461 we must ignore libc5-dev when considering the provides list. */
462 PrvIterator PStart
= Result
.ProvidesList();
463 for (; PStart
.end() != true && PStart
.OwnerPkg() == ParentPkg(); PStart
++);
465 // Nothing but indirect self provides
466 if (PStart
.end() == true)
469 // Check for single packages in the provides list
470 PrvIterator P
= PStart
;
471 for (; P
.end() != true; P
++)
473 // Skip over self provides
474 if (P
.OwnerPkg() == ParentPkg())
476 if (PStart
.OwnerPkg() != P
.OwnerPkg())
480 Result
= PStart
.OwnerPkg();
482 // Check for non dups
489 // DepIterator::AllTargets - Returns the set of all possible targets /*{{{*/
490 // ---------------------------------------------------------------------
491 /* This is a more useful version of TargetPkg() that follows versioned
492 provides. It includes every possible package-version that could satisfy
493 the dependency. The last item in the list has a 0. The resulting pointer
494 must be delete [] 'd */
495 pkgCache::Version
**pkgCache::DepIterator::AllTargets()
498 unsigned long Size
=0;
502 PkgIterator DPkg
= TargetPkg();
504 // Walk along the actual package providing versions
505 for (VerIterator I
= DPkg
.VersionList(); I
.end() == false; I
++)
507 if (Owner
->VS
->CheckDep(I
.VerStr(),S
->CompareOp
,TargetVer()) == false)
510 if ((S
->Type
== pkgCache::Dep::Conflicts
||
511 S
->Type
== pkgCache::Dep::DpkgBreaks
||
512 S
->Type
== pkgCache::Dep::Obsoletes
) &&
513 ParentPkg() == I
.ParentPkg())
521 // Follow all provides
522 for (PrvIterator I
= DPkg
.ProvidesList(); I
.end() == false; I
++)
524 if (Owner
->VS
->CheckDep(I
.ProvideVersion(),S
->CompareOp
,TargetVer()) == false)
527 if ((S
->Type
== pkgCache::Dep::Conflicts
||
528 S
->Type
== pkgCache::Dep::DpkgBreaks
||
529 S
->Type
== pkgCache::Dep::Obsoletes
) &&
530 ParentPkg() == I
.OwnerPkg())
535 *End
++ = I
.OwnerVer();
538 // Do it again and write it into the array
541 Res
= new Version
*[Size
+1];
554 // DepIterator::GlobOr - Compute an OR group /*{{{*/
555 // ---------------------------------------------------------------------
556 /* This Takes an iterator, iterates past the current dependency grouping
557 and returns Start and End so that so End is the final element
558 in the group, if End == Start then D is End++ and End is the
559 dependency D was pointing to. Use in loops to iterate sensibly. */
560 void pkgCache::DepIterator::GlobOr(DepIterator
&Start
,DepIterator
&End
)
562 // Compute a single dependency element (glob or)
565 for (bool LastOR
= true; end() == false && LastOR
== true;)
567 LastOR
= (S
->CompareOp
& pkgCache::Dep::Or
) == pkgCache::Dep::Or
;
574 // VerIterator::CompareVer - Fast version compare for same pkgs /*{{{*/
575 // ---------------------------------------------------------------------
576 /* This just looks over the version list to see if B is listed before A. In
577 most cases this will return in under 4 checks, ver lists are short. */
578 int pkgCache::VerIterator::CompareVer(const VerIterator
&B
) const
580 // Check if they are equal
588 /* Start at A and look for B. If B is found then A > B otherwise
589 B was before A so A < B */
590 VerIterator I
= *this;
591 for (;I
.end() == false; I
++)
597 // VerIterator::Downloadable - Checks if the version is downloadable /*{{{*/
598 // ---------------------------------------------------------------------
600 bool pkgCache::VerIterator::Downloadable() const
602 VerFileIterator Files
= FileList();
603 for (; Files
.end() == false; Files
++)
604 if ((Files
.File()->Flags
& pkgCache::Flag::NotSource
) != pkgCache::Flag::NotSource
)
609 // VerIterator::Automatic - Check if this version is 'automatic' /*{{{*/
610 // ---------------------------------------------------------------------
611 /* This checks to see if any of the versions files are not NotAutomatic.
612 True if this version is selectable for automatic installation. */
613 bool pkgCache::VerIterator::Automatic() const
615 VerFileIterator Files
= FileList();
616 for (; Files
.end() == false; Files
++)
617 if ((Files
.File()->Flags
& pkgCache::Flag::NotAutomatic
) != pkgCache::Flag::NotAutomatic
)
622 // VerIterator::NewestFile - Return the newest file version relation /*{{{*/
623 // ---------------------------------------------------------------------
624 /* This looks at the version numbers associated with all of the sources
625 this version is in and returns the highest.*/
626 pkgCache::VerFileIterator
pkgCache::VerIterator::NewestFile() const
628 VerFileIterator Files
= FileList();
629 VerFileIterator Highest
= Files
;
630 for (; Files
.end() == false; Files
++)
632 if (Owner
->VS
->CmpReleaseVer(Files
.File().Version(),Highest
.File().Version()) > 0)
639 // VerIterator::RelStr - Release description string /*{{{*/
640 // ---------------------------------------------------------------------
641 /* This describes the version from a release-centric manner. The output is a
642 list of Label:Version/Archive */
643 string
pkgCache::VerIterator::RelStr()
647 for (pkgCache::VerFileIterator I
= this->FileList(); I
.end() == false; I
++)
649 // Do not print 'not source' entries'
650 pkgCache::PkgFileIterator File
= I
.File();
651 if ((File
->Flags
& pkgCache::Flag::NotSource
) == pkgCache::Flag::NotSource
)
654 // See if we have already printed this out..
656 for (pkgCache::VerFileIterator J
= this->FileList(); I
!= J
; J
++)
658 pkgCache::PkgFileIterator File2
= J
.File();
659 if (File2
->Label
== 0 || File
->Label
== 0)
662 if (strcmp(File
.Label(),File2
.Label()) != 0)
665 if (File2
->Version
== File
->Version
)
670 if (File2
->Version
== 0 || File
->Version
== 0)
672 if (strcmp(File
.Version(),File2
.Version()) == 0)
684 if (File
->Label
!= 0)
685 Res
= Res
+ File
.Label() + ':';
687 if (File
->Archive
!= 0)
689 if (File
->Version
== 0)
690 Res
+= File
.Archive();
692 Res
= Res
+ File
.Version() + '/' + File
.Archive();
696 // No release file, print the host name that this came from
697 if (File
->Site
== 0 || File
.Site()[0] == 0)
704 Res
.append(" [").append(Arch()).append("]");
708 // PkgFileIterator::IsOk - Checks if the cache is in sync with the file /*{{{*/
709 // ---------------------------------------------------------------------
710 /* This stats the file and compares its stats with the ones that were
711 stored during generation. Date checks should probably also be
713 bool pkgCache::PkgFileIterator::IsOk()
716 if (stat(FileName(),&Buf
) != 0)
719 if (Buf
.st_size
!= (signed)S
->Size
|| Buf
.st_mtime
!= S
->mtime
)
725 // PkgFileIterator::RelStr - Return the release string /*{{{*/
726 // ---------------------------------------------------------------------
728 string
pkgCache::PkgFileIterator::RelStr()
732 Res
= Res
+ (Res
.empty() == true?"v=":",v=") + Version();
734 Res
= Res
+ (Res
.empty() == true?"o=":",o=") + Origin();
736 Res
= Res
+ (Res
.empty() == true?"a=":",a=") + Archive();
738 Res
= Res
+ (Res
.empty() == true?"n=":",n=") + Codename();
740 Res
= Res
+ (Res
.empty() == true?"l=":",l=") + Label();
741 if (Component() != 0)
742 Res
= Res
+ (Res
.empty() == true?"c=":",c=") + Component();
743 if (Architecture() != 0)
744 Res
= Res
+ (Res
.empty() == true?"b=":",b=") + Architecture();
748 // VerIterator::TranslatedDescription - Return the a DescIter for locale/*{{{*/
749 // ---------------------------------------------------------------------
750 /* return a DescIter for the current locale or the default if none is
753 pkgCache::DescIterator
pkgCache::VerIterator::TranslatedDescription() const
755 std::vector
<string
> const lang
= APT::Configuration::getLanguages();
756 for (std::vector
<string
>::const_iterator l
= lang
.begin();
757 l
!= lang
.end(); l
++)
759 pkgCache::DescIterator DescDefault
= DescriptionList();
760 pkgCache::DescIterator Desc
= DescDefault
;
762 for (; Desc
.end() == false; Desc
++)
763 if (*l
== Desc
.LanguageCode())
765 if (Desc
.end() == true)
770 return DescriptionList();