]> git.saurik.com Git - apt.git/commitdiff
* code cleanups (thanks matt!), moved UsePackage before the description list build...
authorMichael Vogt <michael.vogt@ubuntu.com>
Thu, 28 Jul 2005 09:59:06 +0000 (09:59 +0000)
committerMichael Vogt <michael.vogt@ubuntu.com>
Thu, 28 Jul 2005 09:59:06 +0000 (09:59 +0000)
apt-pkg/acquire-item.h
apt-pkg/cacheiterators.h
apt-pkg/deb/debindexfile.cc
apt-pkg/deb/deblistparser.cc
apt-pkg/deb/debmetaindex.cc
apt-pkg/indexfile.cc
apt-pkg/indexfile.h
apt-pkg/init.cc
apt-pkg/pkgcache.cc
apt-pkg/pkgcachegen.cc

index 0000f366ceee3a9cad806e8c861650e57aafc08f..2f7c71a8156abb658d94766bedb956a522b86287 100644 (file)
@@ -9,7 +9,7 @@
    the Owner Acquire class. Derived classes will then call QueueURI to 
    register all the URI's they wish to fetch at the initial moment.   
    
    the Owner Acquire class. Derived classes will then call QueueURI to 
    register all the URI's they wish to fetch at the initial moment.   
    
-   Tree item classes are provided to provide functionality for
+   Three item classes are provided to provide functionality for
    downloading of Index, Translation and Packages files.
    
    A Archive class is provided for downloading .deb files. It does Md5
    downloading of Index, Translation and Packages files.
    
    A Archive class is provided for downloading .deb files. It does Md5
@@ -106,7 +106,7 @@ class pkgAcqIndex : public pkgAcquire::Item
               string ShortDesct, string ExpectedMD5, string compressExt="");
 };
 
               string ShortDesct, string ExpectedMD5, string compressExt="");
 };
 
-// Item class for index files
+// Item class for translated package index files
 class pkgAcqIndexTrans : public pkgAcqIndex
 {
    public:
 class pkgAcqIndexTrans : public pkgAcqIndex
 {
    public:
index 797e854b67cfebd7c69f264c782be3b853dab9a7..e34920032b62b6bad2da45495c0755bf19e9244f 100644 (file)
@@ -99,7 +99,7 @@ class pkgCache::VerIterator
 {
    Version *Ver;
    pkgCache *Owner;
 {
    Version *Ver;
    pkgCache *Owner;
-   
+
    void _dummy();
    
    public:
    void _dummy();
    
    public:
index 5510ad1611570904ea8eb3c3e2b3bbf3c4a47f79..23cc7d0752fbce8cf710fca3dcebf58ecad9d311 100644 (file)
@@ -358,7 +358,7 @@ string debTranslationsIndex::IndexURI(const char *Type) const
 /* */
 bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
 {
 /* */
 bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
 {
-   if (UseTranslation()) {
+   if (TranslationsAvailable()) {
      string TranslationFile = "Translation-" + LanguageCode();
      new pkgAcqIndexTrans(Owner, IndexURI(LanguageCode().c_str()),
                          Info(TranslationFile.c_str()),
      string TranslationFile = "Translation-" + LanguageCode();
      new pkgAcqIndexTrans(Owner, IndexURI(LanguageCode().c_str()),
                          Info(TranslationFile.c_str()),
@@ -403,7 +403,7 @@ string debTranslationsIndex::Info(const char *Type) const
                                                                        /*}}}*/
 bool debTranslationsIndex::HasPackages() const
 {
                                                                        /*}}}*/
 bool debTranslationsIndex::HasPackages() const
 {
-   if(!UseTranslation())
+   if(!TranslationsAvailable())
       return false;
    
    return FileExists(IndexFile(LanguageCode().c_str()));
       return false;
    
    return FileExists(IndexFile(LanguageCode().c_str()));
@@ -435,7 +435,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 {
    // Check the translation file, if in use
    string TranslationFile = IndexFile(LanguageCode().c_str());
 {
    // Check the translation file, if in use
    string TranslationFile = IndexFile(LanguageCode().c_str());
-   if (UseTranslation() && FileExists(TranslationFile))
+   if (TranslationsAvailable() && FileExists(TranslationFile))
    {
      FileFd Trans(TranslationFile,FileFd::ReadOnly);
      debListParser TransParser(&Trans);
    {
      FileFd Trans(TranslationFile,FileFd::ReadOnly);
      debListParser TransParser(&Trans);
index 6e78ed42b80b71950d7fe0bdd7c6683f5ccb89fc..fcc31ec2cf516ecfb9f4d898c594cc9a8494aff1 100644 (file)
@@ -143,14 +143,16 @@ string debListParser::DescriptionLanguage()
                                                                         /*}}}*/
 // ListParser::Description - Return the description_md5 MD5SumValue    /*{{{*/
 // ---------------------------------------------------------------------
                                                                         /*}}}*/
 // ListParser::Description - Return the description_md5 MD5SumValue    /*{{{*/
 // ---------------------------------------------------------------------
-/* This is to return the md5 string to allow the check if is the right
-   description. If thisreturns a blank string then calculate the md5
-   value. */
+/* This is to return the md5 string to allow the check if it is the right
+   description. If no Description-md5 is found in the section it will be
+   calculated.
+ */
 MD5SumValue debListParser::Description_md5()
 {
    string value = Section.FindS("Description-md5");
 
 MD5SumValue debListParser::Description_md5()
 {
    string value = Section.FindS("Description-md5");
 
-   if (value.empty()) {
+   if (value.empty()) 
+   {
       MD5Summation md5;
       md5.Add((Description() + "\n").c_str());
       return md5.Result();
       MD5Summation md5;
       md5.Add((Description() + "\n").c_str());
       return md5.Result();
index 9c7828d6ae28eb86803cbab95aaa3f16bd73e63e..8dfbf7affe1fd4c3cff84d564c6aa18803f1f6bd 100644 (file)
@@ -189,8 +189,10 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
       if ((*I)->IsSrc)
          Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
       else 
       if ((*I)->IsSrc)
          Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
       else 
+      {
          Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted()));
          Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted()));
-      Indexes->push_back(new debTranslationsIndex(URI,Dist,(*I)->Section));
+        Indexes->push_back(new debTranslationsIndex(URI, Dist, (*I)->Section));
+      }
    }
 
    return Indexes;
    }
 
    return Indexes;
index 0f1f48af44461c46027eabf20565da68719aa66e..496e68b8bbd3945a9db2215c9c192caaddf9e763 100644 (file)
@@ -70,10 +70,10 @@ string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
    return string();
 }
                                                                        /*}}}*/
    return string();
 }
                                                                        /*}}}*/
-// IndexFile::UseTranslation - Check if will use Translation           /*{{{*/
+// IndexFile::TranslationsAvailable - Check if will use Translation    /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // ---------------------------------------------------------------------
 /* */
-bool pkgIndexFile::UseTranslation()
+bool pkgIndexFile::TranslationsAvailable()
 {
   const string Translation = _config->Find("APT::Acquire::Translation");
   
 {
   const string Translation = _config->Find("APT::Acquire::Translation");
   
@@ -89,7 +89,6 @@ bool pkgIndexFile::UseTranslation()
 /* common cases: de_DE, de_DE@euro, de_DE.UTF-8, de_DE.UTF-8@euro,
                  de_DE.ISO8859-1, tig_ER
                  more in /etc/gdm/locale.conf 
 /* common cases: de_DE, de_DE@euro, de_DE.UTF-8, de_DE.UTF-8@euro,
                  de_DE.ISO8859-1, tig_ER
                  more in /etc/gdm/locale.conf 
-                approach: just get the first letter before the underscore?!?
 */
 
 bool pkgIndexFile::CheckLanguageCode(const char *Lang)
 */
 
 bool pkgIndexFile::CheckLanguageCode(const char *Lang)
@@ -105,13 +104,20 @@ bool pkgIndexFile::CheckLanguageCode(const char *Lang)
                                                                        /*}}}*/
 // IndexFile::LanguageCode - Return the Language Code                  /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // IndexFile::LanguageCode - Return the Language Code                  /*{{{*/
 // ---------------------------------------------------------------------
-/* */
+/* return the language code */
 string pkgIndexFile::LanguageCode()
 {
   const string Translation = _config->Find("APT::Acquire::Translation");
 
 string pkgIndexFile::LanguageCode()
 {
   const string Translation = _config->Find("APT::Acquire::Translation");
 
-  if (Translation.compare("environment") == 0) {
+  if (Translation.compare("environment") == 0) 
+  {
      string lang = std::setlocale(LC_MESSAGES,NULL);
      string lang = std::setlocale(LC_MESSAGES,NULL);
+
+     // FIXME: this needs to be added
+     // we have a mapping of the language codes that contains all the language
+     // codes that need the country code as well 
+     // (like pt_BR, pt_PT, sv_SE, zh_*, en_*)
+
      if(lang.size() > 2)
        return lang.substr(0,2);
      else
      if(lang.size() > 2)
        return lang.substr(0,2);
      else
index 405f67a94b837dd52ad96067a86f5bdfc689fa5a..d5d1cf57aa6ec55bb126229f17aa044b44aee60f 100644 (file)
@@ -81,7 +81,7 @@ class pkgIndexFile
    virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return true;};
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
    virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return true;};
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
-   static bool UseTranslation();
+   static bool TranslationsAvailable();
    static bool CheckLanguageCode(const char *Lang);
    static string LanguageCode();
 
    static bool CheckLanguageCode(const char *Lang);
    static string LanguageCode();
 
index 3e4c17289eab90f4dfad01007c727d403fc2d15e..6118845e835197cb4ee223a1acd0aec209bf087c 100644 (file)
@@ -33,9 +33,6 @@ const char *pkgOS = COMMON_OS;
    is prepended, this allows a fair degree of flexability. */
 bool pkgInitConfig(Configuration &Cnf)
 {
    is prepended, this allows a fair degree of flexability. */
 bool pkgInitConfig(Configuration &Cnf)
 {
-   // Translation
-   Cnf.Set("APT::Acquire::Translation", "environment");
-
    // General APT things
    if (strcmp(COMMON_OS,"linux") == 0 ||
        strcmp(COMMON_OS,"unknown") == 0)
    // General APT things
    if (strcmp(COMMON_OS,"linux") == 0 ||
        strcmp(COMMON_OS,"unknown") == 0)
@@ -104,6 +101,9 @@ bool pkgInitConfig(Configuration &Cnf)
       bindtextdomain(textdomain(0),Cnf.FindDir("Dir::Locale").c_str());
    }
 #endif
       bindtextdomain(textdomain(0),Cnf.FindDir("Dir::Locale").c_str());
    }
 #endif
+
+   // Translation
+   Cnf.Set("APT::Acquire::Translation", "environment");
    
    return true;
 }
    
    return true;
 }
index 2189d5111cfb7b575ef63be80a3418d0aa2df57b..f76afb9357acc94e034f5002f539473b0084fcad 100644 (file)
@@ -244,11 +244,11 @@ const char *pkgCache::Priority(unsigned char Prio)
    return 0;
 }
                                                                        /*}}}*/
    return 0;
 }
                                                                        /*}}}*/
-
 // Bases for iterator classes                                          /*{{{*/
 void pkgCache::VerIterator::_dummy() {}
 void pkgCache::DepIterator::_dummy() {}
 void pkgCache::PrvIterator::_dummy() {}
 // Bases for iterator classes                                          /*{{{*/
 void pkgCache::VerIterator::_dummy() {}
 void pkgCache::DepIterator::_dummy() {}
 void pkgCache::PrvIterator::_dummy() {}
+void pkgCache::DescIterator::_dummy() {}
                                                                        /*}}}*/
 // PkgIterator::operator ++ - Postfix incr                             /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // PkgIterator::operator ++ - Postfix incr                             /*{{{*/
 // ---------------------------------------------------------------------
index a23e965fa24429fb16bb90dcfeec6c85e1a9a598..1ba791b45774e583823ce9c7836a6940f3705e00 100644 (file)
@@ -125,31 +125,39 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
       string Version = List.Version();
       if (Version.empty() == true)
       {
       string Version = List.Version();
       if (Version.empty() == true)
       {
+        // we first process the package, then the descriptions
+        // (this has the bonus that we get MMap error when we run out
+        //  of MMap space)
+        if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
+           return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
+                                PackageName.c_str());
+
         // Find the right version to write the description
         MD5SumValue CurMd5 = List.Description_md5();
         pkgCache::VerIterator Ver = Pkg.VersionList();
         map_ptrloc *LastVer = &Pkg->VersionList;
         // Find the right version to write the description
         MD5SumValue CurMd5 = List.Description_md5();
         pkgCache::VerIterator Ver = Pkg.VersionList();
         map_ptrloc *LastVer = &Pkg->VersionList;
-        
+
         for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) 
         {
            pkgCache::DescIterator Desc = Ver.DescriptionList();
            map_ptrloc *LastDesc = &Ver->DescriptionList;
         for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) 
         {
            pkgCache::DescIterator Desc = Ver.DescriptionList();
            map_ptrloc *LastDesc = &Ver->DescriptionList;
-       
+
            for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++)
            for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++)
-              if (MD5SumValue(Desc.md5()) == CurMd5) {
+           {
+
+              if (MD5SumValue(Desc.md5()) == CurMd5) 
+               {
                  // Add new description
                  *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
                  Desc->ParentPkg = Pkg.Index();
                  // Add new description
                  *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
                  Desc->ParentPkg = Pkg.Index();
+                 
                  if (NewFileDesc(Desc,List) == false)
                     return _error->Error(_("Error occured while processing %s (NewFileDesc1)"),PackageName.c_str());
                  break;
               }
                  if (NewFileDesc(Desc,List) == false)
                     return _error->Error(_("Error occured while processing %s (NewFileDesc1)"),PackageName.c_str());
                  break;
               }
+           }
         }
         }
-        if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
-           return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
-                                PackageName.c_str());
+
         continue;
       }
 
         continue;
       }
 
@@ -403,14 +411,15 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
    unsigned long DescFile = Map.Allocate(sizeof(pkgCache::DescFile));
    if (DescFile == 0)
       return 0;
    unsigned long DescFile = Map.Allocate(sizeof(pkgCache::DescFile));
    if (DescFile == 0)
       return 0;
-   
+
    pkgCache::DescFileIterator DF(Cache,Cache.DescFileP + DescFile);
    DF->File = CurrentFile - Cache.PkgFileP;
    pkgCache::DescFileIterator DF(Cache,Cache.DescFileP + DescFile);
    DF->File = CurrentFile - Cache.PkgFileP;
-   
+
    // Link it to the end of the list
    map_ptrloc *Last = &Desc->FileList;
    for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++)
       Last = &D->NextFile;
    // Link it to the end of the list
    map_ptrloc *Last = &Desc->FileList;
    for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++)
       Last = &D->NextFile;
+
    DF->NextFile = *Last;
    *Last = DF.Index();
    
    DF->NextFile = *Last;
    *Last = DF.Index();