- drop repodb source list type, use sqlite vs xml automatically as available
authorPanu Matilainen <pmatilai@turre.koti.laiskiainen.org>
Tue, 24 Apr 2007 09:02:05 +0000 (12:02 +0300)
committerPanu Matilainen <pmatilai@turre.koti.laiskiainen.org>
Tue, 24 Apr 2007 09:02:05 +0000 (12:02 +0300)
- rename config option for repomd otherdata acquiring to repomd specific

apt-pkg/rpm/repomd.cc
apt-pkg/rpm/repomd.h
apt-pkg/rpm/rpmindexfile.cc
apt-pkg/rpm/rpmindexfile.h

index a349ccd..8647fe1 100644 (file)
@@ -99,6 +99,11 @@ bool repomdRepository::ParseRelease(string File)
    }
    
    GotRelease = true;
+   if (RepoFiles.find("primary_db") != RepoFiles.end()) {
+      ComprMethod = "bz2";
+   } else {
+      ComprMethod = "gz";
+   }
 
    xmlFreeDoc(RepoMD);
    return true;
index c2ebe08..cc973b4 100644 (file)
@@ -39,10 +39,9 @@ class repomdRepository : public pkgRepository
    bool FindURI(string DataType, string &URI);
    
    repomdRepository(string URI,string Dist, const pkgSourceList::Vendor *Vendor,
-                string RootURI, string Compr)
+                string RootURI)
       : pkgRepository(URI, Dist, Vendor, RootURI) 
    {
-      ComprMethod = Compr;
       // repomd always has a "release" file
       GotRelease = true;
    };
index e26d4bd..9daad8c 100644 (file)
@@ -640,6 +640,19 @@ bool rpmRepomdIndex::GetReleases(pkgAcquire *Owner) const
 bool rpmRepomdIndex::GetIndexes(pkgAcquire *Owner) const
 {
    string TypeURI;
+   bool AcqOther = _config->FindB("Acquire::RepoMD::OtherData", false);
+   if (Repository->FindURI("primary_db", TypeURI)) {
+      new pkgAcqIndex(Owner,Repository,IndexURI("primary_db"),
+                     Info("primary.sqlite"), "primary.sqlite");
+      new pkgAcqIndex(Owner,Repository,IndexURI("filelists_db"),
+                     Info("filelists.sqlite"), "filelists.sqlite");
+      if (AcqOther) {
+        new pkgAcqIndex(Owner,Repository,IndexURI("other_db"),
+                       Info("other.sqlite"), "other.sqlite");
+      }
+      return true;
+   } 
+   
    if (! Repository->FindURI("primary", TypeURI)) {
       _error->Error(_("Primary metadata not found in repository %s %s"),
                     Repository->URI.c_str(), Repository->Dist.c_str());
@@ -650,7 +663,7 @@ bool rpmRepomdIndex::GetIndexes(pkgAcquire *Owner) const
                   Info("primary.xml"), "primary.xml");
    new pkgAcqIndex(Owner,Repository,IndexURI("filelists"),
                   Info("filelists.xml"), "filelists.xml");
-   if (_config->FindB("Acquire::ChangeLogs", false)) {
+   if (AcqOther) {
       new pkgAcqIndex(Owner,Repository,IndexURI("other"),
                     Info("other.xml"), "other.xml");
    }
@@ -684,6 +697,16 @@ string rpmRepomdIndex::ReleasePath() const
    return _config->FindDir("Dir::State::lists")+URItoFileName(ReleaseURI("repomd.xml"));
 }
 
+RPMHandler* rpmRepomdIndex::CreateHandler() const
+{
+   string TypeURI;
+   if (Repository->FindURI("primary_db", TypeURI)) {
+      return new RPMSqliteHandler(IndexFile("primary_db"));
+   } else {
+      return new RPMRepomdHandler(IndexFile("primary"));
+   }
+} 
+
 bool rpmRepomdIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 {
    string PackageFile = IndexPath();
@@ -789,47 +812,6 @@ string rpmRepomdSrcIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
    return Res;
 }
 
-bool rpmRepomdDBIndex::GetIndexes(pkgAcquire *Owner) const
-{
-   string TypeURI;
-   // XXX Optimally we'd just fall back to repomd if sqlite data is not
-   // available but that'd require combining repomd and repomddb index
-   // types which in turn has other issues...
-   if (! Repository->FindURI("primary_db", TypeURI)) {
-      _error->Error(_("Primary metadata not found in repository %s %s"),
-                    Repository->URI.c_str(), Repository->Dist.c_str());
-      return false;
-   }
-
-   new pkgAcqIndex(Owner,Repository,IndexURI("primary_db"),
-                  Info("primary.sqlite"), "primary.sqlite");
-   new pkgAcqIndex(Owner,Repository,IndexURI("filelists_db"),
-                  Info("filelists.sqlite"), "filelists.sqlite");
-   if (_config->FindB("Acquire::ChangeLogs", false)) {
-      new pkgAcqIndex(Owner,Repository,IndexURI("other_db"),
-                    Info("other.sqlite"), "other.sqlite");
-   }
-   return true;
-}
-
-bool rpmRepomdDBIndex::MergeFileProvides(pkgCacheGenerator &Gen,
-                                       OpProgress &Prog) const
-{
-   string PackageFile = IndexPath();
-   RPMHandler *Handler = new RPMSqliteHandler(IndexPath());
-   rpmListParser Parser(Handler);
-   if (_error->PendingError() == true) {
-      delete Handler;
-      return _error->Error(_("Problem opening %s"),PackageFile.c_str());
-   }
-   // We call SubProgress with Size(), since we won't call SelectFile() here.
-   Prog.SubProgress(Size(),Info("pkglist"));
-   if (Gen.MergeFileProvides(Parser) == false)
-      return _error->Error(_("Problem with MergeFileProvides %s"),
-                          PackageFile.c_str());
-   delete Handler;
-   return true;
-}
 #endif /* APT_WITH_REPOMD */
 
 // DatabaseIndex::rpmDatabaseIndex - Constructor                       /*{{{*/
@@ -1066,8 +1048,7 @@ class rpmSLTypeRepomd : public rpmSLTypeGen
    public:
 
    pkgRepository *GetRepository(string URI,string Dist,
-                               const pkgSourceList::Vendor *Vendor,
-                               string Compr) const
+                               const pkgSourceList::Vendor *Vendor) const
    {
       pkgRepository *Rep = FindRepository(URI,Dist,Vendor);
       if (Rep != NULL)
@@ -1084,7 +1065,7 @@ class rpmSLTypeRepomd : public rpmSLTypeGen
       else
         BaseURI = URI + Dist + '/';
 
-      Rep = new repomdRepository(URI,Dist,Vendor,BaseURI,Compr);
+      Rep = new repomdRepository(URI,Dist,Vendor,BaseURI);
       RepList.push_back(Rep);
       return Rep;
    }
@@ -1093,7 +1074,7 @@ class rpmSLTypeRepomd : public rpmSLTypeGen
                   string URI, string Dist, string Section,
                   pkgSourceList::Vendor const *Vendor) const 
    {
-      pkgRepository *Rep = GetRepository(URI,Dist,Vendor,"gz");
+      pkgRepository *Rep = GetRepository(URI,Dist,Vendor);
       List.push_back(new rpmRepomdPkgIndex(URI,Dist,Section,Rep));
       return true;
    };
@@ -1137,7 +1118,7 @@ class rpmSLTypeRepomdSrc : public rpmSLTypeRepomd
                   string URI, string Dist, string Section,
                   pkgSourceList::Vendor const *Vendor) const 
    {
-      pkgRepository *Rep = GetRepository(URI,Dist,Vendor,"gz");
+      pkgRepository *Rep = GetRepository(URI,Dist,Vendor);
       List.push_back(new rpmRepomdSrcIndex(URI,Dist,Section,Rep));
       return true;
    };
@@ -1149,43 +1130,6 @@ class rpmSLTypeRepomdSrc : public rpmSLTypeRepomd
    }   
 };
 
-class rpmSLTypeRepomdDB : public rpmSLTypeRepomd
-{
-   public:
-   bool CreateItem(vector<pkgIndexFile *> &List,
-                  string URI, string Dist, string Section,
-                  pkgSourceList::Vendor const *Vendor) const 
-   {
-      pkgRepository *Rep = GetRepository(URI,Dist,Vendor,"bz2");
-      List.push_back(new rpmRepomdDBPkgIndex(URI,Dist,Section,Rep));
-      return true;
-   };
-
-   rpmSLTypeRepomdDB()
-   {
-      Name = "repodb";
-      Label = "RepoMD DB tree";
-   }   
-};
-
-class rpmSLTypeRepomdDBSrc : public rpmSLTypeRepomd
-{
-   public:
-   bool CreateItem(vector<pkgIndexFile *> &List,
-                  string URI, string Dist, string Section,
-                  pkgSourceList::Vendor const *Vendor) const 
-   {
-      pkgRepository *Rep = GetRepository(URI,Dist,Vendor,"bz2");
-      List.push_back(new rpmRepomdDBSrcIndex(URI,Dist,Section,Rep));
-      return true;
-   };
-
-   rpmSLTypeRepomdDBSrc()
-   {
-      Name = "repodb-src";
-      Label = "RepoMD DB src tree";
-   }   
-};
 #endif /* APT_WITH_REPOMD */
 
 rpmSLTypeRpm _apt_rpmType;
@@ -1195,8 +1139,6 @@ rpmSLTypeSrpmDir _apt_rpmSrcDirType;
 #ifdef APT_WITH_REPOMD
 rpmSLTypeRepomd _apt_repomdType;
 rpmSLTypeRepomdSrc _apt_repomdSrcType;
-rpmSLTypeRepomdDB _apt_repomdDBType;
-rpmSLTypeRepomdDBSrc _apt_repomdDBSrcType;
 #endif
                                                                        /*}}}*/
 // Index File types for rpm                                            /*{{{*/
@@ -1267,14 +1209,6 @@ const pkgIndexFile::Type *rpmRepomdSrcIndex::GetType() const
 {
    return &_apt_Src;
 }
-const pkgIndexFile::Type *rpmRepomdDBPkgIndex::GetType() const
-{
-   return &_apt_Pkg;
-}
-const pkgIndexFile::Type *rpmRepomdDBSrcIndex::GetType() const
-{
-   return &_apt_Src;
-}
 #endif
 
                                                                        /*}}}*/
index 57fbbb3..f909839 100644 (file)
@@ -302,8 +302,7 @@ class rpmRepomdIndex : public rpmIndexFile
    public:
 
    // Creates a RPMHandler suitable for usage with this object
-   virtual RPMHandler *CreateHandler() const
-          { return new RPMRepomdHandler(IndexFile("primary")); };
+   virtual RPMHandler *CreateHandler() const;
 
    virtual bool GetReleases(pkgAcquire *Owner) const;
 
@@ -370,60 +369,6 @@ class rpmRepomdSrcIndex : public rpmRepomdIndex
 
 };
 
-class rpmRepomdDBIndex : public rpmRepomdIndex
-{
-   protected:
-
-   virtual string IndexPath() const {return IndexFile("primary_db");};
-
-   public:
-
-   // Creates a RPMHandler suitable for usage with this object
-   virtual RPMHandler *CreateHandler() const
-          { return new RPMSqliteHandler(IndexFile("primary_db")); };
-   virtual bool GetIndexes(pkgAcquire *Owner) const;
-   virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,
-                                 OpProgress &/*Prog*/) const;
-
-
-   rpmRepomdDBIndex(string URI,string Dist,string Section,
-                     pkgRepository *Repository) :
-          rpmRepomdIndex(URI,Dist,Section,Repository) {};
-};
-
-class rpmRepomdDBPkgIndex : public rpmRepomdDBIndex
-{
-   protected:
-
-   virtual string MainType() const {return "repodb";};
-
-   public:
-
-   virtual bool HasPackages() const {return true;};
-   virtual const Type *GetType() const;
-
-
-   rpmRepomdDBPkgIndex(string URI,string Dist,string Section,
-                     pkgRepository *Repository) :
-          rpmRepomdDBIndex(URI,Dist,Section,Repository) {};
-
-};
-
-class rpmRepomdDBSrcIndex : public rpmRepomdDBIndex
-{
-   protected:
-
-   virtual string MainType() const {return "repodb-src";};
-
-   public:
-
-   virtual const Type *GetType() const;
-
-   rpmRepomdDBSrcIndex(string URI,string Dist,string Section,
-                     pkgRepository *Repository) :
-          rpmRepomdDBIndex(URI,Dist,Section,Repository) {};
-
-};
 #endif /* APT_WITH_REPOMD */
 
 #endif