]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cacheset.cc
eipp: output at most two versions per package
[apt.git] / apt-pkg / cacheset.cc
index 3c38895e972a67338bf2588f9094d9f4d602d4a3..816925c4dbc00bbbbe5b13d21fa6b969919cba00 100644 (file)
 #include <apti18n.h>
                                                                        /*}}}*/
 namespace APT {
-// FromTask - Return all packages in the cache from a specific task    /*{{{*/
-bool PackageContainerInterface::FromTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
+// PackageFrom - selecting the appropriate method for package selection        /*{{{*/
+bool CacheSetHelper::PackageFrom(enum PkgSelector const select, PackageContainerInterface * const pci,
+      pkgCacheFile &Cache, std::string const &pattern) {
+       switch (select) {
+       case UNKNOWN: return false;
+       case REGEX: return PackageFromRegEx(pci, Cache, pattern);
+       case TASK: return PackageFromTask(pci, Cache, pattern);
+       case FNMATCH: return PackageFromFnmatch(pci, Cache, pattern);
+       case PACKAGENAME: return PackageFromPackageName(pci, Cache, pattern);
+       case STRING: return PackageFromString(pci, Cache, pattern);
+       }
+       return false;
+}
+                                                                       /*}}}*/
+// PackageFromTask - Return all packages in the cache from a specific task /*{{{*/
+bool CacheSetHelper::PackageFromTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
        size_t const archfound = pattern.find_last_of(':');
        std::string arch = "native";
        if (archfound != std::string::npos) {
@@ -91,13 +105,13 @@ bool PackageContainerInterface::FromTask(PackageContainerInterface * const pci,
                        continue;
 
                pci->insert(Pkg);
-               helper.showPackageSelection(Pkg, CacheSetHelper::TASK, pattern);
+               showPackageSelection(Pkg, CacheSetHelper::TASK, pattern);
                found = true;
        }
        regfree(&Pattern);
 
        if (found == false) {
-               helper.canNotFindPackage(CacheSetHelper::TASK, pci, Cache, pattern);
+               canNotFindPackage(CacheSetHelper::TASK, pci, Cache, pattern);
                pci->setConstructor(CacheSetHelper::UNKNOWN);
                return false;
        }
@@ -108,8 +122,8 @@ bool PackageContainerInterface::FromTask(PackageContainerInterface * const pci,
        return true;
 }
                                                                        /*}}}*/
-// FromRegEx - Return all packages in the cache matching a pattern     /*{{{*/
-bool PackageContainerInterface::FromRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
+// PackageFromRegEx - Return all packages in the cache matching a pattern /*{{{*/
+bool CacheSetHelper::PackageFromRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
        static const char * const isregex = ".?+*|[^$";
        if (pattern.find_first_of(isregex) == std::string::npos)
                return false;
@@ -139,23 +153,19 @@ bool PackageContainerInterface::FromRegEx(PackageContainerInterface * const pci,
                        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 (archfound == std::string::npos)
+                               Pkg = Grp.FindPreferredPkg(true);
                        if (Pkg.end() == true)
                                continue;
                }
 
                pci->insert(Pkg);
-               helper.showPackageSelection(Pkg, CacheSetHelper::REGEX, pattern);
+               showPackageSelection(Pkg, CacheSetHelper::REGEX, pattern);
                found = true;
        }
 
        if (found == false) {
-               helper.canNotFindPackage(CacheSetHelper::REGEX, pci, Cache, pattern);
+               canNotFindPackage(CacheSetHelper::REGEX, pci, Cache, pattern);
                pci->setConstructor(CacheSetHelper::UNKNOWN);
                return false;
        }
@@ -166,12 +176,9 @@ bool PackageContainerInterface::FromRegEx(PackageContainerInterface * const pci,
        return true;
 }
                                                                        /*}}}*/
-// FromFnmatch - Returns the package defined  by this fnmatch          /*{{{*/
-bool 
-PackageContainerInterface::FromFnmatch(PackageContainerInterface * const pci, 
-                                       pkgCacheFile &Cache,
-                                       std::string pattern,
-                                       CacheSetHelper &helper)
+// PackageFromFnmatch - Returns the package defined  by this fnmatch   /*{{{*/
+bool CacheSetHelper::PackageFromFnmatch(PackageContainerInterface * const pci,
+                                       pkgCacheFile &Cache, std::string pattern)
 {
        static const char * const isfnmatch = ".?*[]!";
        if (pattern.find_first_of(isfnmatch) == std::string::npos)
@@ -202,23 +209,19 @@ PackageContainerInterface::FromFnmatch(PackageContainerInterface * const pci,
                        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 (archfound == std::string::npos)
+                               Pkg = Grp.FindPreferredPkg(true);
                        if (Pkg.end() == true)
                                continue;
                }
 
                pci->insert(Pkg);
-               helper.showPackageSelection(Pkg, CacheSetHelper::FNMATCH, pattern);
+               showPackageSelection(Pkg, CacheSetHelper::FNMATCH, pattern);
                found = true;
        }
 
        if (found == false) {
-               helper.canNotFindPackage(CacheSetHelper::FNMATCH, pci, Cache, pattern);
+               canNotFindPackage(CacheSetHelper::FNMATCH, pci, Cache, pattern);
                pci->setConstructor(CacheSetHelper::UNKNOWN);
                return false;
        }
@@ -229,9 +232,9 @@ PackageContainerInterface::FromFnmatch(PackageContainerInterface * const pci,
        return true;
 }
                                                                        /*}}}*/
-// FromName - Returns the package defined  by this string              /*{{{*/
-pkgCache::PkgIterator PackageContainerInterface::FromName(pkgCacheFile &Cache,
-                       std::string const &str, CacheSetHelper &helper) {
+// PackageFromName - Returns the package defined  by this string       /*{{{*/
+pkgCache::PkgIterator CacheSetHelper::PackageFromName(pkgCacheFile &Cache,
+                       std::string const &str) {
        std::string pkg = str;
        size_t archfound = pkg.find_last_of(':');
        std::string arch;
@@ -252,16 +255,17 @@ pkgCache::PkgIterator PackageContainerInterface::FromName(pkgCacheFile &Cache,
                Pkg = Cache.GetPkgCache()->FindPkg(pkg, arch);
 
        if (Pkg.end() == true)
-               return helper.canNotFindPkgName(Cache, str);
+               return canNotFindPkgName(Cache, str);
        return Pkg;
 }
                                                                        /*}}}*/
-// FromGroup - Returns the package defined  by this string             /*{{{*/
-bool PackageContainerInterface::FromGroup(PackageContainerInterface * const pci, pkgCacheFile &Cache,
-                       std::string pkg, CacheSetHelper &helper) {
+// PackageFromPackageName - Returns the package defined  by this string /*{{{*/
+bool CacheSetHelper::PackageFromPackageName(PackageContainerInterface * const pci, pkgCacheFile &Cache,
+                       std::string pkg) {
        if (unlikely(Cache.GetPkgCache() == 0))
                return false;
 
+       std::string const pkgstring = pkg;
        size_t const archfound = pkg.find_last_of(':');
        std::string arch;
        if (archfound != std::string::npos) {
@@ -298,7 +302,7 @@ bool PackageContainerInterface::FromGroup(PackageContainerInterface * const pci,
                }
        }
 
-       pkgCache::PkgIterator Pkg = helper.canNotFindPkgName(Cache, pkg);
+       pkgCache::PkgIterator Pkg = canNotFindPkgName(Cache, pkgstring);
        if (Pkg.end() == true)
           return false;
 
@@ -306,18 +310,18 @@ bool PackageContainerInterface::FromGroup(PackageContainerInterface * const pci,
        return true;
 }
                                                                        /*}}}*/
-// FromString - Return all packages matching a specific string         /*{{{*/
-bool PackageContainerInterface::FromString(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str, CacheSetHelper &helper) {
+// PackageFromString - Return all packages matching a specific string  /*{{{*/
+bool CacheSetHelper::PackageFromString(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str) {
        bool found = true;
        _error->PushToStack();
 
-       if (FromGroup(pci, Cache, str, helper) == false &&
-                FromTask(pci, Cache, str, helper) == false &&
+       if (PackageFrom(CacheSetHelper::PACKAGENAME, pci, Cache, str) == false &&
+                PackageFrom(CacheSetHelper::TASK, pci, Cache, str) == false &&
                 // FIXME: hm, hm, regexp/fnmatch incompatible?
-                FromFnmatch(pci, Cache, str, helper) == false &&
-                FromRegEx(pci, Cache, str, helper) == false)
+                PackageFrom(CacheSetHelper::FNMATCH, pci, Cache, str) == false &&
+                PackageFrom(CacheSetHelper::REGEX, pci, Cache, str) == false)
        {
-               helper.canNotFindPackage(CacheSetHelper::PACKAGENAME, pci, Cache, str);
+               canNotFindPackage(CacheSetHelper::PACKAGENAME, pci, Cache, str);
                found = false;
        }
 
@@ -328,51 +332,50 @@ bool PackageContainerInterface::FromString(PackageContainerInterface * const pci
        return found;
 }
                                                                        /*}}}*/
-// FromCommandLine - Return all packages specified on commandline      /*{{{*/
-bool PackageContainerInterface::FromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper) {
+// PackageFromCommandLine - Return all packages specified on commandline /*{{{*/
+bool CacheSetHelper::PackageFromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline) {
        bool found = false;
        for (const char **I = cmdline; *I != 0; ++I)
-               found |= PackageContainerInterface::FromString(pci, Cache, *I, helper);
+               found |= PackageFrom(CacheSetHelper::STRING, pci, Cache, *I);
        return found;
 }
                                                                        /*}}}*/
 // FromModifierCommandLine - helper doing the work for PKG:GroupedFromCommandLine      /*{{{*/
-bool PackageContainerInterface::FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
+bool CacheSetHelper::PackageFromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
                                                        pkgCacheFile &Cache, const char * cmdline,
-                                                       std::list<Modifier> const &mods, CacheSetHelper &helper) {
+                                                       std::list<PkgModifier> const &mods) {
        std::string str = cmdline;
        unsigned short fallback = modID;
        bool modifierPresent = false;
-       for (std::list<Modifier>::const_iterator mod = mods.begin();
+       for (std::list<PkgModifier>::const_iterator mod = mods.begin();
             mod != mods.end(); ++mod) {
                size_t const alength = strlen(mod->Alias);
                switch(mod->Pos) {
-               case Modifier::POSTFIX:
+               case PkgModifier::POSTFIX:
                        if (str.compare(str.length() - alength, alength,
                                        mod->Alias, 0, alength) != 0)
                                continue;
                        str.erase(str.length() - alength);
                        modID = mod->ID;
                        break;
-               case Modifier::PREFIX:
+               case PkgModifier::PREFIX:
                        continue;
-               case Modifier::NONE:
+               case PkgModifier::NONE:
                        continue;
                }
                modifierPresent = true;
                break;
        }
        if (modifierPresent == true) {
-               bool const errors = helper.showErrors(false);
-               pkgCache::PkgIterator Pkg = FromName(Cache, cmdline, helper);
-               helper.showErrors(errors);
-               if (Pkg.end() == false) {
-                       pci->insert(Pkg);
+               bool const errors = showErrors(false);
+               bool const found = PackageFrom(PACKAGENAME, pci, Cache, cmdline);
+               showErrors(errors);
+               if (found == true) {
                        modID = fallback;
                        return true;
                }
        }
-       return FromString(pci, Cache, str, helper);
+       return PackageFrom(CacheSetHelper::PACKAGENAME, pci, Cache, str);
 }
                                                                        /*}}}*/
 // FromModifierCommandLine - helper doing the work for VER:GroupedFromCommandLine      /*{{{*/
@@ -438,15 +441,6 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
                                           CacheSetHelper::VerSelector const fallback,
                                           CacheSetHelper &helper,
                                           bool const onlyFromName) {
-        PackageSet pkgset;
-        if(FileExists(pkg))
-        {
-                PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
-                if(pkgset.size() == 0)
-                   return false;
-                return VersionContainerInterface::FromPackage(vci, Cache, pkgset.begin(), fallback, helper);
-        }
-
        std::string ver;
        bool verIsRel = false;
        size_t const vertag = pkg.find_last_of("/=");
@@ -455,10 +449,12 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
                verIsRel = (pkg[vertag] == '/');
                pkg.erase(vertag);
        }
+
+       PackageSet pkgset;
        if (onlyFromName == false)
-               PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
+               helper.PackageFrom(CacheSetHelper::STRING, &pkgset, Cache, pkg);
        else {
-               pkgset.insert(PackageContainerInterface::FromName(Cache, pkg, helper));
+               helper.PackageFrom(CacheSetHelper::PACKAGENAME, &pkgset, Cache, pkg);
        }
 
        bool errors = true;
@@ -573,16 +569,126 @@ bool VersionContainerInterface::FromPackage(VersionContainerInterface * const vc
        return found;
 }
                                                                        /*}}}*/
+// FromDependency - versions satisfying a given dependency             /*{{{*/
+bool VersionContainerInterface::FromDependency(VersionContainerInterface * const vci,
+                                              pkgCacheFile &Cache,
+                                              pkgCache::DepIterator const &D,
+                                              CacheSetHelper::VerSelector const selector,
+                                              CacheSetHelper &helper)
+{
+       bool found = false;
+       switch(selector) {
+       case CacheSetHelper::ALL:
+       {
+               pkgCache::PkgIterator const T = D.TargetPkg();
+               for (pkgCache::VerIterator Ver = T.VersionList(); Ver.end() == false; ++Ver)
+               {
+                  if (D.IsSatisfied(Ver) == true)
+                  {
+                     vci->insert(Ver);
+                     found = true;
+                  }
+                  for (pkgCache::PrvIterator Prv = T.ProvidesList(); Prv.end() != true; ++Prv)
+                  {
+                     pkgCache::VerIterator const V = Prv.OwnerVer();
+                     if (unlikely(V.end() == true) || D.IsSatisfied(Prv) == false)
+                        continue;
+                     vci->insert(V);
+                     found = true;
+                  }
+               }
+               return found;
+       }
+       case CacheSetHelper::CANDANDINST:
+       {
+               found = FromDependency(vci, Cache, D, CacheSetHelper::CANDIDATE, helper);
+               found &= FromDependency(vci, Cache, D, CacheSetHelper::INSTALLED, helper);
+               return found;
+       }
+       case CacheSetHelper::CANDIDATE:
+       {
+               pkgCache::PkgIterator const T = D.TargetPkg();
+               pkgCache::VerIterator const Cand = Cache[T].CandidateVerIter(Cache);
+               if (Cand.end() == false && D.IsSatisfied(Cand) == true)
+               {
+                  vci->insert(Cand);
+                  found = true;
+               }
+               for (pkgCache::PrvIterator Prv = T.ProvidesList(); Prv.end() != true; ++Prv)
+               {
+                  pkgCache::VerIterator const V = Prv.OwnerVer();
+                  pkgCache::VerIterator const Cand = Cache[Prv.OwnerPkg()].CandidateVerIter(Cache);
+                  if (Cand.end() == true || V != Cand || D.IsSatisfied(Prv) == false)
+                     continue;
+                  vci->insert(Cand);
+                  found = true;
+               }
+               return found;
+       }
+       case CacheSetHelper::INSTALLED:
+       {
+               pkgCache::PkgIterator const T = D.TargetPkg();
+               pkgCache::VerIterator const Cand = T.CurrentVer();
+               if (Cand.end() == false && D.IsSatisfied(Cand) == true)
+               {
+                  vci->insert(Cand);
+                  found = true;
+               }
+               for (pkgCache::PrvIterator Prv = T.ProvidesList(); Prv.end() != true; ++Prv)
+               {
+                  pkgCache::VerIterator const V = Prv.OwnerVer();
+                  pkgCache::VerIterator const Cand = Prv.OwnerPkg().CurrentVer();
+                  if (Cand.end() == true || V != Cand || D.IsSatisfied(Prv) == false)
+                     continue;
+                  vci->insert(Cand);
+                  found = true;
+               }
+               return found;
+       }
+       case CacheSetHelper::CANDINST:
+               return FromDependency(vci, Cache, D, CacheSetHelper::CANDIDATE, helper) ||
+                  FromDependency(vci, Cache, D, CacheSetHelper::INSTALLED, helper);
+       case CacheSetHelper::INSTCAND:
+               return FromDependency(vci, Cache, D, CacheSetHelper::INSTALLED, helper) ||
+                  FromDependency(vci, Cache, D, CacheSetHelper::CANDIDATE, helper);
+       case CacheSetHelper::NEWEST:
+       {
+               pkgCache::PkgIterator const T = D.TargetPkg();
+               pkgCache::VerIterator const Cand = T.VersionList();
+               if (Cand.end() == false && D.IsSatisfied(Cand) == true)
+               {
+                  vci->insert(Cand);
+                  found = true;
+               }
+               for (pkgCache::PrvIterator Prv = T.ProvidesList(); Prv.end() != true; ++Prv)
+               {
+                  pkgCache::VerIterator const V = Prv.OwnerVer();
+                  pkgCache::VerIterator const Cand = Prv.OwnerPkg().VersionList();
+                  if (Cand.end() == true || V != Cand || D.IsSatisfied(Prv) == false)
+                     continue;
+                  vci->insert(Cand);
+                  found = true;
+               }
+               return found;
+       }
+       case CacheSetHelper::RELEASE:
+       case CacheSetHelper::VERSIONNUMBER:
+               // both make no sense here, so always false
+               return false;
+       }
+       return found;
+}
+                                                                       /*}}}*/
 // getCandidateVer - Returns the candidate version of the given package        /*{{{*/
 pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache,
                pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
        pkgCache::VerIterator Cand;
-       if (Cache.IsPolicyBuilt() == true || Cache.IsDepCacheBuilt() == false) {
-               if (unlikely(Cache.GetPolicy() == 0))
-                       return pkgCache::VerIterator(Cache);
-               Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
-       } else {
+       if (Cache.IsDepCacheBuilt() == true) {
                Cand = Cache[Pkg].CandidateVerIter(Cache);
+       } else if (unlikely(Cache.GetPolicy() == nullptr)) {
+               return pkgCache::VerIterator(Cache);
+       } else {
+               Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
        }
        if (Cand.end() == true)
                return helper.canNotGetVersion(CacheSetHelper::CANDIDATE, Cache, Pkg);
@@ -603,18 +709,14 @@ void CacheSetHelper::canNotFindPackage(enum PkgSelector const select,
       PackageContainerInterface * const pci, pkgCacheFile &Cache,
       std::string const &pattern) {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case REGEX: canNotFindRegEx(pci, Cache, pattern); break;
        case TASK: canNotFindTask(pci, Cache, pattern); break;
        case FNMATCH: canNotFindFnmatch(pci, Cache, pattern); break;
        case PACKAGENAME: canNotFindPackage(pci, Cache, pattern); break;
+       case STRING: canNotFindPackage(pci, Cache, pattern); break;
        case UNKNOWN: break;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+APT_IGNORE_DEPRECATED_POP
        }
 }
 // canNotFindTask - handle the case no package is found for a task     /*{{{*/
@@ -652,19 +754,14 @@ pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
 void CacheSetHelper::canNotFindVersion(enum VerSelector const select, VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg)
 {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case ALL: canNotFindAllVer(vci, Cache, Pkg); break;
        case INSTCAND: canNotFindInstCandVer(vci, Cache, Pkg); break;
        case CANDINST: canNotFindCandInstVer(vci, Cache, Pkg); break;
        case NEWEST: canNotFindNewestVer(Cache, Pkg); break;
        case CANDIDATE: canNotFindCandidateVer(Cache, Pkg); break;
        case INSTALLED: canNotFindInstalledVer(Cache, Pkg); break;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+APT_IGNORE_DEPRECATED_POP
        case CANDANDINST: canNotGetCandInstVer(Cache, Pkg); break;
        case RELEASE:
        case VERSIONNUMBER:
@@ -695,16 +792,11 @@ void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const /*v
 // canNotGetVersion - for package by selector                          /*{{{*/
 pkgCache::VerIterator CacheSetHelper::canNotGetVersion(enum VerSelector const select, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case NEWEST: return canNotFindNewestVer(Cache, Pkg);
        case CANDIDATE: return canNotFindCandidateVer(Cache, Pkg);
        case INSTALLED: return canNotFindInstalledVer(Cache, Pkg);
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+APT_IGNORE_DEPRECATED_POP
        case CANDINST: return canNotGetCandInstVer(Cache, Pkg);
        case INSTCAND: return canNotGetInstCandVer(Cache, Pkg);
        case ALL:
@@ -758,20 +850,16 @@ pkgCache::VerIterator CacheSetHelper::canNotGetCandInstVer(pkgCacheFile &Cache,
                                                                        /*}}}*/
                                                                        /*}}}*/
 // showPackageSelection - by selector and given pattern                        /*{{{*/
-APT_CONST void CacheSetHelper::showPackageSelection(pkgCache::PkgIterator const &pkg, enum PkgSelector const select,
+void CacheSetHelper::showPackageSelection(pkgCache::PkgIterator const &pkg, enum PkgSelector const select,
                                       std::string const &pattern) {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case REGEX: showRegExSelection(pkg, pattern); break;
        case TASK: showTaskSelection(pkg, pattern); break;
        case FNMATCH: showFnmatchSelection(pkg, pattern); break;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+APT_IGNORE_DEPRECATED_POP
        case PACKAGENAME: /* no suprises here */ break;
+       case STRING: /* handled by the special cases */ break;
        case UNKNOWN: break;
        }
 }
@@ -792,23 +880,17 @@ APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const
                                                                        /*}}}*/
                                                                        /*}}}*/
 // showVersionSelection                                                        /*{{{*/
-APT_CONST void CacheSetHelper::showVersionSelection(pkgCache::PkgIterator const &Pkg,
+void CacheSetHelper::showVersionSelection(pkgCache::PkgIterator const &Pkg,
       pkgCache::VerIterator const &Ver, enum VerSelector const select, std::string const &pattern) {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case RELEASE:
                showSelectedVersion(Pkg, Ver, pattern, true);
                break;
        case VERSIONNUMBER:
                showSelectedVersion(Pkg, Ver, pattern, false);
                break;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_POP
        case NEWEST:
        case CANDIDATE:
        case INSTALLED:
@@ -826,4 +908,28 @@ APT_CONST void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &
                                         bool const /*verIsRel*/) {
 }
                                                                        /*}}}*/
+
+CacheSetHelper::CacheSetHelper(bool const ShowError, GlobalError::MsgType ErrorType) :
+   ShowError(ShowError), ErrorType(ErrorType), d(NULL) {}
+CacheSetHelper::~CacheSetHelper() {}
+
+PackageContainerInterface::PackageContainerInterface() : ConstructedBy(CacheSetHelper::UNKNOWN), d(NULL) {}
+PackageContainerInterface::PackageContainerInterface(CacheSetHelper::PkgSelector const by) : ConstructedBy(by), d(NULL) {}
+PackageContainerInterface& PackageContainerInterface::operator=(PackageContainerInterface const &other) {
+   if (this != &other)
+      this->ConstructedBy = other.ConstructedBy;
+   return *this;
+}
+PackageContainerInterface::~PackageContainerInterface() {}
+
+PackageUniverse::PackageUniverse(pkgCache * const Owner) : _cont(Owner), d(NULL) {}
+PackageUniverse::PackageUniverse(pkgCacheFile * const Owner) : _cont(Owner->GetPkgCache()), d(NULL) {}
+PackageUniverse::~PackageUniverse() {}
+
+VersionContainerInterface::VersionContainerInterface() : d(NULL) {}
+VersionContainerInterface& VersionContainerInterface::operator=(VersionContainerInterface const &) {
+   return *this;
+}
+
+VersionContainerInterface::~VersionContainerInterface() {}
 }