]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debmetaindex.cc
Fix a segfault in the version merger introduced in the previous patch:
[apt.git] / apt-pkg / deb / debmetaindex.cc
index d3b6ed957181941e5b28d431e71410c354419c2f..520e94a807a0d80cb187ed0bab9bea062b2ca843 100644 (file)
@@ -1,14 +1,11 @@
 // ijones, walters
 
 // ijones, walters
 
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/debmetaindex.h"
-#endif
-
 #include <apt-pkg/debmetaindex.h>
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/debmetaindex.h>
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/error.h>
 
 using namespace std;
 #include <apt-pkg/error.h>
 
 using namespace std;
@@ -119,6 +116,13 @@ debReleaseIndex::debReleaseIndex(string URI,string Dist)
    this->Type = "deb";
 }
 
    this->Type = "deb";
 }
 
+debReleaseIndex::~debReleaseIndex()
+{
+   for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
+       I != SectionEntries.end(); I++)
+      delete *I;
+}
+
 vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const
 {
    vector <struct IndexTarget *>* IndexTargets = new vector <IndexTarget *>;
 vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const
 {
    vector <struct IndexTarget *>* IndexTargets = new vector <IndexTarget *>;
@@ -148,9 +152,18 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool GetAll) const
       vector <struct IndexTarget *> *targets = ComputeIndexTargets();
       for (vector <struct IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); Target++) {
         new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
       vector <struct IndexTarget *> *targets = ComputeIndexTargets();
       for (vector <struct IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); Target++) {
         new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
-                        (*Target)->ShortDesc, "");
+                        (*Target)->ShortDesc, HashString());
       }
       }
+      // this is normally created in pkgAcqMetaSig, but if we run
+      // in --print-uris mode, we add it here
+      new pkgAcqMetaIndex(Owner, MetaIndexURI("Release"),
+                    MetaIndexInfo("Release"), "Release",
+                    MetaIndexURI("Release.gpg"), 
+                    ComputeIndexTargets(),
+                    new indexRecords (Dist));
+
    }
    }
+
    new pkgAcqMetaSig(Owner, MetaIndexURI("Release.gpg"),
                     MetaIndexInfo("Release.gpg"), "Release.gpg",
                     MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
    new pkgAcqMetaSig(Owner, MetaIndexURI("Release.gpg"),
                     MetaIndexInfo("Release.gpg"), "Release.gpg",
                     MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
@@ -158,11 +171,20 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool GetAll) const
                     new indexRecords (Dist));
 
    // Queue the translations
                     new indexRecords (Dist));
 
    // Queue the translations
+   std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
    for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin(); 
        I != SectionEntries.end(); I++) {
 
    for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin(); 
        I != SectionEntries.end(); I++) {
 
-      debTranslationsIndex i = debTranslationsIndex(URI,Dist,(*I)->Section);
-      i.GetIndexes(Owner);
+      if((*I)->IsSrc)
+        continue;
+
+      for (vector<string>::const_iterator l = lang.begin();
+               l != lang.end(); l++)
+      {
+       if (*l == "none") continue;
+       debTranslationsIndex i = debTranslationsIndex(URI,Dist,(*I)->Section,(*l).c_str());
+       i.GetIndexes(Owner);
+      }
    }
 
    return true;
    }
 
    return true;
@@ -188,6 +210,7 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
       return Indexes;
 
    Indexes = new vector <pkgIndexFile*>;
       return Indexes;
 
    Indexes = new vector <pkgIndexFile*>;
+   std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
    for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin(); 
        I != SectionEntries.end(); I++) {
       if ((*I)->IsSrc)
    for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin(); 
        I != SectionEntries.end(); I++) {
       if ((*I)->IsSrc)
@@ -195,7 +218,12 @@ vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
       else 
       {
          Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted()));
       else 
       {
          Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted()));
-        Indexes->push_back(new debTranslationsIndex(URI, Dist, (*I)->Section));
+
+        for (vector<string>::const_iterator l = lang.begin();
+               l != lang.end(); l++) {
+           if (*l == "none") continue;
+           Indexes->push_back(new debTranslationsIndex(URI,Dist,(*I)->Section,(*l).c_str()));
+        }
       }
    }
 
       }
    }
 
@@ -226,7 +254,7 @@ class debSLTypeDebian : public pkgSourceList::Type
         // This check insures that there will be only one Release file
         // queued for all the Packages files and Sources files it
         // corresponds to.
         // This check insures that there will be only one Release file
         // queued for all the Packages files and Sources files it
         // corresponds to.
-        if ((*I)->GetType() == "deb")
+               if (strcmp((*I)->GetType(), "deb") == 0)
         {
            debReleaseIndex *Deb = (debReleaseIndex *) (*I);
            // This check insures that there will be only one Release file
         {
            debReleaseIndex *Deb = (debReleaseIndex *) (*I);
            // This check insures that there will be only one Release file