]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
merge patch from Daniel Hartwig to Show a error message if {,dist-}upgrade is used...
[apt.git] / apt-pkg / deb / deblistparser.cc
index e93e51af30dbb5c6ba1b84f6a1887a880e85dd9c..db86bd698117ec9e6ea40850bf24501d9bd6cb79 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                             /*{{{*/
 // ---------------------------------------------------------------------
@@ -283,7 +284,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 +295,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 +636,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 +646,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 +661,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 +766,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
       {
@@ -785,13 +801,12 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
    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;
@@ -803,15 +818,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)