// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcache.cc,v 1.10 1998/10/08 05:02:06 jgg Exp $
+// $Id: pkgcache.cc,v 1.22 1998/12/14 08:07:29 jgg Exp $
/* ######################################################################
Package Cache - Accessor code for the cache
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
MajorVersion = 2;
- MinorVersion = 0;
+ MinorVersion = 2;
Dirty = true;
HeaderSz = sizeof(pkgCache::Header);
VersionCount = 0;
DependsCount = 0;
PackageFileCount = 0;
+ VerFileCount = 0;
+ ProvidesCount = 0;
MaxVerFileSize = 0;
FileList = 0;
Package *Pkg = PkgP + HeaderP->HashTable[Hash(Name)];
for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
{
- if (Pkg->Name != 0 && StrP + Pkg->Name == Name)
+ if (Pkg->Name != 0 && StrP[Pkg->Name] == Name[0] &&
+ StrP + Pkg->Name == Name)
return PkgIterator(*this,Pkg);
}
return PkgIterator(*this,0);
// ---------------------------------------------------------------------
/* By this we mean if it is either cleanly installed or cleanly removed. */
pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const
-{
+{
+ if (Pkg->InstState == pkgCache::State::ReInstReq ||
+ Pkg->InstState == pkgCache::State::HoldReInstReq)
+ return NeedsUnpack;
+
if (Pkg->CurrentState == pkgCache::State::UnPacked ||
Pkg->CurrentState == pkgCache::State::HalfConfigured)
return NeedsConfigure;
conflicts. */
bool pkgCache::DepIterator::IsCritical()
{
- if (Dep->Type == Dep::Conflicts || Dep->Type == Dep::Depends ||
- Dep->Type == Dep::PreDepends)
+ if (Dep->Type == pkgCache::Dep::Conflicts ||
+ Dep->Type == pkgCache::Dep::Depends ||
+ Dep->Type == pkgCache::Dep::PreDepends)
return true;
return false;
}
// ---------------------------------------------------------------------
/* This is a more usefull version of TargetPkg() that follows versioned
provides. It includes every possible package-version that could satisfy
- the dependency. The last item in the list has a 0. */
+ the dependency. The last item in the list has a 0. The resulting pointer
+ must be delete [] 'd */
pkgCache::Version **pkgCache::DepIterator::AllTargets()
{
Version **Res = 0;
if (pkgCheckDep(TargetVer(),I.VerStr(),Dep->CompareOp) == false)
continue;
- if (Dep->Type == Dep::Conflicts && ParentPkg() == I.ParentPkg())
+ if (Dep->Type == pkgCache::Dep::Conflicts &&
+ ParentPkg() == I.ParentPkg())
continue;
Size++;
if (pkgCheckDep(TargetVer(),I.ProvideVersion(),Dep->CompareOp) == false)
continue;
- if (Dep->Type == Dep::Conflicts && ParentPkg() == I.OwnerPkg())
+ if (Dep->Type == pkgCache::Dep::Conflicts &&
+ ParentPkg() == I.OwnerPkg())
continue;
Size++;
const char *pkgCache::DepIterator::CompType()
{
const char *Ops[] = {"","<=",">=","<",">","=","!="};
- if ((Dep->CompareOp & 0xF) < sizeof(Ops))
+ if ((unsigned)(Dep->CompareOp & 0xF) < 7)
return Ops[Dep->CompareOp & 0xF];
return "";
}
/*}}}*/
+// DepIterator::DepType - Return a string describing the dep type /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+const char *pkgCache::DepIterator::DepType()
+{
+ const char *Types[] = {"","Depends","PreDepends","Suggests",
+ "Recommends","Conflicts","Replaces"};
+ if (Dep->Type < 7)
+ return Types[Dep->Type];
+ return "";
+}
+ /*}}}*/
+// DepIterator::GlobOr - Compute an OR group /*{{{*/
+// ---------------------------------------------------------------------
+/* This Takes an iterator, iterates past the current dependency grouping
+ and returns Start and End so that so End is the final element
+ in the group, if End == Start then D is End++ and End is the
+ dependency D was pointing to. Use in loops to iterate sensibly. */
+void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
+{
+ // Compute a single dependency element (glob or)
+ Start = *this;
+ End = *this;
+ for (bool LastOR = true; end() == false && LastOR == true;)
+ {
+ LastOR = (Dep->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
+ (*this)++;
+ if (LastOR == true)
+ End = (*this);
+ }
+}
+ /*}}}*/
// VerIterator::CompareVer - Fast version compare for same pkgs /*{{{*/
// ---------------------------------------------------------------------
/* This just looks over the version list to see if B is listed before A. In
{
VerFileIterator Files = FileList();
for (; Files.end() == false; Files++)
- if ((Files.File()->Flags & Flag::NotSource) != Flag::NotSource)
+ if ((Files.File()->Flags & pkgCache::Flag::NotSource) != pkgCache::Flag::NotSource)
+ return true;
+ return false;
+}
+ /*}}}*/
+// VerIterator::PriorityType - Return a string describing the priority /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+const char *pkgCache::VerIterator::PriorityType()
+{
+ const char *Types[] = {"","Important","Required","Standard",
+ "Optional","Extra"};
+ if (Ver->Priority < 6)
+ return Types[Ver->Priority];
+ return "";
+}
+ /*}}}*/
+// VerIterator::Automatic - Check if this version is 'automatic' /*{{{*/
+// ---------------------------------------------------------------------
+/* This checks to see if any of the versions files are not NotAutomatic.
+ True if this version is selectable for automatic installation. */
+bool pkgCache::VerIterator::Automatic() const
+{
+ VerFileIterator Files = FileList();
+ for (; Files.end() == false; Files++)
+ if ((Files.File()->Flags & pkgCache::Flag::NotAutomatic) != pkgCache::Flag::NotAutomatic)
return true;
return false;
}
/*}}}*/
+// VerIterator::NewestFile - Return the newest file version relation /*{{{*/
+// ---------------------------------------------------------------------
+/* This looks at the version numbers associated with all of the sources
+ this version is in and returns the highest.*/
+pkgCache::VerFileIterator pkgCache::VerIterator::NewestFile() const
+{
+ VerFileIterator Files = FileList();
+ VerFileIterator Highest = Files;
+ for (; Files.end() == false; Files++)
+ {
+ if (pkgVersionCompare(Files.File().Version(),Highest.File().Version()) > 0)
+ Highest = Files;
+ }
+
+ return Highest;
+}
+ /*}}}*/
// PkgFileIterator::IsOk - Checks if the cache is in sync with the file /*{{{*/
// ---------------------------------------------------------------------
/* This stats the file and compares its stats with the ones that were