]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
prefer native arch over higher priority for providers
[apt.git] / apt-pkg / deb / deblistparser.cc
index efb76ef54795ae0833676b43a733cc13ad869307..28857176b12818df2771d539fd3c9fc83f10e3d1 100644 (file)
 
 using std::string;
 
-static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important},
-                       {"required",pkgCache::State::Required},
-                       {"standard",pkgCache::State::Standard},
-                       {"optional",pkgCache::State::Optional},
-                      {"extra",pkgCache::State::Extra},
-                       {}};
+static debListParser::WordList PrioList[] = {
+   {"required",pkgCache::State::Required},
+   {"important",pkgCache::State::Important},
+   {"standard",pkgCache::State::Standard},
+   {"optional",pkgCache::State::Optional},
+   {"extra",pkgCache::State::Extra},
+   {}};
 
 // ListParser::debListParser - Constructor                             /*{{{*/
 // ---------------------------------------------------------------------
@@ -218,8 +219,12 @@ MD5SumValue debListParser::Description_md5()
    string const value = Section.FindS("Description-md5");
    if (value.empty() == true)
    {
+      std::string const desc = Description() + "\n";
+      if (desc == "\n")
+        return MD5SumValue();
+
       MD5Summation md5;
-      md5.Add((Description() + "\n").c_str());
+      md5.Add(desc.c_str());
       return md5.Result();
    }
    else if (likely(value.size() == 32))
@@ -283,7 +288,7 @@ unsigned short debListParser::VersionHash()
                             "Replaces",0};
    unsigned long Result = INIT_FCS;
    char S[1024];
-   for (const char **I = Sections; *I != 0; I++)
+   for (const char * const *I = Sections; *I != 0; ++I)
    {
       const char *Start;
       const char *End;
@@ -294,13 +299,13 @@ unsigned short debListParser::VersionHash()
          of certain fields. dpkg also has the rather interesting notion of
          reformatting depends operators < -> <= */
       char *J = S;
-      for (; Start != End; Start++)
+      for (; Start != End; ++Start)
       {
-        if (isspace(*Start) == 0)
-           *J++ = tolower_ascii(*Start);
-        if (*Start == '<' && Start[1] != '<' && Start[1] != '=')
-           *J++ = '=';
-        if (*Start == '>' && Start[1] != '>' && Start[1] != '=')
+        if (isspace(*Start) != 0)
+           continue;
+        *J++ = tolower_ascii(*Start);
+
+        if ((*Start == '<' || *Start == '>') && Start[1] != *Start && Start[1] != '=')
            *J++ = '=';
       }
 
@@ -635,7 +640,8 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
         return _error->Error("Problem parsing dependency %s",Tag);
       size_t const found = Package.rfind(':');
 
-      if (MultiArchEnabled == true &&
+      // If negative is unspecific it needs to apply on all architectures
+      if (MultiArchEnabled == true && found == string::npos &&
          (Type == pkgCache::Dep::Conflicts ||
           Type == pkgCache::Dep::DpkgBreaks ||
           Type == pkgCache::Dep::Replaces))
@@ -644,6 +650,8 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
              a != Architectures.end(); ++a)
            if (NewDepends(Ver,Package,*a,Version,Op,Type) == false)
               return false;
+        if (NewDepends(Ver,Package,"none",Version,Op,Type) == false)
+           return false;
       }
       else if (MultiArchEnabled == true && found != string::npos &&
               strcmp(Package.c_str() + found, ":any") != 0)
@@ -657,8 +665,18 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
         if (NewDepends(Ver,Package,Arch,Version,Op,Type) == false)
            return false;
       }
-      else if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false)
-        return false;
+      else
+      {
+        if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false)
+           return false;
+        if ((Type == pkgCache::Dep::Conflicts ||
+             Type == pkgCache::Dep::DpkgBreaks ||
+             Type == pkgCache::Dep::Replaces) &&
+            NewDepends(Ver, Package,
+                       (pkgArch != "none") ? "none" : _config->Find("APT::Architecture"),
+                       Version,Op,Type) == false)
+           return false;
+      }
       if (Start == Stop)
         break;
    }
@@ -752,13 +770,15 @@ bool debListParser::Step()
          drop the whole section. A missing arch tag only happens (in theory)
          inside the Status file, so that is a positive return */
       string const Architecture = Section.FindS("Architecture");
-      if (Architecture.empty() == true)
-        return true;
 
       if (Arch.empty() == true || Arch == "any" || MultiArchEnabled == false)
       {
         if (APT::Configuration::checkArchitecture(Architecture) == true)
            return true;
+        /* parse version stanzas without an architecture only in the status file
+           (and as misfortune bycatch flat-archives) */
+        if ((Arch.empty() == true || Arch == "any") && Architecture.empty() == true)
+           return true;
       }
       else
       {
@@ -782,15 +802,15 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
 {
    // apt-secure does no longer download individual (per-section) Release
    // file. to provide Component pinning we use the section name now
-   FileI->Component = WriteUniqString(component);
+   map_ptrloc const storage = WriteUniqString(component);
+   FileI->Component = storage;
 
-   // FIXME: Code depends on the fact that Release files aren't compressed
+   // FIXME: should use FileFd and TagSection
    FILE* release = fdopen(dup(File.Fd()), "r");
    if (release == NULL)
       return false;
 
    char buffer[101];
-   bool gpgClose = false;
    while (fgets(buffer, sizeof(buffer), release) != NULL)
    {
       size_t len = 0;
@@ -802,15 +822,6 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
       if (buffer[len] == '\0')
         continue;
 
-      // only evalute the first GPG section
-      if (strncmp("-----", buffer, 5) == 0)
-      {
-        if (gpgClose == true)
-           break;
-        gpgClose = true;
-        continue;
-      }
-
       // seperate the tag from the data
       const char* dataStart = strchr(buffer + len, ':');
       if (dataStart == NULL)
@@ -869,13 +880,14 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
               break;
            *s = '\0';
         }
+        map_ptrloc const storage = WriteUniqString(data);
         switch (writeTo) {
-        case Suite: FileI->Archive = WriteUniqString(data); break;
-        case Component: FileI->Component = WriteUniqString(data); break;
-        case Version: FileI->Version = WriteUniqString(data); break;
-        case Origin: FileI->Origin = WriteUniqString(data); break;
-        case Codename: FileI->Codename = WriteUniqString(data); break;
-        case Label: FileI->Label = WriteUniqString(data); break;
+        case Suite: FileI->Archive = storage; break;
+        case Component: FileI->Component = storage; break;
+        case Version: FileI->Version = storage; break;
+        case Origin: FileI->Origin = storage; break;
+        case Codename: FileI->Codename = storage; break;
+        case Label: FileI->Label = storage; break;
         case None: break;
         }
       }