]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
German translation proof read by Helge Kreutzmann
[apt.git] / apt-pkg / deb / deblistparser.cc
index e24ced27189fff38650ab555f29623c585e99c56..0f9fe310fb318e7b1c46345827758f6ec5be6d70 100644 (file)
@@ -50,8 +50,18 @@ static const debListParser::WordList PrioList[] = {
    in Step(), if no Architecture is given we will accept every arch
    we would accept in general with checkArchitecture() */
 debListParser::debListParser(FileFd *File) :
-   pkgCacheListParser(), d(NULL), Tags(File)
+   pkgCacheListParser(), Tags(File)
 {
+   // this dance allows an empty value to override the default
+   if (_config->Exists("pkgCacheGen::ForceEssential"))
+   {
+      forceEssential = _config->FindVector("pkgCacheGen::ForceEssential");
+      if (forceEssential.empty() == false && _config->Find("pkgCacheGen::ForceEssential").empty())
+        forceEssential.emplace_back("apt");
+   }
+   else
+      forceEssential.emplace_back("apt");
+   forceImportant = _config->FindVector("pkgCacheGen::ForceImportant");
 }
                                                                        /*}}}*/
 // ListParser::Package - Return the package name                       /*{{{*/
@@ -311,7 +321,7 @@ bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
    if (Section.FindFlag("Important",Pkg->Flags,pkgCache::Flag::Important) == false)
       return false;
 
-   if (strcmp(Pkg.Name(),"apt") == 0)
+   if (std::find(forceEssential.begin(), forceEssential.end(), Pkg.Name()) != forceEssential.end())
    {
       if ((essential == "native" && Pkg->Arch != 0 && myArch == Pkg.Arch()) ||
          essential == "all")
@@ -319,6 +329,8 @@ bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
       else
         Pkg->Flags |= pkgCache::Flag::Important;
    }
+   else if (std::find(forceImportant.begin(), forceImportant.end(), Pkg.Name()) != forceImportant.end())
+      Pkg->Flags |= pkgCache::Flag::Important;
 
    if (ParseStatus(Pkg,Ver) == false)
       return false;
@@ -344,14 +356,14 @@ unsigned short debListParser::VersionHash()
    {
       const char *Start;
       const char *End;
-      if (Section.Find(I,Start,End) == false || End - Start >= (signed)sizeof(S))
+      if (Section.Find(I,Start,End) == false)
         continue;
       
       /* Strip out any spaces from the text, this undoes dpkgs reformatting
          of certain fields. dpkg also has the rather interesting notion of
          reformatting depends operators < -> <= */
       char *J = S;
-      for (; Start != End; ++Start)
+      for (; Start != End && (J - S) < sizeof(S); ++Start)
       {
         if (isspace_ascii(*Start) != 0)
            continue;
@@ -999,7 +1011,7 @@ bool debListParser::SameVersion(unsigned short const Hash,         /*{{{*/
    // status file is parsed last, so the first version we encounter is
    // probably also the version we have downloaded
    unsigned long long const Size = Section.FindULL("Size");
-   if (Size != 0 && Size != Ver->Size)
+   if (Size != 0 && Ver->Size != 0 && Size != Ver->Size)
       return false;
    // available everywhere, but easier to check here than to include in VersionHash
    unsigned char MultiArch = ParseMultiArch(false);