]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cacheset.cc
close server if parsing of header field failed
[apt.git] / apt-pkg / cacheset.cc
index f5cf5215970f721182c28e62def1f7c2f5f4b947..816925c4dbc00bbbbe5b13d21fa6b969919cba00 100644 (file)
@@ -153,12 +153,8 @@ bool CacheSetHelper::PackageFromRegEx(PackageContainerInterface * const pci, pkg
                        continue;
                pkgCache::PkgIterator Pkg = Grp.FindPkg(arch);
                if (Pkg.end() == true) {
                        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;
                }
                        if (Pkg.end() == true)
                                continue;
                }
@@ -213,12 +209,8 @@ bool CacheSetHelper::PackageFromFnmatch(PackageContainerInterface * const pci,
                        continue;
                pkgCache::PkgIterator Pkg = Grp.FindPkg(arch);
                if (Pkg.end() == true) {
                        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;
                }
                        if (Pkg.end() == true)
                                continue;
                }
@@ -273,6 +265,7 @@ bool CacheSetHelper::PackageFromPackageName(PackageContainerInterface * const pc
        if (unlikely(Cache.GetPkgCache() == 0))
                return false;
 
        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) {
        size_t const archfound = pkg.find_last_of(':');
        std::string arch;
        if (archfound != std::string::npos) {
@@ -309,7 +302,7 @@ bool CacheSetHelper::PackageFromPackageName(PackageContainerInterface * const pc
                }
        }
 
                }
        }
 
-       pkgCache::PkgIterator Pkg = canNotFindPkgName(Cache, pkg);
+       pkgCache::PkgIterator Pkg = canNotFindPkgName(Cache, pkgstring);
        if (Pkg.end() == true)
           return false;
 
        if (Pkg.end() == true)
           return false;
 
@@ -343,7 +336,7 @@ bool CacheSetHelper::PackageFromString(PackageContainerInterface * const pci, pk
 bool CacheSetHelper::PackageFromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline) {
        bool found = false;
        for (const char **I = cmdline; *I != 0; ++I)
 bool CacheSetHelper::PackageFromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline) {
        bool found = false;
        for (const char **I = cmdline; *I != 0; ++I)
-               found |= PackageFrom(CacheSetHelper::PACKAGENAME, pci, Cache, *I);
+               found |= PackageFrom(CacheSetHelper::STRING, pci, Cache, *I);
        return found;
 }
                                                                        /*}}}*/
        return found;
 }
                                                                        /*}}}*/
@@ -448,14 +441,6 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
                                           CacheSetHelper::VerSelector const fallback,
                                           CacheSetHelper &helper,
                                           bool const onlyFromName) {
                                           CacheSetHelper::VerSelector const fallback,
                                           CacheSetHelper &helper,
                                           bool const onlyFromName) {
-       PackageSet pkgset;
-       if(FileExists(pkg)) {
-               helper.PackageFrom(CacheSetHelper::STRING, &pkgset, Cache, pkg);
-               if(pkgset.empty() == true)
-                       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("/=");
        std::string ver;
        bool verIsRel = false;
        size_t const vertag = pkg.find_last_of("/=");
@@ -464,6 +449,8 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
                verIsRel = (pkg[vertag] == '/');
                pkg.erase(vertag);
        }
                verIsRel = (pkg[vertag] == '/');
                pkg.erase(vertag);
        }
+
+       PackageSet pkgset;
        if (onlyFromName == false)
                helper.PackageFrom(CacheSetHelper::STRING, &pkgset, Cache, pkg);
        else {
        if (onlyFromName == false)
                helper.PackageFrom(CacheSetHelper::STRING, &pkgset, Cache, pkg);
        else {
@@ -696,12 +683,12 @@ bool VersionContainerInterface::FromDependency(VersionContainerInterface * const
 pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache,
                pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
        pkgCache::VerIterator Cand;
 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);
                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);
        }
        if (Cand.end() == true)
                return helper.canNotGetVersion(CacheSetHelper::CANDIDATE, Cache, Pkg);
@@ -935,7 +922,8 @@ PackageContainerInterface& PackageContainerInterface::operator=(PackageContainer
 }
 PackageContainerInterface::~PackageContainerInterface() {}
 
 }
 PackageContainerInterface::~PackageContainerInterface() {}
 
-PackageUniverse::PackageUniverse(pkgCache * const Owner) : _cont(Owner), d(NULL) { }
+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) {}
 PackageUniverse::~PackageUniverse() {}
 
 VersionContainerInterface::VersionContainerInterface() : d(NULL) {}