Dirty = false;
HeaderSz = sizeof(pkgCache::Header);
+ GroupSz = sizeof(pkgCache::Group);
PackageSz = sizeof(pkgCache::Package);
PackageFileSz = sizeof(pkgCache::PackageFile);
VersionSz = sizeof(pkgCache::Version);
VerFileSz = sizeof(pkgCache::VerFile);
DescFileSz = sizeof(pkgCache::DescFile);
+ GroupCount = 0;
PackageCount = 0;
VersionCount = 0;
DescriptionCount = 0;
bool pkgCache::Header::CheckSizes(Header &Against) const
{
if (HeaderSz == Against.HeaderSz &&
+ GroupSz == Against.GroupSz &&
PackageSz == Against.PackageSz &&
PackageFileSz == Against.PackageFileSz &&
VersionSz == Against.VersionSz &&
/* Returns 0 on error, pointer to the package otherwise */
pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
if (MultiArchCache() == false) {
- if (Arch == "native" || Arch == "all" ||
+ if (Arch == "native" || Arch == "all" || Arch == "any" ||
Arch == _config->Find("APT::Architecture"))
return SingleArchFindPkg(Name);
else
break;
}
+ return PkgIterator(*Owner, 0);
+}
+ /*}}}*/
+// GrpIterator::FindPreferredPkg - Locate the "best" package /*{{{*/
+// ---------------------------------------------------------------------
+/* Returns an End-Pointer on error, pointer to the package otherwise */
+pkgCache::PkgIterator pkgCache::GrpIterator::FindPreferredPkg() {
+ pkgCache::PkgIterator Pkg = FindPkg("native");
+ if (Pkg.end() == false)
+ return Pkg;
+
+ std::vector<std::string> const archs = APT::Configuration::getArchitectures();
+ for (std::vector<std::string>::const_iterator a = archs.begin();
+ a != archs.end(); ++a) {
+ Pkg = FindPkg(*a);
+ if (Pkg.end() == false)
+ return Pkg;
+ }
+
return PkgIterator(*Owner, 0);
}
/*}}}*/
// GrpIterator::NextPkg - Locate the next package in the group /*{{{*/
// ---------------------------------------------------------------------
/* Returns an End-Pointer on error, pointer to the package otherwise.
- We can't simply ++ to the next as the list of packages includes
- "package noise" (= packages with the same hash value but different name) */
+ We can't simply ++ to the next as the next package of the last will
+ be from a different group (with the same hash value) */
pkgCache::PkgIterator pkgCache::GrpIterator::NextPkg(pkgCache::PkgIterator const &LastPkg) {
if (unlikely(IsGood() == false || S->FirstPackage == 0 ||
LastPkg.end() == true))
return PkgIterator(*Owner, 0);
- // Iterate over the list to find the next package
- pkgCache::Package *Pkg = Owner->PkgP + LastPkg.Index();
- Pkg = Owner->PkgP + Pkg->NextPackage;
- for (; Pkg != Owner->PkgP; Pkg = Owner->PkgP + Pkg->NextPackage) {
- if (S->Name == Pkg->Name)
- return PkgIterator(*Owner, Pkg);
- if ((Owner->PkgP + S->LastPackage) == Pkg)
- break;
- }
+ if (S->LastPackage == LastPkg.Index())
+ return PkgIterator(*Owner, 0);
- return PkgIterator(*Owner, 0);
+ return PkgIterator(*Owner, Owner->PkgP + LastPkg->NextPackage);
}
/*}}}*/
// GrpIterator::operator ++ - Postfix incr /*{{{*/
// ---------------------------------------------------------------------
/* This describes the version from a release-centric manner. The output is a
list of Label:Version/Archive */
-string pkgCache::VerIterator::RelStr()
+string pkgCache::VerIterator::RelStr() const
{
bool First = true;
string Res;