Browse Source

merged from donkult

tags/debian/0.8.0
Michael Vogt 11 years ago
parent
commit
358f10d9d4
38 changed files with 2097 additions and 1153 deletions
  1. +1
    -1
      apt-pkg/algorithms.h
  2. +4
    -0
      apt-pkg/aptconfiguration.cc
  3. +1
    -1
      apt-pkg/cachefile.cc
  4. +6
    -2
      apt-pkg/cachefile.h
  5. +31
    -16
      apt-pkg/cacheiterators.h
  6. +0
    -280
      apt-pkg/cacheset.cc
  7. +43
    -0
      apt-pkg/contrib/configuration.cc
  8. +18
    -1
      apt-pkg/contrib/configuration.h
  9. +187
    -180
      apt-pkg/contrib/error.cc
  10. +234
    -29
      apt-pkg/contrib/error.h
  11. +4
    -0
      apt-pkg/contrib/fileutl.cc
  12. +19
    -10
      apt-pkg/contrib/mmap.cc
  13. +1
    -0
      apt-pkg/deb/debindexfile.cc
  14. +18
    -21
      apt-pkg/deb/deblistparser.cc
  15. +10
    -8
      apt-pkg/deb/deblistparser.h
  16. +37
    -51
      apt-pkg/depcache.cc
  17. +10
    -20
      apt-pkg/depcache.h
  18. +5
    -0
      apt-pkg/init.cc
  19. +2
    -3
      apt-pkg/makefile
  20. +2
    -1
      apt-pkg/orderlist.cc
  21. +2
    -1
      apt-pkg/packagemanager.cc
  22. +10
    -7
      apt-pkg/pkgcache.cc
  23. +1
    -1
      apt-pkg/pkgcache.h
  24. +184
    -62
      apt-pkg/pkgcachegen.cc
  25. +34
    -12
      apt-pkg/pkgcachegen.h
  26. +1
    -1
      apt-pkg/policy.h
  27. +11
    -10
      cmdline/apt-cache.cc
  28. +6
    -8
      cmdline/apt-cdrom.cc
  29. +322
    -387
      cmdline/apt-get.cc
  30. +515
    -0
      cmdline/cacheset.cc
  31. +169
    -33
      cmdline/cacheset.h
  32. +2
    -2
      cmdline/makefile
  33. +44
    -2
      debian/changelog
  34. +1
    -1
      debian/control
  35. +9
    -0
      doc/apt.conf.5.xml
  36. +77
    -0
      test/libapt/globalerror_test.cc
  37. +8
    -2
      test/libapt/makefile
  38. +68
    -0
      test/libapt/parsedepends_test.cc

+ 1
- 1
apt-pkg/algorithms.h View File

@@ -48,7 +48,7 @@ class pkgSimulate : public pkgPackageManager /*{{{*/
pkgDepCache *Cache;
public:
virtual VerIterator GetCandidateVer(PkgIterator Pkg)
virtual VerIterator GetCandidateVer(PkgIterator const &Pkg)
{
return (*Cache)[Pkg].CandidateVerIter(*Cache);
}


+ 4
- 0
apt-pkg/aptconfiguration.cc View File

@@ -10,6 +10,7 @@
// Include Files /*{{{*/
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/strutl.h>
@@ -196,6 +197,9 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
// it was undocumented and so it should be not very widthly used
string const oldAcquire = _config->Find("APT::Acquire::Translation","");
if (oldAcquire.empty() == false && oldAcquire != "environment") {
// TRANSLATORS: the two %s are APT configuration options
_error->Notice("Option '%s' is deprecated. Please use '%s' instead, see 'man 5 apt.conf' for details.",
"APT::Acquire::Translation", "Acquire::Languages");
if (oldAcquire != "none")
codes.push_back(oldAcquire);
codes.push_back("en");


+ 1
- 1
apt-pkg/cachefile.cc View File

@@ -28,7 +28,7 @@
// ---------------------------------------------------------------------
/* */
pkgCacheFile::pkgCacheFile() : Map(NULL), Cache(NULL), DCache(NULL),
Policy(NULL), SrcList(NULL)
SrcList(NULL), Policy(NULL)
{
}
/*}}}*/


+ 6
- 2
apt-pkg/cachefile.h View File

@@ -20,10 +20,9 @@

#include <apt-pkg/depcache.h>
#include <apt-pkg/acquire.h>
#include <apt-pkg/policy.h>
#include <apt-pkg/sourcelist.h>

class pkgPolicy;
class pkgSourceList;
class pkgCacheFile
{
protected:
@@ -65,6 +64,11 @@ class pkgCacheFile
inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; };
inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; };

inline bool IsPkgCacheBuilt() const { return (Cache != NULL); };
inline bool IsDepCacheBuilt() const { return (DCache != NULL); };
inline bool IsPolicyBuilt() const { return (Policy != NULL); };
inline bool IsSrcListBuilt() const { return (SrcList != NULL); };

pkgCacheFile();
virtual ~pkgCacheFile();
};


+ 31
- 16
apt-pkg/cacheiterators.h View File

@@ -30,6 +30,8 @@
#ifndef PKGLIB_CACHEITERATORS_H
#define PKGLIB_CACHEITERATORS_H
#include<iterator>

#include<string.h>
// abstract Iterator template /*{{{*/
/* This template provides the very basic iterator methods we
need to have for doing some walk-over-the-cache magic */
@@ -73,6 +75,12 @@ template<typename Str, typename Itr> class pkgCache::Iterator :
inline bool IsGood() const { return S && Owner && ! end();};
inline unsigned long Index() const {return S - OwnerPointer();};

void ReOwn(pkgCache &newOwner, void const * const oldMap, void const * const newMap) {
if (S == 0)
return;
S += (Str*)(newMap) - (Str*)(oldMap);
}

// Constructors - look out for the variable assigning
inline Iterator() : S(0), Owner(0) {};
inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {};
@@ -103,13 +111,13 @@ class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {

inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;};
inline PkgIterator PackageList() const;
PkgIterator FindPkg(string Arch = "any");
PkgIterator FindPkg(string Arch = "any") const;
/** \brief find the package with the "best" architecture

The best architecture is either the "native" or the first
in the list of Architectures which is not an end-Pointer */
PkgIterator FindPreferredPkg();
PkgIterator NextPkg(PkgIterator const &Pkg);
PkgIterator FindPreferredPkg() const;
PkgIterator NextPkg(PkgIterator const &Pkg) const;

// Constructors
inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
@@ -183,6 +191,13 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {

// Comparison
int CompareVer(const VerIterator &B) const;
/** \brief compares two version and returns if they are similar

This method should be used to identify if two pseudo versions are
refering to the same "real" version */
inline bool SimilarVer(const VerIterator &B) const {
return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0);
};

// Accessors
inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;};
@@ -263,17 +278,17 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {

// Accessors
inline const char *TargetVer() const {return S->Version == 0?0:Owner->StrP + S->Version;};
inline PkgIterator TargetPkg() {return PkgIterator(*Owner,Owner->PkgP + S->Package);};
inline PkgIterator SmartTargetPkg() {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;};
inline VerIterator ParentVer() {return VerIterator(*Owner,Owner->VerP + S->ParentVer);};
inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);};
inline bool Reverse() {return Type == DepRev;};
bool IsCritical();
inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->Package);};
inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;};
inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);};
inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);};
inline bool Reverse() const {return Type == DepRev;};
bool IsCritical() const;
void GlobOr(DepIterator &Start,DepIterator &End);
Version **AllTargets();
bool SmartTargetPkg(PkgIterator &Result);
inline const char *CompType() {return Owner->CompType(S->CompareOp);};
inline const char *DepType() {return Owner->DepType(S->Type);};
Version **AllTargets() const;
bool SmartTargetPkg(PkgIterator &Result) const;
inline const char *CompType() const {return Owner->CompType(S->CompareOp);};
inline const char *DepType() const {return Owner->DepType(S->Type);};

inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) :
Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer) {
@@ -306,9 +321,9 @@ class pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
// Accessors
inline const char *Name() const {return Owner->StrP + Owner->PkgP[S->ParentPkg].Name;};
inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;};
inline PkgIterator ParentPkg() {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
inline VerIterator OwnerVer() {return VerIterator(*Owner,Owner->VerP + S->Version);};
inline PkgIterator OwnerPkg() {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);};
inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);};
inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);};

inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {};



+ 0
- 280
apt-pkg/cacheset.cc View File

@@ -1,280 +0,0 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
/* ######################################################################

Simple wrapper around a std::set to provide a similar interface to
a set of cache structures as to the complete set of all structures
in the pkgCache. Currently only Package is supported.

##################################################################### */
/*}}}*/
// Include Files /*{{{*/
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/versionmatch.h>

#include <apti18n.h>

#include <vector>

#include <regex.h>
/*}}}*/
namespace APT {
// FromRegEx - Return all packages in the cache matching a pattern /*{{{*/
PackageSet PackageSet::FromRegEx(pkgCacheFile &Cache, std::string pattern, std::ostream &out) {
PackageSet pkgset;
std::string arch = "native";
static const char * const isregex = ".?+*|[^$";

if (pattern.find_first_of(isregex) == std::string::npos)
return pkgset;

size_t archfound = pattern.find_last_of(':');
if (archfound != std::string::npos) {
arch = pattern.substr(archfound+1);
if (arch.find_first_of(isregex) == std::string::npos)
pattern.erase(archfound);
else
arch = "native";
}

regex_t Pattern;
int Res;
if ((Res = regcomp(&Pattern, pattern.c_str() , REG_EXTENDED | REG_ICASE | REG_NOSUB)) != 0) {
char Error[300];
regerror(Res, &Pattern, Error, sizeof(Error));
_error->Error(_("Regex compilation error - %s"), Error);
return pkgset;
}

for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp)
{
if (regexec(&Pattern, Grp.Name(), 0, 0, 0) != 0)
continue;
pkgCache::PkgIterator Pkg = Grp.FindPkg(arch);
if (Pkg.end() == true) {
if (archfound == std::string::npos) {
std::vector<std::string> archs = APT::Configuration::getArchitectures();
for (std::vector<std::string>::const_iterator a = archs.begin();
a != archs.end() && Pkg.end() != true; ++a)
Pkg = Grp.FindPkg(*a);
}
if (Pkg.end() == true)
continue;
}

ioprintf(out, _("Note, selecting %s for regex '%s'\n"),
Pkg.FullName(true).c_str(), pattern.c_str());

pkgset.insert(Pkg);
}

regfree(&Pattern);

return pkgset;
}
/*}}}*/
// GroupedFromCommandLine - Return all versions specified on commandline/*{{{*/
std::map<unsigned short, PackageSet> PackageSet::GroupedFromCommandLine(
pkgCacheFile &Cache, const char **cmdline,
std::list<PackageSet::Modifier> const &mods,
unsigned short const &fallback, std::ostream &out) {
std::map<unsigned short, PackageSet> pkgsets;
for (const char **I = cmdline; *I != 0; ++I) {
unsigned short modID = fallback;
std::string str = *I;
for (std::list<PackageSet::Modifier>::const_iterator mod = mods.begin();
mod != mods.end(); ++mod) {
size_t const alength = strlen(mod->Alias);
switch(mod->Pos) {
case PackageSet::Modifier::POSTFIX:
if (str.compare(str.length() - alength, alength,
mod->Alias, 0, alength) != 0)
continue;
str.erase(str.length() - alength);
modID = mod->ID;
break;
case PackageSet::Modifier::PREFIX:
continue;
case PackageSet::Modifier::NONE:
continue;
}
break;
}
PackageSet pset = PackageSet::FromString(Cache, str, out);
pkgsets[modID].insert(pset.begin(), pset.end());
}
return pkgsets;
}
/*}}}*/
// FromCommandLine - Return all packages specified on commandline /*{{{*/
PackageSet PackageSet::FromCommandLine(pkgCacheFile &Cache, const char **cmdline, std::ostream &out) {
PackageSet pkgset;
for (const char **I = cmdline; *I != 0; ++I) {
PackageSet pset = FromString(Cache, *I, out);
pkgset.insert(pset.begin(), pset.end());
}
return pkgset;
}
/*}}}*/
// FromString - Return all packages matching a specific string /*{{{*/
PackageSet PackageSet::FromString(pkgCacheFile &Cache, std::string const &str, std::ostream &out) {
std::string pkg = str;
size_t archfound = pkg.find_last_of(':');
std::string arch;
if (archfound != std::string::npos) {
arch = pkg.substr(archfound+1);
pkg.erase(archfound);
}

pkgCache::PkgIterator Pkg;
if (arch.empty() == true) {
pkgCache::GrpIterator Grp = Cache.GetPkgCache()->FindGrp(pkg);
if (Grp.end() == false)
Pkg = Grp.FindPreferredPkg();
} else
Pkg = Cache.GetPkgCache()->FindPkg(pkg, arch);

if (Pkg.end() == false) {
PackageSet pkgset;
pkgset.insert(Pkg);
return pkgset;
}
PackageSet regex = FromRegEx(Cache, str, out);
if (regex.empty() == true)
_error->Warning(_("Unable to locate package %s"), str.c_str());
return regex;
}
/*}}}*/
// FromCommandLine - Return all versions specified on commandline /*{{{*/
APT::VersionSet VersionSet::FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
APT::VersionSet::Version const &fallback, std::ostream &out) {
VersionSet verset;
for (const char **I = cmdline; *I != 0; ++I) {
std::string pkg = *I;
std::string ver;
bool verIsRel = false;
size_t const vertag = pkg.find_last_of("/=");
if (vertag != string::npos) {
ver = pkg.substr(vertag+1);
verIsRel = (pkg[vertag] == '/');
pkg.erase(vertag);
}
PackageSet pkgset = PackageSet::FromString(Cache, pkg.c_str(), out);
for (PackageSet::const_iterator P = pkgset.begin();
P != pkgset.end(); ++P) {
if (vertag == string::npos) {
AddSelectedVersion(Cache, verset, P, fallback);
continue;
}
pkgCache::VerIterator V;
if (ver == "installed")
V = getInstalledVer(Cache, P);
else if (ver == "candidate")
V = getCandidateVer(Cache, P);
else {
pkgVersionMatch Match(ver, (verIsRel == true ? pkgVersionMatch::Release :
pkgVersionMatch::Version));
V = Match.Find(P);
if (V.end() == true) {
if (verIsRel == true)
_error->Error(_("Release '%s' for '%s' was not found"),
ver.c_str(), P.FullName(true).c_str());
else
_error->Error(_("Version '%s' for '%s' was not found"),
ver.c_str(), P.FullName(true).c_str());
continue;
}
}
if (V.end() == true)
continue;
if (ver == V.VerStr())
ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"),
V.VerStr(), V.RelStr().c_str(), P.FullName(true).c_str());
verset.insert(V);
}
}
return verset;
}
/*}}}*/
// AddSelectedVersion - add version from package based on fallback /*{{{*/
bool VersionSet::AddSelectedVersion(pkgCacheFile &Cache, VersionSet &verset,
pkgCache::PkgIterator const &P, VersionSet::Version const &fallback,
bool const &AllowError) {
pkgCache::VerIterator V;
switch(fallback) {
case VersionSet::ALL:
if (P->VersionList != 0)
for (V = P.VersionList(); V.end() != true; ++V)
verset.insert(V);
else if (AllowError == false)
return _error->Error(_("Can't select versions from package '%s' as it purely virtual"), P.FullName(true).c_str());
else
return false;
break;
case VersionSet::CANDANDINST:
verset.insert(getInstalledVer(Cache, P, AllowError));
verset.insert(getCandidateVer(Cache, P, AllowError));
break;
case VersionSet::CANDIDATE:
verset.insert(getCandidateVer(Cache, P, AllowError));
break;
case VersionSet::INSTALLED:
verset.insert(getInstalledVer(Cache, P, AllowError));
break;
case VersionSet::CANDINST:
V = getCandidateVer(Cache, P, true);
if (V.end() == true)
V = getInstalledVer(Cache, P, true);
if (V.end() == false)
verset.insert(V);
else if (AllowError == false)
return _error->Error(_("Can't select installed nor candidate version from package '%s' as it has neither of them"), P.FullName(true).c_str());
else
return false;
break;
case VersionSet::INSTCAND:
V = getInstalledVer(Cache, P, true);
if (V.end() == true)
V = getCandidateVer(Cache, P, true);
if (V.end() == false)
verset.insert(V);
else if (AllowError == false)
return _error->Error(_("Can't select installed nor candidate version from package '%s' as it has neither of them"), P.FullName(true).c_str());
else
return false;
break;
case VersionSet::NEWEST:
if (P->VersionList != 0)
verset.insert(P.VersionList());
else if (AllowError == false)
return _error->Error(_("Can't select newest version from package '%s' as it is purely virtual"), P.FullName(true).c_str());
else
return false;
break;
}
return true;
}
/*}}}*/
// getCandidateVer - Returns the candidate version of the given package /*{{{*/
pkgCache::VerIterator VersionSet::getCandidateVer(pkgCacheFile &Cache,
pkgCache::PkgIterator const &Pkg, bool const &AllowError) {
if (unlikely(Cache.BuildDepCache() == false))
return pkgCache::VerIterator(*Cache);
pkgCache::VerIterator Cand = Cache[Pkg].CandidateVerIter(Cache);
if (AllowError == false && Cand.end() == true)
_error->Error(_("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str());
return Cand;
}
/*}}}*/
// getInstalledVer - Returns the installed version of the given package /*{{{*/
pkgCache::VerIterator VersionSet::getInstalledVer(pkgCacheFile &Cache,
pkgCache::PkgIterator const &Pkg, bool const &AllowError) {
if (AllowError == false && Pkg->CurrentVer == 0)
_error->Error(_("Can't select installed version from package %s as it is not installed"), Pkg.FullName(true).c_str());
return Pkg.CurrentVer();
}
/*}}}*/
}

+ 43
- 0
apt-pkg/contrib/configuration.cc View File

@@ -843,3 +843,46 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir,
return true;
}
/*}}}*/
// MatchAgainstConfig Constructor /*{{{*/
Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config)
{
std::vector<std::string> const strings = _config->FindVector(Config);
for (std::vector<std::string>::const_iterator s = strings.begin();
s != strings.end(); ++s)
{
regex_t *p = new regex_t;
if (regcomp(p, s->c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB) == 0)
patterns.push_back(p);
else
{
regfree(p);
delete p;
_error->Warning("Regex compilation error for '%s' in configuration option '%s'",
s->c_str(), Config);
}
}

}
/*}}}*/
// MatchAgainstConfig Destructor /*{{{*/
Configuration::MatchAgainstConfig::~MatchAgainstConfig()
{
for(std::vector<regex_t *>::const_iterator p = patterns.begin();
p != patterns.end(); ++p)
{
regfree(*p);
delete *p;
}
}
/*}}}*/
// MatchAgainstConfig::Match - returns true if a pattern matches /*{{{*/
bool Configuration::MatchAgainstConfig::Match(char const * str) const
{
for(std::vector<regex_t *>::const_iterator p = patterns.begin();
p != patterns.end(); ++p)
if (regexec(*p, str, 0, 0, 0) == 0)
return true;

return false;
}
/*}}}*/

+ 18
- 1
apt-pkg/contrib/configuration.h View File

@@ -28,7 +28,7 @@
#ifndef PKGLIB_CONFIGURATION_H
#define PKGLIB_CONFIGURATION_H

#include <regex.h>

#include <string>
#include <vector>
@@ -104,6 +104,23 @@ class Configuration
Configuration(const Item *Root);
Configuration();
~Configuration();

/** \brief match a string against a configurable list of patterns */
class MatchAgainstConfig
{
std::vector<regex_t *> patterns;

public:
MatchAgainstConfig(char const * Config);
virtual ~MatchAgainstConfig();

/** \brief Returns \b true for a string matching one of the patterns */
bool Match(char const * str) const;
bool Match(std::string const &str) const { return Match(str.c_str()); };

/** \brief returns if the matcher setup was successful */
bool wasConstructedSuccessfully() const { return patterns.empty() == false; }
};
};

extern Configuration *_config;


+ 187
- 180
apt-pkg/contrib/error.cc View File

@@ -1,16 +1,15 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// $Id: error.cc,v 1.11 2002/03/26 07:38:58 jgg Exp $
/* ######################################################################
Global Erorr Class - Global error mechanism
Global Error Class - Global error mechanism

We use a simple STL vector to store each error record. A PendingFlag
is kept which indicates when the vector contains a Sever error.
This source is placed in the Public Domain, do with it what you will
It was originally written by Jason Gunthorpe.
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
@@ -19,7 +18,6 @@
#include <iostream>
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>

#include <string>
@@ -28,209 +26,218 @@
#include "config.h"
/*}}}*/

using namespace std;

// Global Error Object /*{{{*/
/* If the implementation supports posix threads then the accessor function
is compiled to be thread safe otherwise a non-safe version is used. A
Per-Thread error object is maintained in much the same manner as libc
manages errno */
#if defined(_POSIX_THREADS) && defined(HAVE_PTHREAD)
#include <pthread.h>

static pthread_key_t ErrorKey;
static void ErrorDestroy(void *Obj) {delete (GlobalError *)Obj;};
static void KeyAlloc() {pthread_key_create(&ErrorKey,ErrorDestroy);};

GlobalError *_GetErrorObj()
{
static pthread_once_t Once = PTHREAD_ONCE_INIT;
pthread_once(&Once,KeyAlloc);
void *Res = pthread_getspecific(ErrorKey);
if (Res == 0)
pthread_setspecific(ErrorKey,Res = new GlobalError);
return (GlobalError *)Res;
}
#include <pthread.h>

static pthread_key_t ErrorKey;
static void ErrorDestroy(void *Obj) {delete (GlobalError *)Obj;};
static void KeyAlloc() {pthread_key_create(&ErrorKey,ErrorDestroy);};

GlobalError *_GetErrorObj() {
static pthread_once_t Once = PTHREAD_ONCE_INIT;
pthread_once(&Once,KeyAlloc);

void *Res = pthread_getspecific(ErrorKey);
if (Res == 0)
pthread_setspecific(ErrorKey,Res = new GlobalError);
return (GlobalError *)Res;
}
#else
GlobalError *_GetErrorObj()
{
static GlobalError *Obj = new GlobalError;
return Obj;
}
GlobalError *_GetErrorObj() {
static GlobalError *Obj = new GlobalError;
return Obj;
}
#endif
/*}}}*/

// GlobalError::GlobalError - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
GlobalError::GlobalError() : List(0), PendingFlag(false)
{
GlobalError::GlobalError() : PendingFlag(false) {}
/*}}}*/
// GlobalError::FatalE - Get part of the error string from errno /*{{{*/
bool GlobalError::FatalE(const char *Function,const char *Description,...) {
va_list args;
va_start(args,Description);
return InsertErrno(FATAL, Function, Description, args);
}
/*}}}*/
// GlobalError::Errno - Get part of the error string from errno /*{{{*/
// ---------------------------------------------------------------------
/* Function indicates the stdlib function that failed and Description is
a user string that leads the text. Form is:
Description - Function (errno: strerror)
Carefull of the buffer overrun, sprintf.
*/
bool GlobalError::Errno(const char *Function,const char *Description,...)
{
va_list args;
va_start(args,Description);

// sprintf the description
char S[400];
vsnprintf(S,sizeof(S),Description,args);
snprintf(S + strlen(S),sizeof(S) - strlen(S),
" - %s (%i: %s)",Function,errno,strerror(errno));

// Put it on the list
Item *Itm = new Item;
Itm->Text = S;
Itm->Error = true;
Insert(Itm);

PendingFlag = true;

return false;
}
/*}}}*/
// GlobalError::WarningE - Get part of the warn string from errno /*{{{*/
// ---------------------------------------------------------------------
/* Function indicates the stdlib function that failed and Description is
a user string that leads the text. Form is:
Description - Function (errno: strerror)
Carefull of the buffer overrun, sprintf.
*/
bool GlobalError::WarningE(const char *Function,const char *Description,...)
{
va_list args;
va_start(args,Description);

// sprintf the description
char S[400];
vsnprintf(S,sizeof(S),Description,args);
snprintf(S + strlen(S),sizeof(S) - strlen(S),
" - %s (%i: %s)",Function,errno,strerror(errno));

// Put it on the list
Item *Itm = new Item;
Itm->Text = S;
Itm->Error = false;
Insert(Itm);

return false;
bool GlobalError::Errno(const char *Function,const char *Description,...) {
va_list args;
va_start(args,Description);
return InsertErrno(ERROR, Function, Description, args);
}
/*}}}*/
// GlobalError::WarningE - Get part of the warning string from errno /*{{{*/
bool GlobalError::WarningE(const char *Function,const char *Description,...) {
va_list args;
va_start(args,Description);
return InsertErrno(WARNING, Function, Description, args);
}
/*}}}*/
// GlobalError::NoticeE - Get part of the notice string from errno /*{{{*/
bool GlobalError::NoticeE(const char *Function,const char *Description,...) {
va_list args;
va_start(args,Description);
return InsertErrno(NOTICE, Function, Description, args);
}
/*}}}*/
// GlobalError::DebugE - Get part of the debug string from errno /*{{{*/
bool GlobalError::DebugE(const char *Function,const char *Description,...) {
va_list args;
va_start(args,Description);
return InsertErrno(DEBUG, Function, Description, args);
}
/*}}}*/
// GlobalError::InsertErrno - formats an error message with the errno /*{{{*/
bool GlobalError::InsertErrno(MsgType type, const char* Function,
const char* Description, va_list const &args) {
char S[400];
vsnprintf(S,sizeof(S),Description,args);
snprintf(S + strlen(S),sizeof(S) - strlen(S),
" - %s (%i: %s)", Function, errno, strerror(errno));
return Insert(type, S, args);
}
/*}}}*/
// GlobalError::Fatal - Add a fatal error to the list /*{{{*/
bool GlobalError::Fatal(const char *Description,...) {
va_list args;
va_start(args,Description);
return Insert(FATAL, Description, args);
}
/*}}}*/
// GlobalError::Error - Add an error to the list /*{{{*/
// ---------------------------------------------------------------------
/* Just vsprintfs and pushes */
bool GlobalError::Error(const char *Description,...)
{
va_list args;
va_start(args,Description);

// sprintf the description
char S[400];
vsnprintf(S,sizeof(S),Description,args);

// Put it on the list
Item *Itm = new Item;
Itm->Text = S;
Itm->Error = true;
Insert(Itm);
PendingFlag = true;
return false;
bool GlobalError::Error(const char *Description,...) {
va_list args;
va_start(args,Description);
return Insert(ERROR, Description, args);
}
/*}}}*/
// GlobalError::Warning - Add a warning to the list /*{{{*/
// ---------------------------------------------------------------------
/* This doesn't set the pending error flag */
bool GlobalError::Warning(const char *Description,...)
bool GlobalError::Warning(const char *Description,...) {
va_list args;
va_start(args,Description);
return Insert(WARNING, Description, args);
}
/*}}}*/
// GlobalError::Notice - Add a notice to the list /*{{{*/
bool GlobalError::Notice(const char *Description,...)
{
va_list args;
va_start(args,Description);
va_list args;
va_start(args,Description);
return Insert(NOTICE, Description, args);
}
/*}}}*/
// GlobalError::Debug - Add a debug to the list /*{{{*/
bool GlobalError::Debug(const char *Description,...)
{
va_list args;
va_start(args,Description);
return Insert(DEBUG, Description, args);
}
/*}}}*/
// GlobalError::Insert - Insert a new item at the end /*{{{*/
bool GlobalError::Insert(MsgType type, const char* Description,
va_list const &args) {
char S[400];
vsnprintf(S,sizeof(S),Description,args);

Item const m(S, type);
Messages.push_back(m);

if (type == ERROR || type == FATAL)
PendingFlag = true;

// sprintf the description
char S[400];
vsnprintf(S,sizeof(S),Description,args);
if (type == FATAL || type == DEBUG)
std::clog << m << std::endl;

// Put it on the list
Item *Itm = new Item;
Itm->Text = S;
Itm->Error = false;
Insert(Itm);
return false;
return false;
}
/*}}}*/
// GlobalError::PopMessage - Pulls a single message out /*{{{*/
// ---------------------------------------------------------------------
/* This should be used in a loop checking empty() each cycle. It returns
true if the message is an error. */
bool GlobalError::PopMessage(string &Text)
{
if (List == 0)
return false;
bool Ret = List->Error;
Text = List->Text;
Item *Old = List;
List = List->Next;
delete Old;
// This really should check the list to see if only warnings are left..
if (List == 0)
PendingFlag = false;
return Ret;
bool GlobalError::PopMessage(std::string &Text) {
if (Messages.empty() == true)
return false;

Item const msg = Messages.front();
Messages.pop_front();

bool const Ret = (msg.Type == ERROR || msg.Type == FATAL);
Text = msg.Text;
if (PendingFlag == false || Ret == false)
return Ret;

// check if another error message is pending
for (std::list<Item>::const_iterator m = Messages.begin();
m != Messages.end(); m++)
if (m->Type == ERROR || m->Type == FATAL)
return Ret;

PendingFlag = false;
return Ret;
}
/*}}}*/
// GlobalError::DumpErrors - Dump all of the errors/warns to cerr /*{{{*/
// ---------------------------------------------------------------------
/* */
void GlobalError::DumpErrors()
{
// Print any errors or warnings found
string Err;
while (empty() == false)
{
bool Type = PopMessage(Err);
if (Type == true)
cerr << "E: " << Err << endl;
else
cerr << "W: " << Err << endl;
}
}
/*}}}*/
// GlobalError::Discard - Discard /*{{{*/
// ---------------------------------------------------------------------
/* */
void GlobalError::Discard()
{
while (List != 0)
{
Item *Old = List;
List = List->Next;
delete Old;
}
PendingFlag = false;
void GlobalError::DumpErrors(std::ostream &out, MsgType const &trashhold,
bool const &mergeStack) {
if (mergeStack == true)
for (std::list<MsgStack>::const_reverse_iterator s = Stacks.rbegin();
s != Stacks.rend(); ++s)
Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end());

for (std::list<Item>::const_iterator m = Messages.begin();
m != Messages.end(); m++)
if (m->Type >= trashhold)
out << (*m) << std::endl;
Discard();
}
/*}}}*/
// GlobalError::Discard - Discard /*{{{*/
void GlobalError::Discard() {
Messages.clear();
PendingFlag = false;
};
/*}}}*/
// GlobalError::Insert - Insert a new item at the end /*{{{*/
// ---------------------------------------------------------------------
/* */
void GlobalError::Insert(Item *Itm)
{
Item **End = &List;
for (Item *I = List; I != 0; I = I->Next)
End = &I->Next;
Itm->Next = *End;
*End = Itm;
// GlobalError::empty - does our error list include anything? /*{{{*/
bool GlobalError::empty(MsgType const &trashhold) const {
if (PendingFlag == true)
return false;

if (Messages.empty() == true)
return true;

for (std::list<Item>::const_iterator m = Messages.begin();
m != Messages.end(); m++)
if (m->Type >= trashhold)
return false;

return true;
}
/*}}}*/
// GlobalError::PushToStack /*{{{*/
void GlobalError::PushToStack() {
MsgStack pack(Messages, PendingFlag);
Stacks.push_back(pack);
Discard();
}
/*}}}*/
// GlobalError::RevertToStack /*{{{*/
void GlobalError::RevertToStack() {
Discard();
MsgStack pack = Stacks.back();
Messages = pack.Messages;
PendingFlag = pack.PendingFlag;
Stacks.pop_back();
}
/*}}}*/
// GlobalError::MergeWithStack /*{{{*/
void GlobalError::MergeWithStack() {
MsgStack pack = Stacks.back();
Messages.insert(Messages.begin(), pack.Messages.begin(), pack.Messages.end());
PendingFlag = PendingFlag || pack.PendingFlag;
Stacks.pop_back();
}
/*}}}*/

+ 234
- 29
apt-pkg/contrib/error.h View File

@@ -42,43 +42,248 @@

#include <apt-pkg/macros.h>

#include <iostream>
#include <list>
#include <string>

class GlobalError
#include <stdarg.h>

class GlobalError /*{{{*/
{
struct Item
{
std::string Text;
bool Error;
Item *Next;
};
Item *List;
bool PendingFlag;
void Insert(Item *I);
public:
public: /*{{{*/
/** \brief a message can have one of following severity */
enum MsgType {
/** \brief Message will be printed instantly as it is likely that
this error will lead to a complete crash */
FATAL = 40,
/** \brief An error does hinder the correct execution and should be corrected */
ERROR = 30,
/** \brief indicates problem that can lead to errors later on */
WARNING = 20,
/** \brief deprecation warnings, old fallback behavior, … */
NOTICE = 10,
/** \brief for developers only in areas it is hard to print something directly */
DEBUG = 0
};

// Call to generate an error from a library call.
bool Errno(const char *Function,const char *Description,...) __like_printf(3) __cold;
bool WarningE(const char *Function,const char *Description,...) __like_printf(3) __cold;
/** \brief add a fatal error message with errno to the list
*
* \param Function name of the function generating the error
* \param Description format string for the error message
*
* \return \b false
*/
bool FatalE(const char *Function,const char *Description,...) __like_printf(3) __cold;

/* A warning should be considered less severe than an error, and may be
ignored by the client. */
bool Error(const char *Description,...) __like_printf(2) __cold;
bool Warning(const char *Description,...) __like_printf(2) __cold;
/** \brief add an Error message with errno to the list
*
* \param Function name of the function generating the error
* \param Description format string for the error message
*
* \return \b false
*/
bool Errno(const char *Function,const char *Description,...) __like_printf(3) __cold;

// Simple accessors
inline bool PendingError() {return PendingFlag;};
inline bool empty() {return List == 0;};
bool PopMessage(std::string &Text);
void Discard();
/** \brief add a warning message with errno to the list
*
* A warning should be considered less severe than an error and
* may be ignored by the client.
*
* \param Function Name of the function generates the warning.
* \param Description Format string for the warning message.
*
* \return \b false
*/
bool WarningE(const char *Function,const char *Description,...) __like_printf(3) __cold;

// Usefull routine to dump to cerr
void DumpErrors();
GlobalError();
/** \brief add a notice message with errno to the list
*
* \param Function name of the function generating the error
* \param Description format string for the error message
*
* \return \b false
*/
bool NoticeE(const char *Function,const char *Description,...) __like_printf(3) __cold;

/** \brief add a debug message with errno to the list
*
* \param Function name of the function generating the error
* \param Description format string for the error message
*
* \return \b false
*/
bool DebugE(const char *Function,const char *Description,...) __like_printf(3) __cold;

/** \brief add an fatal error message to the list
*
* Most of the stuff we consider as "error" is also "fatal" for
* the user as the application will not have the expected result,
* but a fatal message here means that it gets printed directly
* to stderr in addiction to adding it to the list as the error
* leads sometimes to crashes and a maybe duplicated message
* is better than "Segfault" as the only displayed text
*
* \param Description Format string for the fatal error message.
*
* \return \b false
*/
bool Fatal(const char *Description,...) __like_printf(2) __cold;

/** \brief add an Error message to the list
*
* \param Description Format string for the error message.
*
* \return \b false
*/
bool Error(const char *Description,...) __like_printf(2) __cold;

/** \brief add a warning message to the list
*
* A warning should be considered less severe than an error and
* may be ignored by the client.
*
* \param Description Format string for the message
*
* \return \b false
*/
bool Warning(const char *Description,...) __like_printf(2) __cold;

/** \brief add a notice message to the list
*
* A notice should be considered less severe than an error or a
* warning and can be ignored by the client without further problems
* for some times, but he should consider fixing the problem.
* This error type can be used for e.g. deprecation warnings of options.
*
* \param Description Format string for the message
*
* \return \b false
*/
bool Notice(const char *Description,...) __like_printf(2) __cold;

/** \brief add a debug message to the list
*
* \param Description Format string for the message
*
* \return \b false
*/
bool Debug(const char *Description,...) __like_printf(2) __cold;

/** \brief is an error in the list?
*
* \return \b true if an error is included in the list, \b false otherwise
*/
inline bool PendingError() const {return PendingFlag;};

/** \brief is the list empty?
*
* The default checks if the list is empty or contains only notices,
* if you want to check if also no notices happend set the parameter
* flag to \b false.
*
* \param WithoutNotice does notices count, default is \b true, so no
*
* \return \b true if an the list is empty, \b false otherwise
*/
bool empty(MsgType const &trashhold = WARNING) const;

/** \brief returns and removes the first (or last) message in the list
*
* \param[out] Text message of the first/last item
*
* \return \b true if the message was an error, \b false otherwise
*/
bool PopMessage(std::string &Text);

/** \brief clears the list of messages */
void Discard();

/** \brief outputs the list of messages to the given stream
*
* Note that all messages are discarded, also the notices
* displayed or not.
*
* \param[out] out output stream to write the messages in
* \param WithoutNotice output notices or not
*/
void DumpErrors(std::ostream &out, MsgType const &trashhold = WARNING,
bool const &mergeStack = true);

/** \brief dumps the list of messages to std::cerr
*
* Note that all messages are discarded, also the notices
* displayed or not.
*
* \param WithoutNotice print notices or not
*/
void inline DumpErrors(MsgType const &trashhold = WARNING) {
DumpErrors(std::cerr, trashhold);
}

/** \brief put the current Messages into the stack
*
* All "old" messages will be pushed into a stack to
* them later back, but for now the Message query will be
* empty and performs as no messages were present before.
*
* The stack can be as deep as you want - all stack operations
* will only operate on the last element in the stack.
*/
void PushToStack();

/** \brief throw away all current messages */
void RevertToStack();

/** \brief merge current and stack together */
void MergeWithStack();

/** \brief return the deep of the stack */
size_t StackCount() const {
return Stacks.size();
}

GlobalError();
/*}}}*/
private: /*{{{*/
struct Item {
std::string Text;
MsgType Type;

Item(char const *Text, MsgType const &Type) :
Text(Text), Type(Type) {};

friend std::ostream& operator<< (std::ostream &out, Item i) {
switch(i.Type) {
case FATAL:
case ERROR: out << "E"; break;
case WARNING: out << "W"; break;
case NOTICE: out << "N"; break;
case DEBUG: out << "D"; break;
}
return out << ": " << i.Text;
}
};

std::list<Item> Messages;
bool PendingFlag;

struct MsgStack {
std::list<Item> const Messages;
bool const PendingFlag;

MsgStack(std::list<Item> const &Messages, bool const &Pending) :
Messages(Messages), PendingFlag(Pending) {};
};

std::list<MsgStack> Stacks;

bool InsertErrno(MsgType type, const char* Function,
const char* Description, va_list const &args);
bool Insert(MsgType type, const char* Description,
va_list const &args);
/*}}}*/
};
/*}}}*/

// The 'extra-ansi' syntax is used to help with collisions.
GlobalError *_GetErrorObj();


+ 4
- 0
apt-pkg/contrib/fileutl.cc View File

@@ -282,6 +282,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
}

std::vector<string> List;
Configuration::MatchAgainstConfig SilentIgnore("Dir::Ignore-Files-Silently");
DIR *D = opendir(Dir.c_str());
if (D == 0)
{
@@ -307,6 +308,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
{
if (Debug == true)
std::clog << "Bad file: " << Ent->d_name << " → no extension" << std::endl;
_error->Notice("Ignoring file '%s' in directory '%s' as it has no filename extension", Ent->d_name, Dir.c_str());
continue;
}
}
@@ -314,6 +316,8 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
{
if (Debug == true)
std::clog << "Bad file: " << Ent->d_name << " → bad extension »" << flExtension(Ent->d_name) << "«" << std::endl;
if (SilentIgnore.Match(Ent->d_name) == false)
_error->Notice("Ignoring file '%s' in directory '%s' as it has an invalid filename extension", Ent->d_name, Dir.c_str());
continue;
}
}


+ 19
- 10
apt-pkg/contrib/mmap.cc View File

@@ -225,22 +225,22 @@ DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long const &WorkSpace,

// disable Moveable if we don't grow
if (Grow == 0)
Flags &= ~Moveable;
this->Flags &= ~Moveable;

#ifndef __linux__
// kfreebsd doesn't have mremap, so we use the fallback
if ((Flags & Moveable) == Moveable)
Flags |= Fallback;
if ((this->Flags & Moveable) == Moveable)
this->Flags |= Fallback;
#endif

#ifdef _POSIX_MAPPED_FILES
if ((Flags & Fallback) != Fallback) {
if ((this->Flags & Fallback) != Fallback) {
// Set the permissions.
int Prot = PROT_READ;
int Map = MAP_PRIVATE | MAP_ANONYMOUS;
if ((Flags & ReadOnly) != ReadOnly)
if ((this->Flags & ReadOnly) != ReadOnly)
Prot |= PROT_WRITE;
if ((Flags & Public) == Public)
if ((this->Flags & Public) == Public)
Map = MAP_SHARED | MAP_ANONYMOUS;

// use anonymous mmap() to get the memory
@@ -297,7 +297,7 @@ unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln)
{
if(!Grow())
{
_error->Error(_("Dynamic MMap ran out of room. Please increase the size "
_error->Fatal(_("Dynamic MMap ran out of room. Please increase the size "
"of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace);
return 0;
}
@@ -314,7 +314,7 @@ unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
// Look for a matching pool entry
Pool *I;
Pool *Empty = 0;
for (I = Pools; I != Pools + PoolCount; I++)
for (I = Pools; I != Pools + PoolCount; ++I)
{
if (I->ItemSize == 0)
Empty = I;
@@ -342,7 +342,11 @@ unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
{
const unsigned long size = 20*1024;
I->Count = size/ItemSize;
Pool* oldPools = Pools;
Result = RawAllocate(size,ItemSize);
if (Pools != oldPools)
I += Pools - oldPools;

// Does the allocation failed ?
if (Result == 0 && _error->PendingError())
return 0;
@@ -365,7 +369,7 @@ unsigned long DynamicMMap::WriteString(const char *String,
if (Len == (unsigned long)-1)
Len = strlen(String);

unsigned long Result = RawAllocate(Len+1,0);
unsigned long const Result = RawAllocate(Len+1,0);

if (Result == 0 && _error->PendingError())
return 0;
@@ -395,16 +399,20 @@ bool DynamicMMap::Grow() {
return _error->Error(_("Unable to increase the size of the MMap as the "
"limit of %lu bytes is already reached."), Limit);

unsigned long const newSize = WorkSpace + 1024*1024;
unsigned long const newSize = WorkSpace + GrowFactor;

if(Fd != 0) {
Fd->Seek(newSize - 1);
char C = 0;
Fd->Write(&C,sizeof(C));
}

unsigned long const poolOffset = Pools - ((Pool*) Base);

if ((Flags & Fallback) != Fallback) {
#if defined(_POSIX_MAPPED_FILES) && defined(__linux__)
#ifdef MREMAP_MAYMOVE

if ((Flags & Moveable) == Moveable)
Base = mremap(Base, WorkSpace, newSize, MREMAP_MAYMOVE);
else
@@ -425,6 +433,7 @@ bool DynamicMMap::Grow() {
return false;
}

Pools =(Pool*) Base + poolOffset;
WorkSpace = newSize;
return true;
}


+ 1
- 0
apt-pkg/deb/debindexfile.cc View File

@@ -277,6 +277,7 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const

// Store the IMS information
pkgCache::PkgFileIterator File = Gen.GetCurFile();
pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(File);
struct stat St;
if (fstat(Pkg.Fd(),&St) != 0)
return _error->Errno("fstat","Failed to stat");


+ 18
- 21
apt-pkg/deb/deblistparser.cc View File

@@ -39,6 +39,8 @@ debListParser::debListParser(FileFd *File, string const &Arch) : Tags(File),
Arch(Arch) {
if (Arch == "native")
this->Arch = _config->Find("APT::Architecture");
Architectures = APT::Configuration::getArchitectures();
MultiArchEnabled = Architectures.size() > 1;
}
/*}}}*/
// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
@@ -104,7 +106,7 @@ string debListParser::Version()
// ListParser::NewVersion - Fill in the version structure /*{{{*/
// ---------------------------------------------------------------------
/* */
bool debListParser::NewVersion(pkgCache::VerIterator Ver)
bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
{
// Parse the section
Ver->Section = UniqFindTagWrite("Section");
@@ -156,10 +158,9 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
to a NOP in the download/install step - this package will ensure that
it is downloaded only one time and installed only one time -- even if
the architecture bound versions coming in and out on regular basis. */
bool const static multiArch = APT::Configuration::getArchitectures().size() > 1;
if (strcmp(Ver.Arch(true),"all") == 0)
return true;
else if (multiArch == true)
else if (MultiArchEnabled == true)
{
// our pseudo packages have no size to not confuse the fetcher
Ver->Size = 0;
@@ -250,8 +251,8 @@ MD5SumValue debListParser::Description_md5()
// ---------------------------------------------------------------------
/* This is called to update the package with any new information
that might be found in the section */
bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
pkgCache::VerIterator Ver)
bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver)
{
if (Pkg->Section == 0)
Pkg->Section = UniqFindTagWrite("Section");
@@ -331,8 +332,8 @@ unsigned short debListParser::VersionHash()
Some of the above are obsolete (I think?) flag = hold-* and
status = post-inst-failed, removal-failed at least.
*/
bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg,
pkgCache::VerIterator Ver)
bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver)
{
const char *Start;
const char *Stop;
@@ -633,7 +634,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
// ---------------------------------------------------------------------
/* This is the higher level depends parser. It takes a tag and generates
a complete depends tree for the given version. */
bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
const char *Tag,unsigned int Type)
{
const char *Start;
@@ -641,9 +642,6 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
if (Section.Find(Tag,Start,Stop) == false)
return true;

static std::vector<std::string> const archs = APT::Configuration::getArchitectures();
static bool const multiArch = archs.size() <= 1;

string Package;
string const pkgArch = Ver.Arch(true);
string Version;
@@ -655,13 +653,13 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
if (Start == 0)
return _error->Error("Problem parsing dependency %s",Tag);

if (multiArch == true &&
if (MultiArchEnabled == true &&
(Type == pkgCache::Dep::Conflicts ||
Type == pkgCache::Dep::DpkgBreaks ||
Type == pkgCache::Dep::Replaces))
{
for (std::vector<std::string>::const_iterator a = archs.begin();
a != archs.end(); ++a)
for (std::vector<std::string>::const_iterator a = Architectures.begin();
a != Architectures.end(); ++a)
if (NewDepends(Ver,Package,*a,Version,Op,Type) == false)
return false;
}
@@ -676,7 +674,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
// ListParser::ParseProvides - Parse the provides list /*{{{*/
// ---------------------------------------------------------------------
/* */
bool debListParser::ParseProvides(pkgCache::VerIterator Ver)
bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
{
const char *Start;
const char *Stop;
@@ -713,14 +711,13 @@ bool debListParser::ParseProvides(pkgCache::VerIterator Ver)
if (Ver->MultiArch != pkgCache::Version::Foreign)
return true;

std::vector<string> const archs = APT::Configuration::getArchitectures();
if (archs.size() <= 1)
if (MultiArchEnabled == false)
return true;

string const Package = Ver.ParentPkg().Name();
string const Version = Ver.VerStr();
for (std::vector<string>::const_iterator a = archs.begin();
a != archs.end(); ++a)
for (std::vector<string>::const_iterator a = Architectures.begin();
a != Architectures.end(); ++a)
{
if (NewProvides(Ver, Package, *a, Version) == false)
return false;
@@ -760,7 +757,7 @@ bool debListParser::Step()
if (Architecture.empty() == true)
return true;

if (Arch.empty() == true)
if (Arch.empty() == true || MultiArchEnabled == false)
{
if (APT::Configuration::checkArchitecture(Architecture) == true)
return true;
@@ -782,7 +779,7 @@ bool debListParser::Step()
// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
// ---------------------------------------------------------------------
/* */
bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI,
bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
FileFd &File, string component)
{
pkgTagFile Tags(&File, File.Size() + 256); // XXX


+ 10
- 8
apt-pkg/deb/deblistparser.h View File

@@ -32,12 +32,14 @@ class debListParser : public pkgCacheGenerator::ListParser
pkgTagSection Section;
unsigned long iOffset;
string Arch;
std::vector<std::string> Architectures;
bool MultiArchEnabled;

unsigned long UniqFindTagWrite(const char *Tag);
bool ParseStatus(pkgCache::PkgIterator Pkg,pkgCache::VerIterator Ver);
bool ParseDepends(pkgCache::VerIterator Ver,const char *Tag,
bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
unsigned int Type);
bool ParseProvides(pkgCache::VerIterator Ver);
bool ParseProvides(pkgCache::VerIterator &Ver);
static bool GrabWord(string Word,WordList *List,unsigned char &Out);
public:
@@ -49,19 +51,19 @@ class debListParser : public pkgCacheGenerator::ListParser
virtual string Architecture();
virtual bool ArchitectureAll();
virtual string Version();
virtual bool NewVersion(pkgCache::VerIterator Ver);
virtual bool NewVersion(pkgCache::VerIterator &Ver);
virtual string Description();
virtual string DescriptionLanguage();
virtual MD5SumValue Description_md5();
virtual unsigned short VersionHash();
virtual bool UsePackage(pkgCache::PkgIterator Pkg,
pkgCache::VerIterator Ver);
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver);
virtual unsigned long Offset() {return iOffset;};
virtual unsigned long Size() {return Section.size();};

virtual bool Step();
bool LoadReleaseInfo(pkgCache::PkgFileIterator FileI,FileFd &File,
bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
string section);
static const char *ParseDepends(const char *Start,const char *Stop,


+ 37
- 51
apt-pkg/depcache.cc View File

@@ -1255,6 +1255,10 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
Update(Pkg);
AddSizes(Pkg);

// always trigger the install of the all package for a pseudo package
if (P.CandidateVerIter(*Cache).Pseudo() == true)
MarkInstall(Pkg.Group().FindPkg("all"), AutoInst, Depth, FromUser, ForceImportantDeps);

if (AutoInst == false)
return;

@@ -1453,6 +1457,9 @@ bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst,
/* */
void pkgDepCache::SetReInstall(PkgIterator const &Pkg,bool To)
{
if (unlikely(Pkg.end() == true))
return;

ActionGroup group(*this);

RemoveSizes(Pkg);
@@ -1466,12 +1473,17 @@ void pkgDepCache::SetReInstall(PkgIterator const &Pkg,bool To)
AddStates(Pkg);
AddSizes(Pkg);

if (unlikely(Pkg.CurrentVer().end() == true) || Pkg.CurrentVer().Pseudo() == false)
return;

SetReInstall(Pkg.Group().FindPkg("all"), To);
}
/*}}}*/
// DepCache::SetCandidateVersion - Change the candidate version /*{{{*/
// ---------------------------------------------------------------------
/* */
void pkgDepCache::SetCandidateVersion(VerIterator TargetVer)
void pkgDepCache::SetCandidateVersion(VerIterator TargetVer, bool const &Pseudo)
{
ActionGroup group(*this);

@@ -1489,6 +1501,28 @@ void pkgDepCache::SetCandidateVersion(VerIterator TargetVer)
AddStates(Pkg);
Update(Pkg);
AddSizes(Pkg);

if (TargetVer.Pseudo() == false || Pseudo == false)
return;

// the version was pseudo: set all other pseudos also
pkgCache::GrpIterator Grp = Pkg.Group();
for (Pkg = Grp.FindPkg("any"); Pkg.end() == false; ++Pkg)
{
StateCache &P = PkgState[Pkg->ID];
if (TargetVer.SimilarVer(P.CandidateVerIter(*this)) == true ||
(P.CandidateVerIter(*this).Pseudo() == false &&
strcmp(Pkg.Arch(), "all") != 0))
continue;

for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
if (TargetVer.SimilarVer(Ver) == false)
continue;
SetCandidateVersion(Ver, false);
break;
}
}
}

void pkgDepCache::MarkAuto(const PkgIterator &Pkg, bool Auto)
@@ -1551,7 +1585,7 @@ const char *pkgDepCache::StateCache::StripEpoch(const char *Ver)
// ---------------------------------------------------------------------
/* The default just returns the highest available version that is not
a source and automatic. */
pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator Pkg)
pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pkg)
{
/* Not source/not automatic versions cannot be a candidate version
unless they are already installed */
@@ -1586,7 +1620,7 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator Pkg)
// Policy::IsImportantDep - True if the dependency is important /*{{{*/
// ---------------------------------------------------------------------
/* */
bool pkgDepCache::Policy::IsImportantDep(DepIterator Dep)
bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep)
{
if(Dep.IsCritical())
return true;
@@ -1605,54 +1639,6 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator Dep)
else if(Dep->Type == pkgCache::Dep::Suggests)
return _config->FindB("APT::Install-Suggests", false);

return false;
}
/*}}}*/
pkgDepCache::DefaultRootSetFunc::DefaultRootSetFunc() /*{{{*/
: constructedSuccessfully(false)
{
Configuration::Item const *Opts;
Opts = _config->Tree("APT::NeverAutoRemove");
if (Opts != 0 && Opts->Child != 0)
{
Opts = Opts->Child;
for (; Opts != 0; Opts = Opts->Next)
{
if (Opts->Value.empty() == true)
continue;

regex_t *p = new regex_t;
if(regcomp(p,Opts->Value.c_str(),
REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
{
regfree(p);
delete p;
_error->Error("Regex compilation error for APT::NeverAutoRemove");
return;
}

rootSetRegexp.push_back(p);
}
}

constructedSuccessfully = true;
}
/*}}}*/
pkgDepCache::DefaultRootSetFunc::~DefaultRootSetFunc() /*{{{*/
{
for(unsigned int i = 0; i < rootSetRegexp.size(); i++)
{
regfree(rootSetRegexp[i]);
delete rootSetRegexp[i];
}
}
/*}}}*/
bool pkgDepCache::DefaultRootSetFunc::InRootSet(const pkgCache::PkgIterator &pkg) /*{{{*/
{
for(unsigned int i = 0; i < rootSetRegexp.size(); i++)
if (regexec(rootSetRegexp[i], pkg.Name(), 0, 0, 0) == 0)
return true;

return false;
}
/*}}}*/


+ 10
- 20
apt-pkg/depcache.h View File

@@ -38,11 +38,10 @@
#ifndef PKGLIB_DEPCACHE_H
#define PKGLIB_DEPCACHE_H

#include <apt-pkg/configuration.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/progress.h>

#include <regex.h>
#include <apt-pkg/error.h>

#include <vector>
#include <memory>
@@ -184,22 +183,13 @@ class pkgDepCache : protected pkgCache::Namespace
/** \brief Returns \b true for packages matching a regular
* expression in APT::NeverAutoRemove.
*/
class DefaultRootSetFunc : public InRootSetFunc
class DefaultRootSetFunc : public InRootSetFunc, public Configuration::MatchAgainstConfig
{
std::vector<regex_t *> rootSetRegexp;
bool constructedSuccessfully;

public:
DefaultRootSetFunc();
~DefaultRootSetFunc();

/** \return \b true if the class initialized successfully, \b
* false otherwise. Used to avoid throwing an exception, since
* APT classes generally don't.
*/
bool wasConstructedSuccessfully() const { return constructedSuccessfully; }
DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverRemove") {};
virtual ~DefaultRootSetFunc() {};

bool InRootSet(const pkgCache::PkgIterator &pkg);
bool InRootSet(const pkgCache::PkgIterator &pkg) { return pkg.end() == true && Match(pkg.Name()); };
};

struct StateCache
@@ -266,8 +256,8 @@ class pkgDepCache : protected pkgCache::Namespace
{
public:
virtual VerIterator GetCandidateVer(PkgIterator Pkg);
virtual bool IsImportantDep(DepIterator Dep);
virtual VerIterator GetCandidateVer(PkgIterator const &Pkg);
virtual bool IsImportantDep(DepIterator const &Dep);
virtual ~Policy() {};
};
@@ -344,7 +334,7 @@ class pkgDepCache : protected pkgCache::Namespace
inline pkgVersioningSystem &VS() {return *Cache->VS;};
// Policy implementation
inline VerIterator GetCandidateVer(PkgIterator Pkg) {return LocalPolicy->GetCandidateVer(Pkg);};
inline VerIterator GetCandidateVer(PkgIterator const &Pkg) {return LocalPolicy->GetCandidateVer(Pkg);};
inline bool IsImportantDep(DepIterator Dep) {return LocalPolicy->IsImportantDep(Dep);};
inline Policy &GetPolicy() {return *LocalPolicy;};
@@ -405,7 +395,7 @@ class pkgDepCache : protected pkgCache::Namespace
bool ForceImportantDeps = false);

void SetReInstall(PkgIterator const &Pkg,bool To);
void SetCandidateVersion(VerIterator TargetVer);
void SetCandidateVersion(VerIterator TargetVer, bool const &Pseudo = true);

/** Set the "is automatically installed" flag of Pkg. */
void MarkAuto(const PkgIterator &Pkg, bool Auto);


+ 5
- 0
apt-pkg/init.cc View File

@@ -78,6 +78,11 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.Set("Dir::Log::Terminal","term.log");
Cnf.Set("Dir::Log::History","history.log");

Cnf.Set("Dir::Ignore-Files-Silently::", "~$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.disabled$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.bak$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$");

// Translation
Cnf.Set("APT::Acquire::Translation", "environment");



+ 2
- 3
apt-pkg/makefile View File

@@ -35,15 +35,14 @@ SOURCE+= pkgcache.cc version.cc depcache.cc \
srcrecords.cc cachefile.cc versionmatch.cc policy.cc \
pkgsystem.cc indexfile.cc pkgcachegen.cc acquire-item.cc \
indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \
aptconfiguration.cc cacheset.cc
aptconfiguration.cc
HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \
orderlist.h sourcelist.h packagemanager.h tagfile.h \
init.h pkgcache.h version.h progress.h pkgrecords.h \
acquire.h acquire-worker.h acquire-item.h acquire-method.h \
clean.h srcrecords.h cachefile.h versionmatch.h policy.h \
pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \
vendorlist.h cdrom.h indexcopy.h aptconfiguration.h \
cacheset.h
vendorlist.h cdrom.h indexcopy.h aptconfiguration.h

# Source code for the debian specific components
# In theory the deb headers do not need to be exported..


+ 2
- 1
apt-pkg/orderlist.cc View File

@@ -117,7 +117,8 @@ bool pkgOrderList::IsMissing(PkgIterator Pkg)
return false;

// Skip Packages that need configure only.
if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
if ((Pkg.State() == pkgCache::PkgIterator::NeedsConfigure ||
Pkg.State() == pkgCache::PkgIterator::NeedsNothing) &&
Cache[Pkg].Keep() == true)
return false;



+ 2
- 1
apt-pkg/packagemanager.cc View File

@@ -602,7 +602,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg)
// configured we don't need to unpack it again…
PkgIterator const P = Pkg.Group().FindPkg("all");
if (List->IsFlag(P,pkgOrderList::UnPacked) != true &&
List->IsFlag(P,pkgOrderList::Configured) != true) {
List->IsFlag(P,pkgOrderList::Configured) != true &&
P.State() != pkgCache::PkgIterator::NeedsNothing) {
if (SmartUnPack(P) == false)
return false;
}


+ 10
- 7
apt-pkg/pkgcache.cc View File

@@ -119,7 +119,7 @@ pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map)
// Cache::ReMap - Reopen the cache file /*{{{*/
// ---------------------------------------------------------------------
/* If the file is already closed then this will open it open it. */
bool pkgCache::ReMap()
bool pkgCache::ReMap(bool const &Errorchecks)
{
// Apply the typecasts.
HeaderP = (Header *)Map.Data();
@@ -135,6 +135,9 @@ bool pkgCache::ReMap()
StringItemP = (StringItem *)Map.Data();
StrP = (char *)Map.Data();

if (Errorchecks == false)
return true;

if (Map.Size() == 0 || HeaderP == 0)
return _error->Error(_("Empty package cache"));
@@ -307,7 +310,7 @@ const char *pkgCache::Priority(unsigned char Prio)
// GrpIterator::FindPkg - Locate a package by arch /*{{{*/
// ---------------------------------------------------------------------
/* Returns an End-Pointer on error, pointer to the package otherwise */
pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) {
pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
if (unlikely(IsGood() == false || S->FirstPackage == 0))
return PkgIterator(*Owner, 0);

@@ -346,7 +349,7 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) {
// GrpIterator::FindPreferredPkg - Locate the "best" package /*{{{*/
// ---------------------------------------------------------------------
/* Returns an End-Pointer on error, pointer to the package otherwise */
pkgCache::PkgIterator pkgCache::GrpIterator::FindPreferredPkg() {
pkgCache::PkgIterator pkgCache::GrpIterator::FindPreferredPkg() const {
pkgCache::PkgIterator Pkg = FindPkg("native");
if (Pkg.end() == false)
return Pkg;
@@ -367,7 +370,7 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPreferredPkg() {
/* Returns an End-Pointer on error, pointer to the package otherwise.
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) {
pkgCache::PkgIterator pkgCache::GrpIterator::NextPkg(pkgCache::PkgIterator const &LastPkg) const {
if (unlikely(IsGood() == false || S->FirstPackage == 0 ||
LastPkg.end() == true))
return PkgIterator(*Owner, 0);
@@ -504,7 +507,7 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
// ---------------------------------------------------------------------
/* Currently critical deps are defined as depends, predepends and
conflicts (including dpkg's Breaks fields). */
bool pkgCache::DepIterator::IsCritical()
bool pkgCache::DepIterator::IsCritical() const
{
if (S->Type == pkgCache::Dep::Conflicts ||
S->Type == pkgCache::Dep::DpkgBreaks ||
@@ -528,7 +531,7 @@ bool pkgCache::DepIterator::IsCritical()
In Conjunction with the DepCache the value of Result may not be
super-good since the policy may have made it uninstallable. Using
AllTargets is better in this case. */
bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result)
bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result) const
{
Result = TargetPkg();
@@ -577,7 +580,7 @@ bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result)
provides. It includes every possible package-version that could satisfy
the dependency. The last item in the list has a 0. The resulting pointer
must be delete [] 'd */
pkgCache::Version **pkgCache::DepIterator::AllTargets()
pkgCache::Version **pkgCache::DepIterator::AllTargets() const
{
Version **Res = 0;
unsigned long Size =0;


+ 1
- 1
apt-pkg/pkgcache.h View File

@@ -174,7 +174,7 @@ class pkgCache /*{{{*/
StringItem *StringItemP;
char *StrP;

virtual bool ReMap();
virtual bool ReMap(bool const &Errorchecks = true);
inline bool Sync() {return Map.Sync();};
inline MMap &GetMap() {return Map;};
inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();};


+ 184
- 62
apt-pkg/pkgcachegen.cc View File

@@ -36,6 +36,7 @@
#include <stdio.h>
/*}}}*/
typedef vector<pkgIndexFile *>::iterator FileIterator;
template <typename Iter> std::set<Iter*> pkgCacheGenerator::Dynamic<Iter>::toReMap;

// CacheGenerator::pkgCacheGenerator - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -61,8 +62,12 @@ pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) :

// Starting header
*Cache.HeaderP = pkgCache::Header();
Cache.HeaderP->VerSysName = Map.WriteString(_system->VS->Label);
Cache.HeaderP->Architecture = Map.WriteString(_config->Find("APT::Architecture"));
map_ptrloc const idxVerSysName = WriteStringInMap(_system->VS->Label);
Cache.HeaderP->VerSysName = idxVerSysName;
map_ptrloc const idxArchitecture = WriteStringInMap(_config->Find("APT::Architecture"));
Cache.HeaderP->Architecture = idxArchitecture;
if (unlikely(idxVerSysName == 0 || idxArchitecture == 0))
return;
Cache.ReMap();
}
else
@@ -96,6 +101,67 @@ pkgCacheGenerator::~pkgCacheGenerator()
Map.Sync(0,sizeof(pkgCache::Header));
}
/*}}}*/
void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newMap) {/*{{{*/
if (oldMap == newMap)
return;

Cache.ReMap(false);

CurrentFile += (pkgCache::PackageFile*) newMap - (pkgCache::PackageFile*) oldMap;

for (size_t i = 0; i < _count(UniqHash); ++i)
if (UniqHash[i] != 0)
UniqHash[i] += (pkgCache::StringItem*) newMap - (pkgCache::StringItem*) oldMap;

for (std::set<pkgCache::GrpIterator*>::const_iterator i = Dynamic<pkgCache::GrpIterator>::toReMap.begin();
i != Dynamic<pkgCache::GrpIterator>::toReMap.end(); ++i)
(*i)->ReOwn(Cache, oldMap, newMap);
for (std::set<pkgCache::PkgIterator*>::const_iterator i = Dynamic<pkgCache::PkgIterator>::toReMap.begin();
i != Dynamic<pkgCache::PkgIterator>::toReMap.end(); ++i)
(*i)->ReOwn(Cache, oldMap, newMap);
for (std::set<pkgCache::VerIterator*>::const_iterator i = Dynamic<pkgCache::VerIterator>::toReMap.begin();
i != Dynamic<pkgCache::VerIterator>::toReMap.end(); ++i)
(*i)->ReOwn(Cache, oldMap, newMap);
for (std::set<pkgCache::DepIterator*>::const_iterator i = Dynamic<pkgCache::DepIterator>::toReMap.begin();
i != Dynamic<pkgCache::DepIterator>::toReMap.end(); ++i)
(*i)->ReOwn(Cache, oldMap, newMap);
for (std::set<pkgCache::DescIterator*>::const_iterator i = Dynamic<pkgCache::DescIterator>::toReMap.begin();
i != Dynamic<pkgCache::DescIterator>::toReMap.end(); ++i)
(*i)->ReOwn(Cache, oldMap, newMap);
for (std::set<pkgCache::PrvIterator*>::const_iterator i = Dynamic<pkgCache::PrvIterator>::toReMap.begin();
i != Dynamic<pkgCache::PrvIterator>::toReMap.end(); ++i)