]> git.saurik.com Git - apt.git/commitdiff
Add with pkgCacheGen::Essential a way to control which packages get the
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 21 Mar 2010 20:48:09 +0000 (21:48 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 21 Mar 2010 20:48:09 +0000 (21:48 +0100)
essential flag:
* native is the default and will only mark packages of the main arch
* all will mark all packages which have these flag in Packages
* none will obviously do the opposite
* installed will only mark packages which are installed as essential,
  so it will behave in the same way as dpkg does it.
It is mostly needed sometimes for debugging but some users with special
needs might like to switch the mode as well under the expense to be
on their own…

apt-pkg/deb/deblistparser.cc
doc/examples/configure-index

index 5c9cf6d4bfe79c27ebd5c4061f3008360c4a453b..947e060e31e20ad7f81d3068a2d1d7dd71eb56d6 100644 (file)
@@ -255,9 +255,13 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
    if (Pkg->Section == 0)
       Pkg->Section = UniqFindTagWrite("Section");
 
    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");
    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)
       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;
    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++);
    // Isolate the first word
    const char *I = Start;
    for(; I < Stop && *I != ' '; I++);
index f07302efd4c0c56e26b77b202f62cec4196753b5..f08a42ec733d34152f5c2f3b71839e48b1338904 100644 (file)
@@ -432,6 +432,8 @@ Debug
   
 }
 
   
 }
 
+pkgCacheGen::Essential "native"; // other modes: all, none, installed
+
 /* Whatever you do, do not use this configuration file!! Take out ONLY
    the portions you need! */
 This Is Not A Valid Config File
 /* Whatever you do, do not use this configuration file!! Take out ONLY
    the portions you need! */
 This Is Not A Valid Config File