]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debindexfile.cc
merge with lp:~mvo/apt/debian-sid to get 0.7.25.1 and my changes back
[apt.git] / apt-pkg / deb / debindexfile.cc
index 38ecdd16af5249adb44f96d124aa48d792f5b430..201fd7fdf754bf59967ee2bb77683c9c80d31c66 100644 (file)
@@ -9,10 +9,6 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/debindexfile.h"
-#endif
-
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/deblistparser.h>
@@ -305,14 +301,24 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    for (; File.end() == false; File++)
    {
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    for (; File.end() == false; File++)
    {
-      if (FileName != File.FileName())
+       if (File.FileName() == NULL || FileName != File.FileName())
         continue;
       
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
         continue;
       
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "PackagesIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
         return pkgCache::PkgFileIterator(Cache);
+      }
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "PackagesIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
+                       << ") or mtime (" << St.st_mtime << " <> " << File->mtime
+                       << ") doesn't match for " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
         return pkgCache::PkgFileIterator(Cache);
+      }
       return File;
    }
    
       return File;
    }
    
@@ -323,10 +329,11 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
 // TranslationsIndex::debTranslationsIndex - Contructor                        /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // TranslationsIndex::debTranslationsIndex - Contructor                        /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section) : 
-                  pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section)
-{
-}
+debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section,
+                                               char const * const Translation) :
+                       pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section),
+                               Language(Translation)
+{}
                                                                        /*}}}*/
 // TranslationIndex::Trans* - Return the URI to the translation files  /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // TranslationIndex::Trans* - Return the URI to the translation files  /*{{{*/
 // ---------------------------------------------------------------------
@@ -359,8 +366,8 @@ string debTranslationsIndex::IndexURI(const char *Type) const
 bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
 {
    if (TranslationsAvailable()) {
 bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
 {
    if (TranslationsAvailable()) {
-     string TranslationFile = "Translation-" + LanguageCode();
-     new pkgAcqIndexTrans(Owner, IndexURI(LanguageCode().c_str()),
+     string const TranslationFile = string("Translation-").append(Language);
+     new pkgAcqIndexTrans(Owner, IndexURI(Language),
                          Info(TranslationFile.c_str()),
                          TranslationFile);
    }
                          Info(TranslationFile.c_str()),
                          TranslationFile);
    }
@@ -379,7 +386,7 @@ string debTranslationsIndex::Describe(bool Short) const
       snprintf(S,sizeof(S),"%s",Info(TranslationFile().c_str()).c_str());
    else
       snprintf(S,sizeof(S),"%s (%s)",Info(TranslationFile().c_str()).c_str(),
       snprintf(S,sizeof(S),"%s",Info(TranslationFile().c_str()).c_str());
    else
       snprintf(S,sizeof(S),"%s (%s)",Info(TranslationFile().c_str()).c_str(),
-              IndexFile(LanguageCode().c_str()).c_str());
+              IndexFile(Language).c_str());
    return S;
 }
                                                                        /*}}}*/
    return S;
 }
                                                                        /*}}}*/
@@ -401,20 +408,20 @@ string debTranslationsIndex::Info(const char *Type) const
    return Info;
 }
                                                                        /*}}}*/
    return Info;
 }
                                                                        /*}}}*/
-bool debTranslationsIndex::HasPackages() const
+bool debTranslationsIndex::HasPackages() const                         /*{{{*/
 {
    if(!TranslationsAvailable())
       return false;
    
 {
    if(!TranslationsAvailable())
       return false;
    
-   return FileExists(IndexFile(LanguageCode().c_str()));
+   return FileExists(IndexFile(Language));
 }
 }
-
+                                                                       /*}}}*/
 // TranslationsIndex::Exists - Check if the index is available         /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 bool debTranslationsIndex::Exists() const
 {
 // TranslationsIndex::Exists - Check if the index is available         /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 bool debTranslationsIndex::Exists() const
 {
-   return FileExists(IndexFile(LanguageCode().c_str()));
+   return FileExists(IndexFile(Language));
 }
                                                                        /*}}}*/
 // TranslationsIndex::Size - Return the size of the index              /*{{{*/
 }
                                                                        /*}}}*/
 // TranslationsIndex::Size - Return the size of the index              /*{{{*/
@@ -423,7 +430,7 @@ bool debTranslationsIndex::Exists() const
 unsigned long debTranslationsIndex::Size() const
 {
    struct stat S;
 unsigned long debTranslationsIndex::Size() const
 {
    struct stat S;
-   if (stat(IndexFile(LanguageCode().c_str()).c_str(),&S) != 0)
+   if (stat(IndexFile(Language).c_str(),&S) != 0)
       return 0;
    return S.st_size;
 }
       return 0;
    return S.st_size;
 }
@@ -434,7 +441,7 @@ unsigned long debTranslationsIndex::Size() const
 bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 {
    // Check the translation file, if in use
 bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 {
    // Check the translation file, if in use
-   string TranslationFile = IndexFile(LanguageCode().c_str());
+   string TranslationFile = IndexFile(Language);
    if (TranslationsAvailable() && FileExists(TranslationFile))
    {
      FileFd Trans(TranslationFile,FileFd::ReadOnly);
    if (TranslationsAvailable() && FileExists(TranslationFile))
    {
      FileFd Trans(TranslationFile,FileFd::ReadOnly);
@@ -466,7 +473,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 /* */
 pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
 {
 /* */
 pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
 {
-   string FileName = IndexFile(LanguageCode().c_str());
+   string FileName = IndexFile(Language);
    
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    for (; File.end() == false; File++)
    
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    for (; File.end() == false; File++)
@@ -476,9 +483,19 @@ pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) con
 
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
 
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "TranslationIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
         return pkgCache::PkgFileIterator(Cache);
+      }
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "TranslationIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
+                       << ") or mtime (" << St.st_mtime << " <> " << File->mtime
+                       << ") doesn't match for " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
         return pkgCache::PkgFileIterator(Cache);
+      }
       return File;
    }   
    return File;
       return File;
    }   
    return File;
@@ -545,9 +562,19 @@ pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
       
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
       
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "StatusIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
         return pkgCache::PkgFileIterator(Cache);
+      }
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "StatusIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
+                       << ") or mtime (" << St.st_mtime << " <> " << File->mtime
+                       << ") doesn't match for " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
         return pkgCache::PkgFileIterator(Cache);
+      }
       return File;
    }   
    return File;
       return File;
    }   
    return File;