]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debindexfile.cc
* merged from apt--mvo
[apt.git] / apt-pkg / deb / debindexfile.cc
index 1d8c1e8ecd757e207752678ed6611693ea9fdb67..9f435bba55dc4df5da75afa718e6f9149aeab6a3 100644 (file)
@@ -24,7 +24,7 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/debmetaindex.h>
-    
+
 #include <sys/stat.h>
                                                                        /*}}}*/
 
@@ -290,7 +290,7 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
       FileFd Rel(ReleaseFile,FileFd::ReadOnly);
       if (_error->PendingError() == true)
         return false;
-      Parser.LoadReleaseInfo(File,Rel);
+      Parser.LoadReleaseInfo(File,Rel,Section);
    }
    
    return true;
@@ -305,7 +305,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
    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;
@@ -324,7 +324,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
 // ---------------------------------------------------------------------
 /* */
 debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section) : 
-                  URI(URI), Dist(Dist), Section(Section)
+                  pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section)
 {
 }
                                                                        /*}}}*/
@@ -358,7 +358,7 @@ string debTranslationsIndex::IndexURI(const char *Type) 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()),
@@ -401,12 +401,20 @@ string debTranslationsIndex::Info(const char *Type) const
    return Info;
 }
                                                                        /*}}}*/
+bool debTranslationsIndex::HasPackages() const
+{
+   if(!TranslationsAvailable())
+      return false;
+   
+   return FileExists(IndexFile(LanguageCode().c_str()));
+}
+
 // TranslationsIndex::Exists - Check if the index is available         /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 bool debTranslationsIndex::Exists() const
 {
-   return true;
+   return FileExists(IndexFile(LanguageCode().c_str()));
 }
                                                                        /*}}}*/
 // TranslationsIndex::Size - Return the size of the index              /*{{{*/
@@ -427,7 +435,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 {
    // 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);
@@ -453,7 +461,29 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
    return true;
 }
                                                                        /*}}}*/
+// TranslationsIndex::FindInCache - Find this index                            /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
+{
+   string FileName = IndexFile(LanguageCode().c_str());
+   
+   pkgCache::PkgFileIterator File = Cache.FileBegin();
+   for (; File.end() == false; File++)
+   {
+      if (FileName != File.FileName())
+        continue;
 
+      struct stat St;
+      if (stat(File.FileName(),&St) != 0)
+        return pkgCache::PkgFileIterator(Cache);
+      if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+        return pkgCache::PkgFileIterator(Cache);
+      return File;
+   }   
+   return File;
+}
+                                                                       /*}}}*/
 // StatusIndex::debStatusIndex - Constructor                           /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -550,6 +580,11 @@ class debIFTypePkg : public pkgIndexFile::Type
    };
    debIFTypePkg() {Label = "Debian Package Index";};
 };
+class debIFTypeTrans : public debIFTypePkg
+{
+   public:
+   debIFTypeTrans() {Label = "Debian Translation Index";};
+};
 class debIFTypeStatus : public pkgIndexFile::Type
 {
    public:
@@ -562,6 +597,7 @@ class debIFTypeStatus : public pkgIndexFile::Type
 };
 static debIFTypeSrc _apt_Src;
 static debIFTypePkg _apt_Pkg;
+static debIFTypeTrans _apt_Trans;
 static debIFTypeStatus _apt_Status;
 
 const pkgIndexFile::Type *debSourcesIndex::GetType() const
@@ -574,7 +610,7 @@ const pkgIndexFile::Type *debPackagesIndex::GetType() const
 }
 const pkgIndexFile::Type *debTranslationsIndex::GetType() const
 {
-   return &_apt_Pkg;
+   return &_apt_Trans;
 }
 const pkgIndexFile::Type *debStatusIndex::GetType() const
 {