]> git.saurik.com Git - apt.git/commitdiff
clean deblistparser a bit by get the Architectures at one place
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 4 Jul 2010 15:04:07 +0000 (17:04 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 4 Jul 2010 15:04:07 +0000 (17:04 +0200)
instead of distributed in a few methods

apt-pkg/deb/deblistparser.cc
apt-pkg/deb/deblistparser.h

index 83c5b8d2eb64d1e159e769deabb166dffba4de66..d1931f90926b4e151308a12477978a19ff6d7da3 100644 (file)
@@ -38,6 +38,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  /*{{{*/
@@ -155,10 +157,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;
@@ -620,9 +621,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;
@@ -634,13 +632,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;
       }
@@ -692,14 +690,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;
@@ -739,7 +736,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;
index 8da051530fd06cf9b60e5a25e318a90ee733c64d..6c81d9fa0dfd55531353dc4430ddea58a4e44a3f 100644 (file)
@@ -32,7 +32,9 @@ 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,