]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
* apt-pkg/deb/debrecords.cc:
[apt.git] / apt-pkg / deb / deblistparser.cc
index c2b26b5eb5322a8f4543a89bea742bf65004ef6c..66108d8220e96be3c0c76d9bc16baf217135b1bf 100644 (file)
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/crc-16.h>
 #include <apt-pkg/md5.h>
+#include <apt-pkg/macros.h>
 
 #include <ctype.h>
-
-#include <system.h>
                                                                        /*}}}*/
 
 static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important},
@@ -105,8 +105,12 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
       return false;
    if (ParseDepends(Ver,"Conflicts",pkgCache::Dep::Conflicts) == false)
       return false;
+   if (ParseDepends(Ver,"Breaks",pkgCache::Dep::DpkgBreaks) == false)
+      return false;
    if (ParseDepends(Ver,"Replaces",pkgCache::Dep::Replaces) == false)
       return false;
+   if (ParseDepends(Ver,"Enhances",pkgCache::Dep::Enhances) == false)
+      return false;
 
    // Obsolete.
    if (ParseDepends(Ver,"Optional",pkgCache::Dep::Suggests) == false)
@@ -125,10 +129,11 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
    only describe package properties */
 string debListParser::Description()
 {
-   if (DescriptionLanguage().empty())
+   string const lang = DescriptionLanguage();
+   if (lang.empty())
       return Section.FindS("Description");
    else
-      return Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str());
+      return Section.FindS(string("Description-").append(lang).c_str());
 }
                                                                         /*}}}*/
 // ListParser::DescriptionLanguage - Return the description lang string        /*{{{*/
@@ -138,7 +143,16 @@ string debListParser::Description()
    assumed to describe original description. */
 string debListParser::DescriptionLanguage()
 {
-   return Section.FindS("Description").empty() ? pkgIndexFile::LanguageCode() : "";
+   if (Section.FindS("Description").empty() == false)
+      return "";
+
+   std::vector<string> const lang = APT::Configuration::getLanguages();
+   for (std::vector<string>::const_iterator l = lang.begin();
+       l != lang.end(); l++)
+      if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false)
+        return *l;
+
+   return "";
 }
                                                                         /*}}}*/
 // ListParser::Description - Return the description_md5 MD5SumValue    /*{{{*/
@@ -193,6 +207,7 @@ unsigned short debListParser::VersionHash()
 //                            "Suggests",
 //                            "Recommends",
                             "Conflicts",
+                            "Breaks",
                             "Replaces",0};
    unsigned long Result = INIT_FCS;
    char S[1024];
@@ -210,7 +225,7 @@ unsigned short debListParser::VersionHash()
       for (; Start != End; Start++)
       {
         if (isspace(*Start) == 0)
-           *I++ = tolower(*Start);
+           *I++ = tolower_ascii(*Start);
         if (*Start == '<' && Start[1] != '<' && Start[1] != '=')
            *I++ = '=';
         if (*Start == '>' && Start[1] != '>' && Start[1] != '=')
@@ -290,6 +305,8 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg,
                             {"installed",pkgCache::State::Installed},
                             {"half-installed",pkgCache::State::HalfInstalled},
                             {"config-files",pkgCache::State::ConfigFiles},
+                            {"triggers-awaited",pkgCache::State::TriggersAwaited},
+                            {"triggers-pending",pkgCache::State::TriggersPending},
                             {"post-inst-failed",pkgCache::State::HalfConfigured},
                             {"removal-failed",pkgCache::State::HalfInstalled},
                             {}};
@@ -377,7 +394,8 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
    bit by bit. */
 const char *debListParser::ParseDepends(const char *Start,const char *Stop,
                                        string &Package,string &Ver,
-                                       unsigned int &Op, bool ParseArchFlags)
+                                       unsigned int &Op, bool const &ParseArchFlags,
+                                       bool const &StripMultiArch)
 {
    // Strip off leading space
    for (;Start != Stop && isspace(*Start) != 0; Start++);
@@ -396,7 +414,14 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
    
    // Stash the package name
    Package.assign(Start,I - Start);
-   
+
+   // We don't want to confuse library users which can't handle MultiArch
+   if (StripMultiArch == true) {
+      size_t const found = Package.rfind(':');
+      if (found != string::npos)
+        Package = Package.substr(0,found);
+   }
+
    // Skip white space to the '('
    for (;I != Stop && isspace(*I) != 0 ; I++);
    
@@ -632,6 +657,8 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI,
       FileI->Version = WriteUniqString(Start,Stop - Start);
    if (Section.Find("Origin",Start,Stop) == true)
       FileI->Origin = WriteUniqString(Start,Stop - Start);
+   if (Section.Find("Codename",Start,Stop) == true)
+      FileI->Codename = WriteUniqString(Start,Stop - Start);
    if (Section.Find("Label",Start,Stop) == true)
       FileI->Label = WriteUniqString(Start,Stop - Start);
    if (Section.Find("Architecture",Start,Stop) == true)