summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcachegen.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-09-13 17:52:22 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-09-13 17:52:22 +0200
commit74b220028595342028e3309002e4ec359af328f9 (patch)
tree0132b7fd4b4f5fa5e2dbce1f2e0fbeeff2c8e101 /apt-pkg/pkgcachegen.cc
parent650faab01603caac04494d54cf6b10a65c00ea13 (diff)
parentb11fe392b2245354591296df88c3be2e6218af12 (diff)
merge with debian/experimental
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r--apt-pkg/pkgcachegen.cc58
1 files changed, 37 insertions, 21 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 1cae23134..a39aa9f59 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -97,6 +97,7 @@ pkgCacheGenerator::~pkgCacheGenerator()
return;
Cache.HeaderP->Dirty = false;
+ Cache.HeaderP->CacheFileSize = Map.Size();
Map.Sync(0,sizeof(pkgCache::Header));
}
/*}}}*/
@@ -104,6 +105,9 @@ void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newM
if (oldMap == newMap)
return;
+ if (_config->FindB("Debug::pkgCacheGen", false))
+ std::clog << "Remaping from " << oldMap << " to " << newMap << std::endl;
+
Cache.ReMap(false);
CurrentFile += (pkgCache::PackageFile*) newMap - (pkgCache::PackageFile*) oldMap;
@@ -216,7 +220,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
// don't add a new description if we have one for the given
// md5 && language
- for ( ; Desc.end() == false; Desc++)
+ for ( ; Desc.end() == false; ++Desc)
if (MD5SumValue(Desc.md5()) == CurMd5 &&
Desc.LanguageCode() == List.DescriptionLanguage())
duplicate=true;
@@ -225,7 +229,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
for (Desc = Ver.DescriptionList();
Desc.end() == false;
- LastDesc = &Desc->NextDesc, Desc++)
+ LastDesc = &Desc->NextDesc, ++Desc)
{
if (MD5SumValue(Desc.md5()) == CurMd5)
{
@@ -391,7 +395,7 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List)
unsigned long Hash = List.VersionHash();
pkgCache::VerIterator Ver = Pkg.VersionList();
Dynamic<pkgCache::VerIterator> DynVer(Ver);
- for (; Ver.end() == false; Ver++)
+ for (; Ver.end() == false; ++Ver)
{
if (Ver->Hash == Hash && Version.c_str() == Ver.VerStr())
{
@@ -507,7 +511,7 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
// Link it to the end of the list
map_ptrloc *Last = &Ver->FileList;
- for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++)
+ for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; ++V)
Last = &V->NextFile;
VF->NextFile = *Last;
*Last = VF.Index();
@@ -564,7 +568,7 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
// Link it to the end of the list
map_ptrloc *Last = &Desc->FileList;
- for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++)
+ for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; ++D)
Last = &D->NextFile;
DF->NextFile = *Last;
@@ -619,7 +623,7 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
// Create Conflicts in between the group
pkgCache::GrpIterator G = GetCache().GrpBegin();
Dynamic<pkgCache::GrpIterator> DynG(G);
- for (; G.end() != true; G++)
+ for (; G.end() != true; ++G)
{
string const PkgName = G.Name();
pkgCache::PkgIterator P = G.PackageList();
@@ -630,9 +634,11 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
Dynamic<pkgCache::PkgIterator> DynallPkg(allPkg);
pkgCache::VerIterator V = P.VersionList();
Dynamic<pkgCache::VerIterator> DynV(V);
- for (; V.end() != true; V++)
+ for (; V.end() != true; ++V)
{
- char const * const Arch = P.Arch();
+ // copy P.Arch() into a string here as a cache remap
+ // in NewDepends() later may alter the pointer location
+ string Arch = P.Arch() == NULL ? "" : P.Arch();
map_ptrloc *OldDepLast = NULL;
/* MultiArch handling introduces a lot of implicit Dependencies:
- MultiArch: same → Co-Installable if they have the same version
@@ -641,7 +647,7 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
for (vector<string>::const_iterator A = archs.begin(); A != archs.end(); ++A)
{
- if (Arch == 0 || *A == Arch)
+ if (*A == Arch)
continue;
/* We allow only one installed arch at the time
per group, therefore each group member conflicts
@@ -683,7 +689,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
string const &Version,
unsigned int const &Op,
unsigned int const &Type,
- map_ptrloc *OldDepLast)
+ map_ptrloc* &OldDepLast)
{
void const * const oldMap = Map.Data();
// Get a structure
@@ -722,7 +728,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
if (OldDepLast == NULL)
{
OldDepLast = &Ver->DependsList;
- for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++)
+ for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D)
OldDepLast = &D->NextDepends;
} else if (oldMap != Map.Data())
OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
@@ -914,8 +920,11 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
/* This just verifies that each file in the list of index files exists,
has matching attributes with the cache and the cache does not have
any extra files. */
-static bool CheckValidity(const string &CacheFile, FileIterator Start,
- FileIterator End,MMap **OutMap = 0)
+static bool CheckValidity(const string &CacheFile,
+ pkgSourceList &List,
+ FileIterator Start,
+ FileIterator End,
+ MMap **OutMap = 0)
{
bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
// No file, certainly invalid
@@ -926,6 +935,13 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
return false;
}
+ if (List.GetLastModifiedTime() > GetModificationTime(CacheFile))
+ {
+ if (Debug == true)
+ std::clog << "sources.list is newer than the cache" << std::endl;
+ return false;
+ }
+
// Map it
FileFd CacheF(CacheFile,FileFd::ReadOnly);
SPtr<MMap> Map = new MMap(CacheF,0);
@@ -942,7 +958,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
verify the IMS data and check that it is on the disk too.. */
SPtrArray<bool> Visited = new bool[Cache.HeaderP->PackageFileCount];
memset(Visited,0,sizeof(*Visited)*Cache.HeaderP->PackageFileCount);
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
if (Debug == true)
std::clog << "Checking PkgFile " << (*Start)->Describe() << ": ";
@@ -1009,7 +1025,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
static unsigned long ComputeSize(FileIterator Start,FileIterator End)
{
unsigned long TotalSize = 0;
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
if ((*Start)->HasPackages() == false)
continue;
@@ -1027,7 +1043,7 @@ static bool BuildCache(pkgCacheGenerator &Gen,
FileIterator Start, FileIterator End)
{
FileIterator I;
- for (I = Start; I != End; I++)
+ for (I = Start; I != End; ++I)
{
if ((*I)->HasPackages() == false)
continue;
@@ -1057,7 +1073,7 @@ static bool BuildCache(pkgCacheGenerator &Gen,
Progress->Done();
TotalSize = ComputeSize(Start, End);
CurrentSize = 0;
- for (I = Start; I != End; I++)
+ for (I = Start; I != End; ++I)
{
unsigned long Size = (*I)->Size();
if (Progress != NULL)
@@ -1104,12 +1120,12 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
vector<pkgIndexFile *> Files;
for (vector<metaIndex *>::const_iterator i = List.begin();
i != List.end();
- i++)
+ ++i)
{
vector <pkgIndexFile *> *Indexes = (*i)->GetIndexFiles();
for (vector<pkgIndexFile *>::const_iterator j = Indexes->begin();
j != Indexes->end();
- j++)
+ ++j)
Files.push_back (*j);
}
@@ -1151,7 +1167,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
Progress->OverallProgress(0,1,1,_("Reading package lists"));
// Cache is OK, Fin.
- if (CheckValidity(CacheFile,Files.begin(),Files.end(),OutMap) == true)
+ if (CheckValidity(CacheFile, List, Files.begin(),Files.end(),OutMap) == true)
{
if (Progress != NULL)
Progress->OverallProgress(1,1,1,_("Reading package lists"));
@@ -1204,7 +1220,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
// Lets try the source cache.
unsigned long CurrentSize = 0;
unsigned long TotalSize = 0;
- if (CheckValidity(SrcCacheFile,Files.begin(),
+ if (CheckValidity(SrcCacheFile, List, Files.begin(),
Files.begin()+EndOfSource) == true)
{
if (Debug == true)