]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
* apt-pkg/pkgcache.h:
[apt.git] / apt-pkg / deb / deblistparser.cc
index 5c9cf6d4bfe79c27ebd5c4061f3008360c4a453b..83c5b8d2eb64d1e159e769deabb166dffba4de66 100644 (file)
@@ -36,8 +36,8 @@ static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Impor
    we would accept in general with checkArchitecture() */
 debListParser::debListParser(FileFd *File, string const &Arch) : Tags(File),
                                Arch(Arch) {
-       if (Arch == "native")
-               this->Arch = _config->Find("APT::Architecture");
+   if (Arch == "native")
+      this->Arch = _config->Find("APT::Architecture");
 }
                                                                        /*}}}*/
 // ListParser::UniqFindTagWrite - Find the tag and write a unq string  /*{{{*/
@@ -56,10 +56,10 @@ unsigned long debListParser::UniqFindTagWrite(const char *Tag)
 // ---------------------------------------------------------------------
 /* This is to return the name of the package this section describes */
 string debListParser::Package() {
-       string const Result = Section.FindS("Package");
-       if(unlikely(Result.empty() == true))
-               _error->Error("Encountered a section with no Package: header");
-       return Result;
+   string const Result = Section.FindS("Package");
+   if(unlikely(Result.empty() == true))
+      _error->Error("Encountered a section with no Package: header");
+   return Result;
 }
                                                                        /*}}}*/
 // ListParser::Architecture - Return the package arch                  /*{{{*/
@@ -68,25 +68,26 @@ string debListParser::Package() {
    Note that architecture "all" packages will get the architecture of the
    Packages file parsed here. */
 string debListParser::Architecture() {
-       string const Result = Section.FindS("Architecture");
-       if (Result.empty() == true || Result == "all") {
-               if (Arch.empty() == true)
-                       /* FIXME: this is a problem for installed arch all
-                          packages as we don't know from which arch this
-                          package was installed - and therefore which
-                          dependency this package resolves. */
-                       return _config->Find("APT::Architecture");
-               else
-                       return Arch;
-       }
-       return Result;
+   string const Result = Section.FindS("Architecture");
+   if (Result.empty() == true || Result == "all")
+   {
+      if (Arch.empty() == true)
+        /* FIXME: this is a problem for installed arch all
+           packages as we don't know from which arch this
+           package was installed - and therefore which
+           dependency this package resolves. */
+        return _config->Find("APT::Architecture");
+      else
+        return Arch;
+   }
+   return Result;
 }
                                                                        /*}}}*/
 // ListParser::ArchitectureAll                                         /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 bool debListParser::ArchitectureAll() {
-       return Section.FindS("Architecture") == "all";
+   return Section.FindS("Architecture") == "all";
 }
                                                                        /*}}}*/
 // ListParser::Version - Return the version string                     /*{{{*/
@@ -132,10 +133,9 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
    }
 
    // Archive Size
-   Ver->Size = (unsigned)Section.FindI("Size");
-   
+   Ver->Size = Section.FindULL("Size");
    // Unpacked Size (in K)
-   Ver->InstalledSize = (unsigned)Section.FindI("Installed-Size");
+   Ver->InstalledSize = Section.FindULL("Installed-Size");
    Ver->InstalledSize *= 1024;
 
    // Priority
@@ -255,9 +255,13 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
    if (Pkg->Section == 0)
       Pkg->Section = UniqFindTagWrite("Section");
 
-   // Packages which are not from "our" arch doesn't get the essential flag
+   // Packages which are not from the "native" arch doesn't get the essential flag
+   // in the default "native" mode - it is also possible to mark "all" or "none".
+   // The "installed" mode is handled by ParseStatus(), See #544481 and friends.
    string const static myArch = _config->Find("APT::Architecture");
-   if (Pkg->Arch != 0 && myArch == Pkg.Arch())
+   string const static essential = _config->Find("pkgCacheGen::Essential", "native");
+   if ((essential == "native" && Pkg->Arch != 0 && myArch == Pkg.Arch()) ||
+       essential == "all")
       if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
         return false;
    if (Section.FindFlag("Important",Pkg->Flags,pkgCache::Flag::Important) == false)
@@ -333,7 +337,13 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg,
    const char *Stop;
    if (Section.Find("Status",Start,Stop) == false)
       return true;
-   
+
+   // UsePackage() is responsible for setting the flag in the default case
+   bool const static essential = _config->Find("pkgCacheGen::Essential", "") == "installed";
+   if (essential == true &&
+       Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
+      return false;
+
    // Isolate the first word
    const char *I = Start;
    for(; I < Stop && *I != ' '; I++);