]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
Use --add-location=file for po/ and doc/po
[apt.git] / apt-pkg / deb / deblistparser.cc
index a908057d77cd0ad083fe182a6b5e381d21ce2184..b51ee815e363f11e7d79effd54f10f57da6b4d6c 100644 (file)
 #include <apt-pkg/cachefilter.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/md5.h>
-#include <apt-pkg/mmap.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/tagfile.h>
@@ -95,14 +93,14 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors)  /*{{{*/
    unsigned char MA;
    string const MultiArch = Section.FindS("Multi-Arch");
    if (MultiArch.empty() == true || MultiArch == "no")
-      MA = pkgCache::Version::None;
+      MA = pkgCache::Version::No;
    else if (MultiArch == "same") {
       if (ArchitectureAll() == true)
       {
         if (showErrors == true)
            _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
                  Section.FindS("Package").c_str());
-        MA = pkgCache::Version::None;
+        MA = pkgCache::Version::No;
       }
       else
         MA = pkgCache::Version::Same;
@@ -116,7 +114,7 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors)  /*{{{*/
       if (showErrors == true)
         _error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
               MultiArch.c_str(), Section.FindS("Package").c_str());
-      MA = pkgCache::Version::None;
+      MA = pkgCache::Version::No;
    }
 
    if (ArchitectureAll() == true)
@@ -364,7 +362,7 @@ unsigned short debListParser::VersionHash()
    return Result;
 }
                                                                        /*}}}*/
-// ListParser::ParseStatus - Parse the status field                    /*{{{*/
+// StatusListParser::ParseStatus - Parse the status field              /*{{{*/
 // ---------------------------------------------------------------------
 /* Status lines are of the form,
      Status: want flag status
@@ -373,7 +371,12 @@ unsigned short debListParser::VersionHash()
    status = not-installed, config-files, half-installed, unpacked,
             half-configured, triggers-awaited, triggers-pending, installed
  */
-bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
+bool debListParser::ParseStatus(pkgCache::PkgIterator &,
+                               pkgCache::VerIterator &)
+{
+   return true;
+}
+bool debStatusListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
                                pkgCache::VerIterator &Ver)
 {
    const char *Start;
@@ -788,20 +791,24 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
         return _error->Error("Problem parsing dependency %s",Tag);
       size_t const found = Package.rfind(':');
 
-      if (found == string::npos || strcmp(Package.c_str() + found, ":any") == 0)
+      if (found == string::npos)
       {
         if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false)
            return false;
       }
+      else if (strcmp(Package.c_str() + found, ":any") == 0)
+      {
+        if (NewDepends(Ver,Package,"any",Version,Op,Type) == false)
+           return false;
+      }
       else
       {
-        string Arch = Package.substr(found+1, string::npos);
-        Package = Package.substr(0, found);
         // Such dependencies are not supposed to be accepted …
         // … but this is probably the best thing to do anyway
-        if (Arch == "native")
-           Arch = _config->Find("APT::Architecture");
-        if (NewDepends(Ver,Package,Arch,Version,Op | pkgCache::Dep::ArchSpecific,Type) == false)
+        if (Package.substr(found + 1) == "native")
+           Package = Package.substr(0, found) + ':' + Ver.Cache()->NativeArch();
+
+        if (NewDepends(Ver, Package, "any", Version, Op | pkgCache::Dep::ArchSpecific, Type) == false)
            return false;
       }
 
@@ -816,49 +823,98 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
 /* */
 bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
 {
+   /* it is unlikely, but while parsing dependencies, we might have already
+      picked up multi-arch implicit provides which we do not want to duplicate here */
+   bool hasProvidesAlready = false;
+   std::string const spzName = Ver.ParentPkg().FullName(false);
+   {
+      for (pkgCache::PrvIterator Prv = Ver.ProvidesList(); Prv.end() == false; ++Prv)
+      {
+        if (Prv.IsMultiArchImplicit() == false || (Prv->Flags & pkgCache::Flag::ArchSpecific) == 0)
+           continue;
+        if (spzName != Prv.OwnerPkg().FullName(false))
+           continue;
+        hasProvidesAlready = true;
+        break;
+      }
+   }
+
+   string const Arch = Ver.Arch();
    const char *Start;
    const char *Stop;
    if (Section.Find("Provides",Start,Stop) == true)
    {
       string Package;
       string Version;
-      string const Arch = Ver.Arch();
       unsigned int Op;
 
-      while (1)
+      do
       {
-        Start = ParseDepends(Start,Stop,Package,Version,Op);
+        Start = ParseDepends(Start,Stop,Package,Version,Op, false, false, false);
         const size_t archfound = Package.rfind(':');
         if (Start == 0)
            return _error->Error("Problem parsing Provides line");
         if (Op != pkgCache::Dep::NoOp && Op != pkgCache::Dep::Equals) {
            _error->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package.c_str());
         } else if (archfound != string::npos) {
-           string OtherArch = Package.substr(archfound+1, string::npos);
-           Package = Package.substr(0, archfound);
-           if (NewProvides(Ver, Package, OtherArch, Version, pkgCache::Flag::ArchSpecific) == false)
+           std::string spzArch = Package.substr(archfound + 1);
+           if (spzArch != "any")
+           {
+              if (NewProvides(Ver, Package.substr(0, archfound), spzArch, Version, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false)
+                 return false;
+           }
+           if (NewProvides(Ver, Package, "any", Version, pkgCache::Flag::ArchSpecific) == false)
               return false;
         } else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) {
-           if (NewProvidesAllArch(Ver, Package, Version, 0) == false)
-              return false;
+           if (APT::Configuration::checkArchitecture(Arch))
+              if (NewProvidesAllArch(Ver, Package, Version, 0) == false)
+                 return false;
         } else {
+           if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
+           {
+              if (NewProvides(Ver, Package + ":any", "any", Version, pkgCache::Flag::MultiArchImplicit) == false)
+                 return false;
+           }
            if (NewProvides(Ver, Package, Arch, Version, 0) == false)
               return false;
         }
+        if (archfound == std::string::npos)
+        {
+           std::string const spzName = Package + ':' + Ver.ParentPkg().Arch();
+           pkgCache::PkgIterator const spzPkg = Ver.Cache()->FindPkg(spzName, "any");
+           if (spzPkg.end() == false)
+           {
+              if (NewProvides(Ver, spzName, "any", Version, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false)
+                 return false;
+           }
+        }
+      } while (Start != Stop);
+   }
 
-        if (Start == Stop)
-           break;
+   if (APT::Configuration::checkArchitecture(Arch))
+   {
+      if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
+      {
+        string const Package = string(Ver.ParentPkg().Name()).append(":").append("any");
+        if (NewProvides(Ver, Package, "any", Ver.VerStr(), pkgCache::Flag::MultiArchImplicit) == false)
+           return false;
+      }
+      else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
+      {
+        if (NewProvidesAllArch(Ver, Ver.ParentPkg().Name(), Ver.VerStr(), pkgCache::Flag::MultiArchImplicit) == false)
+           return false;
       }
    }
 
-   if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
+   if (hasProvidesAlready == false)
    {
-      string const Package = string(Ver.ParentPkg().Name()).append(":").append("any");
-      return NewProvidesAllArch(Ver, Package, Ver.VerStr(), pkgCache::Flag::MultiArchImplicit);
+      pkgCache::PkgIterator const spzPkg = Ver.Cache()->FindPkg(spzName, "any");
+      if (spzPkg.end() == false)
+      {
+        if (NewProvides(Ver, spzName, "any", Ver.VerStr(), pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false)
+           return false;
+      }
    }
-   else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
-      return NewProvidesAllArch(Ver, Ver.ParentPkg().Name(), Ver.VerStr(), pkgCache::Flag::MultiArchImplicit);
-
    return true;
 }
                                                                        /*}}}*/