// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcache.cc,v 1.23 1999/02/23 06:46:24 jgg Exp $
+// $Id: pkgcache.cc,v 1.31 1999/12/10 23:40:29 jgg Exp $
/* ######################################################################
Package Cache - Accessor code for the cache
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/version.h>
#include <apt-pkg/error.h>
-#include <system.h>
+#include <apt-pkg/strutl.h>
#include <string>
#include <sys/stat.h>
#include <unistd.h>
+
+#include <system.h>
+
/*}}}*/
// Cache::Header::Header - Constructor /*{{{*/
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
- MajorVersion = 2;
- MinorVersion = 3;
+ MajorVersion = 3;
+ MinorVersion = 5;
Dirty = true;
HeaderSz = sizeof(pkgCache::Header);
{
unsigned long Hash = 0;
for (const char *I = Str.begin(); I != Str.end(); I++)
- Hash = 5*Hash + *I;
+ Hash = 5*Hash + tolower(*I);
return Hash % _count(HeaderP->HashTable);
}
{
unsigned long Hash = 0;
for (const char *I = Str; *I != 0; I++)
- Hash = 5*Hash + *I;
+ Hash = 5*Hash + tolower(*I);
return Hash % _count(HeaderP->HashTable);
}
for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage)
{
if (Pkg->Name != 0 && StrP[Pkg->Name] == Name[0] &&
- StrP + Pkg->Name == Name)
+ stringcasecmp(Name.begin(),Name.end(),StrP + Pkg->Name) == 0)
return PkgIterator(*this,Pkg);
-// cout << "b" << flush;
}
return PkgIterator(*this,0);
}
return 0;
}
/*}}}*/
+// Cache::GetCandidateVer - Returns the Candidate install version /*{{{*/
+// ---------------------------------------------------------------------
+/* The default just returns the highest available version that is not
+ a source and automatic */
+pkgCache::VerIterator pkgCache::GetCandidateVer(PkgIterator Pkg,
+ bool AllowCurrent)
+{
+ /* Not source/not automatic versions cannot be a candidate version
+ unless they are already installed */
+ VerIterator Last(*this,0);
+
+ for (VerIterator I = Pkg.VersionList(); I.end() == false; I++)
+ {
+ if (Pkg.CurrentVer() == I && AllowCurrent == true)
+ return I;
+
+ for (VerFileIterator J = I.FileList(); J.end() == false; J++)
+ {
+ if ((J.File()->Flags & Flag::NotSource) != 0)
+ continue;
+
+ /* Stash the highest version of a not-automatic source, we use it
+ if there is nothing better */
+ if ((J.File()->Flags & Flag::NotAutomatic) != 0)
+ {
+ if (Last.end() == true)
+ Last = I;
+ continue;
+ }
+
+ return I;
+ }
+ }
+
+ return Last;
+}
+ /*}}}*/
// Bases for iterator classes /*{{{*/
void pkgCache::VerIterator::_dummy() {}
Pkg->CurrentState == pkgCache::State::HalfConfigured)
return NeedsConfigure;
- if (Pkg->CurrentState == pkgCache::State::UnInstalled ||
- Pkg->CurrentState == pkgCache::State::HalfInstalled ||
+ if (Pkg->CurrentState == pkgCache::State::HalfInstalled ||
Pkg->InstState != pkgCache::State::Ok)
return NeedsUnpack;