Просмотр исходного кода

add #ifdefed ABI break & cleaner solution once the abi break is in place

Michael Vogt лет назад: 12
Родитель
Сommit
916e5cb41e
6 измененных файлов с 72 добавлено и 8 удалено
  1. 2 1
      apt-pkg/deb/debmetaindex.cc
  2. 5 0
      apt-pkg/deb/debmetaindex.h
  3. 1 1
      apt-pkg/makefile
  4. 44 0
      apt-pkg/metaindex.cc
  5. 15 6
      apt-pkg/metaindex.h
  6. 5 0
      cmdline/apt-get.cc

+ 2 - 1
apt-pkg/deb/debmetaindex.cc

@@ -1,4 +1,3 @@
-// ijones, walters
 #include <config.h>
 #include <config.h>
 
 
 #include <apt-pkg/debmetaindex.h>
 #include <apt-pkg/debmetaindex.h>
@@ -36,6 +35,7 @@ string debReleaseIndex::Info(const char *Type, string const &Section, string con
    return Info;
    return Info;
 }
 }
 
 
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
 string debReleaseIndex::MetaIndexInfo(const char *Type) const
 string debReleaseIndex::MetaIndexInfo(const char *Type) const
 {
 {
    string Info = ::URI::SiteOnly(URI) + ' ';
    string Info = ::URI::SiteOnly(URI) + ' ';
@@ -71,6 +71,7 @@ string debReleaseIndex::MetaIndexURI(const char *Type) const
    Res += Type;
    Res += Type;
    return Res;
    return Res;
 }
 }
+#endif
 
 
 string debReleaseIndex::IndexURISuffix(const char *Type, string const &Section, string const &Arch) const
 string debReleaseIndex::IndexURISuffix(const char *Type, string const &Section, string const &Arch) const
 {
 {

+ 5 - 0
apt-pkg/deb/debmetaindex.h

@@ -3,6 +3,7 @@
 #define PKGLIB_DEBMETAINDEX_H
 #define PKGLIB_DEBMETAINDEX_H
 
 
 #include <apt-pkg/metaindex.h>
 #include <apt-pkg/metaindex.h>
+#include <apt-pkg/init.h>
 
 
 #include <map>
 #include <map>
 #include <string>
 #include <string>
@@ -39,9 +40,13 @@ class debReleaseIndex : public metaIndex {
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
    std::vector <struct IndexTarget *>* ComputeIndexTargets() const;
    std::vector <struct IndexTarget *>* ComputeIndexTargets() const;
    std::string Info(const char *Type, std::string const &Section, std::string const &Arch="") const;
    std::string Info(const char *Type, std::string const &Section, std::string const &Arch="") const;
+
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
    std::string MetaIndexInfo(const char *Type) const;
    std::string MetaIndexInfo(const char *Type) const;
    std::string MetaIndexFile(const char *Types) const;
    std::string MetaIndexFile(const char *Types) const;
    std::string MetaIndexURI(const char *Type) const;
    std::string MetaIndexURI(const char *Type) const;
+#endif
+
    std::string IndexURI(const char *Type, std::string const &Section, std::string const &Arch="native") const;
    std::string IndexURI(const char *Type, std::string const &Section, std::string const &Arch="native") const;
    std::string IndexURISuffix(const char *Type, std::string const &Section, std::string const &Arch="native") const;
    std::string IndexURISuffix(const char *Type, std::string const &Section, std::string const &Arch="native") const;
    std::string SourceIndexURI(const char *Type, const std::string &Section) const;
    std::string SourceIndexURI(const char *Type, const std::string &Section) const;

+ 1 - 1
apt-pkg/makefile

@@ -41,7 +41,7 @@ SOURCE+= pkgcache.cc version.cc depcache.cc \
 	 pkgrecords.cc algorithms.cc acquire.cc\
 	 pkgrecords.cc algorithms.cc acquire.cc\
 	 acquire-worker.cc acquire-method.cc init.cc clean.cc \
 	 acquire-worker.cc acquire-method.cc init.cc clean.cc \
 	 srcrecords.cc cachefile.cc versionmatch.cc policy.cc \
 	 srcrecords.cc cachefile.cc versionmatch.cc policy.cc \
-	 pkgsystem.cc indexfile.cc pkgcachegen.cc acquire-item.cc \
+	 pkgsystem.cc indexfile.cc metaindex.cc pkgcachegen.cc acquire-item.cc \
 	 indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \
 	 indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \
 	 aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc \
 	 aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc \
 	 install-progress.cc upgrade.cc update.cc
 	 install-progress.cc upgrade.cc update.cc

+ 44 - 0
apt-pkg/metaindex.cc

@@ -0,0 +1,44 @@
+
+#include <apt-pkg/strutl.h>
+
+#include "init.h"
+#include "metaindex.h"
+
+
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+string metaIndex::MetaIndexInfo(const char *Type) const
+{
+   string Info = ::URI::SiteOnly(URI) + ' ';
+   if (Dist[Dist.size() - 1] == '/')
+   {
+      if (Dist != "/")
+	 Info += Dist;
+   }
+   else
+      Info += Dist;
+   Info += " ";
+   Info += Type;
+   return Info;
+}
+
+string metaIndex::MetaIndexFile(const char *Type) const
+{
+   return _config->FindDir("Dir::State::lists") +
+      URItoFileName(MetaIndexURI(Type));
+}
+
+string metaIndex::MetaIndexURI(const char *Type) const
+{
+   string Res;
+
+   if (Dist == "/")
+      Res = URI;
+   else if (Dist[Dist.size()-1] == '/')
+      Res = URI + Dist;
+   else
+      Res = URI + "dists/" + Dist + "/";
+   
+   Res += Type;
+   return Res;
+}
+#endif

+ 15 - 6
apt-pkg/metaindex.h

@@ -5,6 +5,7 @@
 #include <string>
 #include <string>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/indexfile.h>
+#include <apt-pkg/init.h>
 
 
 #ifndef APT_8_CLEANER_HEADERS
 #ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/srcrecords.h>
 #include <apt-pkg/srcrecords.h>
@@ -28,24 +29,32 @@ class metaIndex
 
 
    public:
    public:
 
 
-   
    // Various accessors
    // Various accessors
    virtual std::string GetURI() const {return URI;}
    virtual std::string GetURI() const {return URI;}
    virtual std::string GetDist() const {return Dist;}
    virtual std::string GetDist() const {return Dist;}
    virtual const char* GetType() const {return Type;}
    virtual const char* GetType() const {return Type;}
 
 
    // Interface for acquire
    // Interface for acquire
-   virtual std::string ArchiveURI(std::string const& /*File*/) const = 0;
+   virtual std::string ArchiveURI(std::string const& File) const = 0;
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const = 0;
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const = 0;
-   
    virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0; 
    virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0; 
    virtual bool IsTrusted() const = 0;
    virtual bool IsTrusted() const = 0;
 
 
-   metaIndex(std::string const &URI, std::string const &Dist, char const * const Type) :
-		Indexes(NULL), Type(Type), URI(URI), Dist(Dist) {
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+   virtual std::string MetaIndexInfo(const char *Type) const;
+   virtual std::string MetaIndexFile(const char *Types) const;
+   virtual std::string MetaIndexURI(const char *Type) const;
+#endif
+
+   metaIndex(std::string const &URI, std::string const &Dist, 
+             char const * const Type) 
+      : Indexes(NULL), Type(Type), URI(URI), Dist(Dist)
+   {
+      /* nothing */
    }
    }
 
 
-   virtual ~metaIndex() {
+   virtual ~metaIndex() 
+   {
       if (Indexes == 0)
       if (Indexes == 0)
 	 return;
 	 return;
       for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();
       for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();

+ 5 - 0
cmdline/apt-get.cc

@@ -136,10 +136,15 @@ bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache,
 									/*}}}*/
 									/*}}}*/
 
 
 // FIXME: move into more generic code (metaindex ?)
 // FIXME: move into more generic code (metaindex ?)
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
 std::string MetaIndexFileName(metaIndex *metaindex)
 std::string MetaIndexFileName(metaIndex *metaindex)
 {
 {
    // FIXME: this cast is the horror, the horror
    // FIXME: this cast is the horror, the horror
    debReleaseIndex *r = (debReleaseIndex*)metaindex;
    debReleaseIndex *r = (debReleaseIndex*)metaindex;
+#else
+std::string MetaIndexFileName(metaIndex *r)
+{
+#endif
 
 
    // see if we have a InRelease file
    // see if we have a InRelease file
    std::string PathInRelease =  r->MetaIndexFile("InRelease");
    std::string PathInRelease =  r->MetaIndexFile("InRelease");