]> git.saurik.com Git - apt.git/commitdiff
Merge remote-tracking branch 'mvo/feature/build-dep-dsc2' into debian/experimental
authorMichael Vogt <mvo@debian.org>
Thu, 8 May 2014 12:29:30 +0000 (14:29 +0200)
committerMichael Vogt <mvo@debian.org>
Thu, 8 May 2014 12:29:30 +0000 (14:29 +0200)
Conflicts:
apt-pkg/deb/debindexfile.cc
apt-pkg/deb/debindexfile.h
apt-pkg/deb/debsrcrecords.cc

1  2 
apt-pkg/deb/debindexfile.cc
apt-pkg/deb/debindexfile.h
apt-pkg/deb/debmetaindex.cc
apt-pkg/deb/debsrcrecords.cc
apt-pkg/sourcelist.h
cmdline/apt-get.cc

index 86ef92bfbc681b6a9a643ea010e943aa2eb4466b,bb688412333e3a3d8866dd67901eef3146345eee..37efa05b02e09ffe5f8891a5851ee3fad26e3a94
@@@ -668,97 -667,42 +668,132 @@@ APT_CONST bool debStatusIndex::Exists(
  }
                                                                        /*}}}*/
  
 +// debDebPkgFile - Single .deb file                                           /*{{{*/
 +// ---------------------------------------------------------------------
 +debDebPkgFileIndex::debDebPkgFileIndex(std::string DebFile)
 +   : pkgIndexFile(true), DebFile(DebFile)
 +{
 +   DebFileFullPath = flAbsPath(DebFile);
 +}
 +
 +std::string debDebPkgFileIndex::ArchiveURI(std::string /*File*/) const
 +{
 +   return "file:" + DebFileFullPath;
 +}
 +
 +bool debDebPkgFileIndex::Exists() const
 +{
 +   return FileExists(DebFile);
 +}
 +bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const
 +{
 +   if(Prog)
 +      Prog->SubProgress(0, "Reading deb file");
 +
 +   // get the control data out of the deb file vid dpkg -I
 +   // ... can I haz libdpkg?
 +   const char *Args[5] = {"/usr/bin/dpkg",
 +                          "-I",
 +                          DebFile.c_str(),
 +                          "control",
 +                          NULL};
 +   FileFd PipeFd;
 +   pid_t Child;
 +   if(Popen(Args, PipeFd, Child, FileFd::ReadOnly) == false)
 +      return _error->Error("Popen failed");
 +   // FIXME: static buffer
 +   char buf[8*1024];
 +   unsigned long long n = 0;
 +   if(PipeFd.Read(buf, sizeof(buf)-1, &n) == false)
 +      return _error->Errno("read", "Failed to read dpkg pipe");
 +   ExecWait(Child, "Popen");
 +
 +   // now write the control data to a tempfile
 +   SPtr<FileFd> DebControl = GetTempFile("deb-file-" + DebFile);
 +   if(DebControl == NULL)
 +      return false;
 +   DebControl->Write(buf, n);
 +   // append size of the file
 +   FileFd Fd(DebFile, FileFd::ReadOnly);
 +   string Size;
 +   strprintf(Size, "Size: %llu\n", Fd.Size());
 +   DebControl->Write(Size.c_str(), Size.size());
 +   // and rewind for the listparser
 +   DebControl->Seek(0);
 +
 +   // and give it to the list parser
 +   debDebFileParser Parser(DebControl, DebFile);
 +   if(Gen.SelectFile(DebFile, "local", *this) == false)
 +      return _error->Error("Problem with SelectFile %s", DebFile.c_str());
 +
 +   pkgCache::PkgFileIterator File = Gen.GetCurFile();
 +   File->Size = DebControl->Size();
 +   File->mtime = DebControl->ModificationTime();
 +   
 +   if (Gen.MergeList(Parser) == false)
 +      return _error->Error("Problem with MergeLister for %s", DebFile.c_str());
 +
 +   return true;
 +}
 +pkgCache::PkgFileIterator debDebPkgFileIndex::FindInCache(pkgCache &Cache) const
 +{
 +   // FIXME: we could simply always return pkgCache::PkgFileIterator(Cache);
 +   //        to indicate its never in the cache which will force a Merge()
 +   pkgCache::PkgFileIterator File = Cache.FileBegin();
 +   for (; File.end() == false; ++File)
 +   {
 +       if (File.FileName() == NULL || DebFile != File.FileName())
 +       continue;
 +
 +       return File;
 +   }
 +   
 +   return File;
 +}
 +unsigned long debDebPkgFileIndex::Size() const
 +{
 +   struct stat buf;
 +   if(stat(DebFile.c_str(), &buf) != 0)
 +      return 0;
 +   return buf.st_size;
 +}
 +                                                                      /*}}}*/
  
+ // 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
  {
@@@ -791,20 -735,32 +826,42 @@@ class debIFTypeStatus : public pkgIndex
     };
     debIFTypeStatus() {Label = "Debian dpkg status file";};
  };
 +class debIFTypeDebPkgFile : public pkgIndexFile::Type
 +{
 +   public:
 +   virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const 
 +   {
 +      return new debDebFileRecordParser(File.FileName(),*File.Cache());
 +   };
 +   debIFTypeDebPkgFile() {Label = "deb Package 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";};
+ };
+ class debIFTypeDebianSourceDir : public pkgIndexFile::Type
+ {
+    public:
+    virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string SourceDir) const
+    {
+       return new debDscRecordParser(SourceDir + string("/debian/control"), NULL);
+    };
+    debIFTypeDebianSourceDir() {Label = "debian/control File Source Index";};
+ };
  static debIFTypeSrc _apt_Src;
  static debIFTypePkg _apt_Pkg;
  static debIFTypeTrans _apt_Trans;
  static debIFTypeStatus _apt_Status;
 +static debIFTypeDebPkgFile _apt_DebPkgFile;
+ // file based pseudo indexes
+ static debIFTypeDscFile _apt_DscFile;
+ static debIFTypeDebianSourceDir _apt_DebianSourceDir;
  
  const pkgIndexFile::Type *debSourcesIndex::GetType() const
  {
@@@ -822,8 -778,13 +879,16 @@@ const pkgIndexFile::Type *debStatusInde
  {
     return &_apt_Status;
  }
 +const pkgIndexFile::Type *debDebPkgFileIndex::GetType() const
 +{
 +   return &_apt_DebPkgFile;
++}
+ const pkgIndexFile::Type *debDscFileIndex::GetType() const
+ {
+    return &_apt_DscFile;
+ }
+ const pkgIndexFile::Type *debDebianSourceDirIndex::GetType() const
+ {
+    return &_apt_DebianSourceDir;
  }
 -
                                                                        /*}}}*/
index 69754e79d469490a3fee43eca7dc35014ce98f03,64ca558d2d4589041c1d59b63e73621f23ecebb0..18322dc1b1b3902750f38017a63073afcc988c65
@@@ -164,35 -164,27 +164,57 @@@ class debSourcesIndex : public pkgIndex
     virtual ~debSourcesIndex() {};
  };
  
-    
 +class debDebPkgFileIndex : public pkgIndexFile
 +{
 + private:
 +   void *d;
 +   std::string DebFile;
 +   std::string DebFileFullPath;
 +
 + public:
 +   virtual const Type *GetType() const APT_CONST;
 +
 +   virtual std::string Describe(bool /*Short*/) const {
 +      return DebFile;
 +   }
 +
 +   // Interface for the Cache Generator
 +   virtual bool Exists() const;
 +   virtual bool HasPackages() const {
 +      return true;
 +   };
 +   virtual unsigned long Size() const;
 +   virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
 +   virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 +
 +   // Interface for acquire
 +   virtual std::string ArchiveURI(std::string /*File*/) const;
 +
 +   debDebPkgFileIndex(std::string DebFile);
 +   virtual ~debDebPkgFileIndex() {};
++};   
++
+ 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() {};
+ };
+ class debDebianSourceDirIndex : public debDscFileIndex
+ {
+    virtual const Type *GetType() const APT_CONST;
  };
  
  #endif
index 56eecdca11c201fa14efdac74557fdeead141619,6fd12add8f3589cf02fdb1fd84b596e70f7986b4..b4839ada4cfb6e2dfa37071546f6cbdbe22605b4
@@@ -516,25 -507,5 +516,25 @@@ class debSLTypeDebSrc : public debSLTyp
     }   
  };
  
-                  string const &Dist, string const &Section,
-                  std::map<string, string> const &Options) const
 +class debSLTypeDebFile : public pkgSourceList::Type
 +{
 +   public:
 +
 +   bool CreateItem(vector<metaIndex *> &List, string const &URI,
++                 string const &/*Dist*/, string const &/*Section*/,
++                 std::map<string, string> const &/*Options*/) const
 +   {
 +      metaIndex *mi = new debDebFileMetaIndex(URI);
 +      List.push_back(mi);
 +      return true;
 +   }
 +   
 +   debSLTypeDebFile()
 +   {
 +      Name = "deb-file";
 +      Label = "Debian Deb File";
 +   }   
 +};
  debSLTypeDeb _apt_DebType;
  debSLTypeDebSrc _apt_DebSrcType;
 +debSLTypeDebFile _apt_DebFileType;
index 615f0f57d4dbfe0c3c67b57011ec3be296f33966,8aad81e3cfd839d029f96efe0147d88e61e8e6d5..7b9a828d3fba5a5d6902748bf9b6400bfeee0c1d
@@@ -18,7 -18,7 +18,8 @@@
  #include <apt-pkg/aptconfiguration.h>
  #include <apt-pkg/srcrecords.h>
  #include <apt-pkg/tagfile.h>
 +#include <apt-pkg/hashes.h>
+ #include <apt-pkg/gpgv.h>
  
  #include <ctype.h>
  #include <stdlib.h>
Simple merge
Simple merge