Michael Vogt лет назад: 12
Родитель
Сommit
a49e794802

+ 52 - 0
apt-pkg/deb/debindexfile.cc

@@ -667,6 +667,42 @@ APT_CONST bool debStatusIndex::Exists() const
 }
 									/*}}}*/
 
+
+// debDscFileIndex stuff
+debDscFileIndex::debDscFileIndex(std::string &DscFile) 
+   : pkgIndexFile(true), DscFile(DscFile)
+{
+}
+
+bool debDscFileIndex::Exists() const
+{
+   return FileExists(DscFile);
+}
+
+unsigned long debDscFileIndex::Size() const
+{
+   struct stat buf;
+   if(stat(DscFile.c_str(), &buf) == 0)
+      return buf.st_size;
+   return 0;
+}
+
+// DscFileIndex::CreateSrcParser - Get a parser for the .dsc file	/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgSrcRecords::Parser *debDscFileIndex::CreateSrcParser() const
+{
+   if (!FileExists(DscFile))
+      return NULL;
+
+   return new debDscRecordParser(DscFile,this);
+}
+									/*}}}*/
+
+
+
+
+// ---------------------------------------------------------------------
 // Index File types for Debian						/*{{{*/
 class debIFTypeSrc : public pkgIndexFile::Type
 {
@@ -699,10 +735,22 @@ class debIFTypeStatus : public pkgIndexFile::Type
    };
    debIFTypeStatus() {Label = "Debian dpkg status file";};
 };
+class debIFTypeDscFile : public pkgIndexFile::Type
+{
+   public:
+   virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string DscFile) const
+   {
+      return new debDscRecordParser(DscFile, NULL);
+   };
+   debIFTypeDscFile() {Label = "dsc File Source Index";};
+};
+
 static debIFTypeSrc _apt_Src;
 static debIFTypePkg _apt_Pkg;
 static debIFTypeTrans _apt_Trans;
 static debIFTypeStatus _apt_Status;
+// file based pseudo indexes
+static debIFTypeDscFile _apt_DscFile;
 
 const pkgIndexFile::Type *debSourcesIndex::GetType() const
 {
@@ -720,5 +768,9 @@ const pkgIndexFile::Type *debStatusIndex::GetType() const
 {
    return &_apt_Status;
 }
+const pkgIndexFile::Type *debDscFileIndex::GetType() const
+{
+   return &_apt_DscFile;
+}
 
 									/*}}}*/

+ 18 - 0
apt-pkg/deb/debindexfile.h

@@ -164,4 +164,22 @@ class debSourcesIndex : public pkgIndexFile
    virtual ~debSourcesIndex() {};
 };
 
+class debDscFileIndex : public pkgIndexFile
+{
+ private:
+   std::string DscFile;
+ public:
+   virtual const Type *GetType() const APT_CONST;
+   virtual pkgSrcRecords::Parser *CreateSrcParser() const;
+   virtual bool Exists() const;
+   virtual bool HasPackages() const {return false;};
+   virtual unsigned long Size() const;
+   virtual std::string Describe(bool /*Short*/) const {
+      return DscFile;
+   };
+
+   debDscFileIndex(std::string &DscFile);
+   virtual ~debDscFileIndex() {};
+};
+
 #endif

+ 2 - 2
apt-pkg/deb/debsrcrecords.cc

@@ -192,8 +192,8 @@ debSrcRecordParser::~debSrcRecordParser()
 									/*}}}*/
 
 
-debDscRecordParser::debDscRecordParser(std::string const &DscFile)
-   : debSrcRecordParser(DscFile, NULL)
+debDscRecordParser::debDscRecordParser(std::string const &DscFile, pkgIndexFile const *Index)
+   : debSrcRecordParser(DscFile, Index)
 {
    // support clear signed files
    if (OpenMaybeClearSignedFile(DscFile, Fd) == false)

+ 1 - 1
apt-pkg/deb/debsrcrecords.h

@@ -64,7 +64,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
 class debDscRecordParser : public debSrcRecordParser
 {
  public:
-   debDscRecordParser(std::string const &DscFile);
+   debDscRecordParser(std::string const &DscFile, pkgIndexFile const *Index);
 };
 
 #endif

+ 1 - 0
apt-pkg/indexfile.h

@@ -59,6 +59,7 @@ class pkgIndexFile
       const char *Label;
 
       virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
+      virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string /*File*/) const {return 0;};
       Type();
       virtual ~Type() {};
    };

+ 4 - 2
apt-pkg/pkgsystem.h

@@ -85,10 +85,12 @@ class pkgSystem
    virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0;   
    virtual bool FindIndex(pkgCache::PkgFileIterator File,
 			  pkgIndexFile *&Found) const = 0;
-   
+
    /* Evauluate how 'right' we are for this system based on the filesystem
       etc.. */
-   virtual signed Score(Configuration const &/*Cnf*/) {return 0;};
+   virtual signed Score(Configuration const &/*Cnf*/) {
+      return 0;
+   };
    
    pkgSystem();
    virtual ~pkgSystem() {};

+ 1 - 1
apt-pkg/sourcelist.h

@@ -86,7 +86,7 @@ class pkgSourceList
    
    typedef std::vector<metaIndex *>::const_iterator const_iterator;
    
-   protected:
+   public:
 
    std::vector<metaIndex *> SrcList;
 

+ 10 - 10
cmdline/apt-get.cc

@@ -57,9 +57,6 @@
 #include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/upgrade.h>
 
-// FIXME: direct include of deb specific header
-#include <apt-pkg/debsrcrecords.h>
-
 #include <apt-private/acqprogress.h>
 #include <apt-private/private-cacheset.h>
 #include <apt-private/private-cachefile.h>
@@ -1057,22 +1054,25 @@ static bool DoBuildDep(CommandLine &CmdL)
    {
       string Src;
       pkgSrcRecords::Parser *Last = 0;
-      vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
 
-      // support local .dsc files
-      if (FileExists(*I) && flExtension(*I) == "dsc")
+      // if its a local file (e.g. .dsc) use this
+      if (FileExists(*I))
       {
-         // FIXME: add a layer of abstraction
-         Last = new debDscRecordParser(*I);
-         Src = *I;
+         // see if we can get a parser for this pkgIndexFile type
+         string TypeName = flExtension(*I) + " File Source Index";
+         pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
+         if(Type != NULL)
+            Last = Type->CreateSrcPkgParser(*I);
       } else {
+         // normal case, search the cache for the source file
          Last = FindSrc(*I,Recs,SrcRecs,Src,Cache);
       }
+
       if (Last == 0)
 	 return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
             
       // Process the build-dependencies
-
+      vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
       // FIXME: Can't specify architecture to use for [wildcard] matching, so switch default arch temporary
       if (hostArch.empty() == false)
       {