diff options
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r-- | apt-pkg/deb/debindexfile.cc | 416 | ||||
-rw-r--r-- | apt-pkg/deb/debindexfile.h | 84 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 7 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.h | 2 |
4 files changed, 147 insertions, 362 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index e67233e5f..627cd36c5 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -36,27 +36,20 @@ #include <iostream> #include <sstream> #include <string> +#include <memory> #include <sys/stat.h> /*}}}*/ -using std::string; - -// SourcesIndex::debSourcesIndex - Constructor /*{{{*/ -// --------------------------------------------------------------------- -/* */ +// Sources Index /*{{{*/ debSourcesIndex::debSourcesIndex(IndexTarget const &Target,bool const Trusted) : - pkgIndexTargetFile(Target, Trusted), d(NULL) + pkgDebianIndexTargetFile(Target, Trusted), d(NULL) { } - /*}}}*/ -// SourcesIndex::SourceInfo - Short 1 liner describing a source /*{{{*/ -// --------------------------------------------------------------------- -/* The result looks like: - http://foo/debian/ stable/main src 1.1.1 (dsc) */ -string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record, +std::string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record, pkgSrcRecords::File const &File) const { - string Res = Target.Description; + // The result looks like: http://foo/debian/ stable/main src 1.1.1 (dsc) + std::string Res = Target.Description; Res.erase(Target.Description.rfind(' ')); Res += " "; @@ -67,294 +60,111 @@ string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record, Res += " (" + File.Type + ")"; return Res; } - /*}}}*/ -// SourcesIndex::CreateSrcParser - Get a parser for the source files /*{{{*/ -// --------------------------------------------------------------------- -/* */ pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const { - string const SourcesURI = IndexFileName(); + std::string const SourcesURI = IndexFileName(); if (FileExists(SourcesURI)) return new debSrcRecordParser(SourcesURI, this); return NULL; } +bool debSourcesIndex::OpenListFile(FileFd &, std::string const &) +{ + return true; +} +pkgCacheListParser * debSourcesIndex::CreateListParser(FileFd &) +{ + return NULL; +} +uint8_t debSourcesIndex::GetIndexFlags() const +{ + return 0; +} /*}}}*/ - -// PackagesIndex::debPackagesIndex - Contructor /*{{{*/ -// --------------------------------------------------------------------- -/* */ +// Packages Index /*{{{*/ debPackagesIndex::debPackagesIndex(IndexTarget const &Target, bool const Trusted) : - pkgIndexTargetFile(Target, Trusted), d(NULL) + pkgDebianIndexTargetFile(Target, Trusted), d(NULL) { } - /*}}}*/ -// PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/ -// --------------------------------------------------------------------- -/* This is a shorter version that is designed to be < 60 chars or so */ -string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const +std::string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator const &Ver) const { - std::string const Dist = Target.Option(IndexTarget::RELEASE); - string Res = Target.Option(IndexTarget::SITE) + " " + Dist; - std::string const Component = Target.Option(IndexTarget::COMPONENT); - if (Component.empty() == false) - Res += "/" + Component; + std::string Res = Target.Description; + Res.erase(Target.Description.rfind(' ')); Res += " "; Res += Ver.ParentPkg().Name(); Res += " "; + std::string const Dist = Target.Option(IndexTarget::RELEASE); if (Dist.empty() == false && Dist[Dist.size() - 1] != '/') Res.append(Ver.Arch()).append(" "); Res += Ver.VerStr(); return Res; } - /*}}}*/ -// PackagesIndex::Merge - Load the index file into a cache /*{{{*/ -// --------------------------------------------------------------------- -/* */ -bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const -{ - string const PackageFile = IndexFileName(); - FileFd Pkg(PackageFile,FileFd::ReadOnly, FileFd::Extension); - debListParser Parser(&Pkg, Target.Option(IndexTarget::ARCHITECTURE)); - - if (_error->PendingError() == true) - return _error->Error("Problem opening %s",PackageFile.c_str()); - if (Prog != NULL) - Prog->SubProgress(0, Target.Description); - - - std::string const URI = Target.Option(IndexTarget::REPO_URI); - std::string Dist = Target.Option(IndexTarget::RELEASE); - if (Dist.empty()) - Dist = "/"; - ::URI Tmp(URI); - if (Gen.SelectFile(PackageFile, *this, Target.Option(IndexTarget::ARCHITECTURE), Target.Option(IndexTarget::COMPONENT)) == false) - return _error->Error("Problem with SelectFile %s",PackageFile.c_str()); - - // Store the IMS information - pkgCache::PkgFileIterator File = Gen.GetCurFile(); - pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(File); - File->Size = Pkg.FileSize(); - File->mtime = Pkg.ModificationTime(); - - if (Gen.MergeList(Parser) == false) - return _error->Error("Problem with MergeList %s",PackageFile.c_str()); - - return true; -} - /*}}}*/ -// PackagesIndex::FindInCache - Find this index /*{{{*/ -// --------------------------------------------------------------------- -/* */ -pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const +uint8_t debPackagesIndex::GetIndexFlags() const { - string const FileName = IndexFileName(); - pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; ++File) - { - if (File.FileName() == NULL || FileName != File.FileName()) - continue; - - struct stat St; - if (stat(File.FileName(),&St) != 0) - { - if (_config->FindB("Debug::pkgCacheGen", false)) - std::clog << "PackagesIndex::FindInCache - stat failed on " << File.FileName() << std::endl; - return pkgCache::PkgFileIterator(Cache); - } - if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime) - { - if (_config->FindB("Debug::pkgCacheGen", false)) - std::clog << "PackagesIndex::FindInCache - size (" << St.st_size << " <> " << File->Size - << ") or mtime (" << St.st_mtime << " <> " << File->mtime - << ") doesn't match for " << File.FileName() << std::endl; - return pkgCache::PkgFileIterator(Cache); - } - return File; - } - - return File; + return 0; } /*}}}*/ - -// TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/ +// Translation-* Index /*{{{*/ debTranslationsIndex::debTranslationsIndex(IndexTarget const &Target) : - pkgIndexTargetFile(Target, true), d(NULL) + pkgDebianIndexTargetFile(Target, true), d(NULL) {} - /*}}}*/ -bool debTranslationsIndex::HasPackages() const /*{{{*/ +bool debTranslationsIndex::HasPackages() const { return Exists(); } - /*}}}*/ -// TranslationsIndex::Merge - Load the index file into a cache /*{{{*/ -// --------------------------------------------------------------------- -/* */ -bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const -{ - // Check the translation file, if in use - string const TranslationFile = IndexFileName(); - if (FileExists(TranslationFile)) - { - FileFd Trans(TranslationFile,FileFd::ReadOnly, FileFd::Extension); - debTranslationsParser TransParser(&Trans); - if (_error->PendingError() == true) - return false; - - if (Prog != NULL) - Prog->SubProgress(0, Target.Description); - if (Gen.SelectFile(TranslationFile, *this, "", Target.Option(IndexTarget::COMPONENT), pkgCache::Flag::NotSource | pkgCache::Flag::NoPackages) == false) - return _error->Error("Problem with SelectFile %s",TranslationFile.c_str()); - - // Store the IMS information - pkgCache::PkgFileIterator TransFile = Gen.GetCurFile(); - TransFile->Size = Trans.FileSize(); - TransFile->mtime = Trans.ModificationTime(); - - if (Gen.MergeList(TransParser) == false) - return _error->Error("Problem with MergeList %s",TranslationFile.c_str()); - } - +bool debTranslationsIndex::OpenListFile(FileFd &Pkg, std::string const &FileName) +{ + if (FileExists(FileName)) + return pkgDebianIndexTargetFile::OpenListFile(Pkg, FileName); return true; } - /*}}}*/ -// TranslationsIndex::FindInCache - Find this index /*{{{*/ -// --------------------------------------------------------------------- -/* */ -pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const +uint8_t debTranslationsIndex::GetIndexFlags() const { - string FileName = IndexFileName(); - - pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; ++File) - { - if (FileName != File.FileName()) - continue; - - struct stat St; - if (stat(File.FileName(),&St) != 0) - { - if (_config->FindB("Debug::pkgCacheGen", false)) - std::clog << "TranslationIndex::FindInCache - stat failed on " << File.FileName() << std::endl; - return pkgCache::PkgFileIterator(Cache); - } - if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime) - { - if (_config->FindB("Debug::pkgCacheGen", false)) - std::clog << "TranslationIndex::FindInCache - size (" << St.st_size << " <> " << File->Size - << ") or mtime (" << St.st_mtime << " <> " << File->mtime - << ") doesn't match for " << File.FileName() << std::endl; - return pkgCache::PkgFileIterator(Cache); - } - return File; - } - return File; + return pkgCache::Flag::NotSource | pkgCache::Flag::NoPackages; } - /*}}}*/ - -// StatusIndex::debStatusIndex - Constructor /*{{{*/ -// --------------------------------------------------------------------- -/* */ -debStatusIndex::debStatusIndex(string File) : pkgIndexFile(true), d(NULL), File(File) +std::string debTranslationsIndex::GetArchitecture() const { + return std::string(); } - /*}}}*/ -// StatusIndex::Size - Return the size of the index /*{{{*/ -// --------------------------------------------------------------------- -/* */ -unsigned long debStatusIndex::Size() const +pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg) { - struct stat S; - if (stat(File.c_str(),&S) != 0) - return 0; - return S.st_size; -} - /*}}}*/ -// StatusIndex::Merge - Load the index file into a cache /*{{{*/ -// --------------------------------------------------------------------- -/* */ -bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const -{ - FileFd Pkg(File,FileFd::ReadOnly, FileFd::Extension); - if (_error->PendingError() == true) - return false; - debListParser Parser(&Pkg); - if (_error->PendingError() == true) - return false; - - if (Prog != NULL) - Prog->SubProgress(0,File); - if (Gen.SelectFile(File, *this, "", "now", pkgCache::Flag::NotSource) == false) - return _error->Error("Problem with SelectFile %s",File.c_str()); - - // Store the IMS information - pkgCache::PkgFileIterator CFile = Gen.GetCurFile(); - pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(CFile); - CFile->Size = Pkg.FileSize(); - CFile->mtime = Pkg.ModificationTime(); - - if (Gen.MergeList(Parser) == false) - return _error->Error("Problem with MergeList %s",File.c_str()); - return true; + if (Pkg.IsOpen() == false) + return NULL; + _error->PushToStack(); + pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg); + bool const newError = _error->PendingError(); + _error->MergeWithStack(); + return newError ? NULL : Parser; } /*}}}*/ -// StatusIndex::FindInCache - Find this index /*{{{*/ -// --------------------------------------------------------------------- -/* */ -pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const +// dpkg/status Index /*{{{*/ +debStatusIndex::debStatusIndex(std::string const &File) : pkgDebianIndexRealFile(File, true), d(NULL) { - pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; ++File) - { - if (this->File != File.FileName()) - continue; - - struct stat St; - if (stat(File.FileName(),&St) != 0) - { - if (_config->FindB("Debug::pkgCacheGen", false)) - std::clog << "StatusIndex::FindInCache - stat failed on " << File.FileName() << std::endl; - return pkgCache::PkgFileIterator(Cache); - } - if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime) - { - if (_config->FindB("Debug::pkgCacheGen", false)) - std::clog << "StatusIndex::FindInCache - size (" << St.st_size << " <> " << File->Size - << ") or mtime (" << St.st_mtime << " <> " << File->mtime - << ") doesn't match for " << File.FileName() << std::endl; - return pkgCache::PkgFileIterator(Cache); - } - return File; - } - return File; } - /*}}}*/ -// StatusIndex::Exists - Check if the index is available /*{{{*/ -// --------------------------------------------------------------------- -/* */ -APT_CONST bool debStatusIndex::Exists() const +std::string debStatusIndex::GetArchitecture() const { - // Abort if the file does not exist. - return true; + return std::string(); } - /*}}}*/ - -// debDebPkgFileIndex - Single .deb file /*{{{*/ -debDebPkgFileIndex::debDebPkgFileIndex(std::string const &DebFile) - : pkgIndexFile(true), d(NULL), DebFile(DebFile) +std::string debStatusIndex::GetComponent() const { - DebFileFullPath = flAbsPath(DebFile); + return "now"; } -std::string debDebPkgFileIndex::ArchiveURI(std::string /*File*/) const +uint8_t debStatusIndex::GetIndexFlags() const { - return "file:" + DebFileFullPath; + return pkgCache::Flag::NotSource; } -bool debDebPkgFileIndex::Exists() const + /*}}}*/ +// DebPkgFile Index - a single .deb file as an index /*{{{*/ +debDebPkgFileIndex::debDebPkgFileIndex(std::string const &DebFile) + : pkgDebianIndexRealFile(DebFile, true), d(NULL), DebFile(DebFile) { - return FileExists(DebFile); } bool debDebPkgFileIndex::GetContent(std::ostream &content, std::string const &debfile) { + struct stat Buf; + if (stat(debfile.c_str(), &Buf) != 0) + return false; + // get the control data out of the deb file via dpkg-deb -I std::string dpkg = _config->Find("Dir::Bin::dpkg","dpkg-deb"); std::vector<const char *> Args; @@ -381,91 +191,73 @@ bool debDebPkgFileIndex::GetContent(std::ostream &content, std::string const &de ExecWait(Child, "Popen"); content << "Filename: " << debfile << "\n"; - struct stat Buf; - if (stat(debfile.c_str(), &Buf) != 0) - return false; content << "Size: " << Buf.st_size << "\n"; return true; } -bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const +bool debDebPkgFileIndex::OpenListFile(FileFd &Pkg, std::string const &FileName) { - if(Prog) - Prog->SubProgress(0, "Reading deb file"); - // write the control data to a tempfile - SPtr<FileFd> DebControl = GetTempFile("deb-file-" + flNotDir(DebFile)); - if(DebControl == NULL) + if (GetTempFile("deb-file-" + flNotDir(FileName), true, &Pkg) == NULL) return false; std::ostringstream content; - if (GetContent(content, DebFile) == false) + if (GetContent(content, FileName) == false) return false; std::string const contentstr = content.str(); if (contentstr.empty()) return true; - DebControl->Write(contentstr.c_str(), contentstr.length()); - // rewind for the listparser - DebControl->Seek(0); - - // and give it to the list parser - debDebFileParser Parser(DebControl, DebFile); - if(Gen.SelectFile(DebFile, *this, "", "now", pkgCache::Flag::LocalSource) == 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()); - + if (Pkg.Write(contentstr.c_str(), contentstr.length()) == false || Pkg.Seek(0) == false) + return false; return true; } +pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg) +{ + if (Pkg.IsOpen() == false) + return NULL; + _error->PushToStack(); + pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile); + bool const newError = _error->PendingError(); + _error->MergeWithStack(); + return newError ? NULL : Parser; +} +uint8_t debDebPkgFileIndex::GetIndexFlags() const +{ + return pkgCache::Flag::LocalSource; +} +std::string debDebPkgFileIndex::GetArchitecture() const +{ + return std::string(); +} +std::string debDebPkgFileIndex::GetComponent() const +{ + return "local-deb"; +} pkgCache::PkgFileIterator debDebPkgFileIndex::FindInCache(pkgCache &Cache) const { + std::string const FileName = IndexFileName(); pkgCache::PkgFileIterator File = Cache.FileBegin(); for (; File.end() == false; ++File) { - if (File.FileName() == NULL || DebFile != File.FileName()) + if (File.FileName() == NULL || FileName != File.FileName()) continue; - - return File; + // we can't do size checks here as file size != content size + 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 - a .dsc file /*{{{*/ + /*}}}*/ +// DscFile Index - a single .dsc file as an index /*{{{*/ debDscFileIndex::debDscFileIndex(std::string const &DscFile) - : pkgIndexFile(true), d(NULL), DscFile(DscFile) + : pkgDebianIndexRealFile(DscFile, true), d(NULL) { } -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; -} pkgSrcRecords::Parser *debDscFileIndex::CreateSrcParser() const { - if (!FileExists(DscFile)) + if (Exists() == false) return NULL; - - return new debDscRecordParser(DscFile,this); + return new debDscRecordParser(File, this); } /*}}}*/ @@ -478,7 +270,7 @@ class APT_HIDDEN debIFTypeSrc : public pkgIndexFile::Type class APT_HIDDEN debIFTypePkg : public pkgIndexFile::Type { public: - virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const APT_OVERRIDE + virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &File) const APT_OVERRIDE { return new debRecordParser(File.FileName(),*File.Cache()); }; @@ -492,7 +284,7 @@ class APT_HIDDEN debIFTypeTrans : public debIFTypePkg class APT_HIDDEN debIFTypeStatus : public pkgIndexFile::Type { public: - virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const APT_OVERRIDE + virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &File) const APT_OVERRIDE { return new debRecordParser(File.FileName(),*File.Cache()); }; @@ -501,7 +293,7 @@ class APT_HIDDEN debIFTypeStatus : public pkgIndexFile::Type class APT_HIDDEN debIFTypeDebPkgFile : public pkgIndexFile::Type { public: - virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const APT_OVERRIDE + virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &File) const APT_OVERRIDE { return new debDebFileRecordParser(File.FileName()); }; @@ -510,7 +302,7 @@ class APT_HIDDEN debIFTypeDebPkgFile : public pkgIndexFile::Type class APT_HIDDEN debIFTypeDscFile : public pkgIndexFile::Type { public: - virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string DscFile) const APT_OVERRIDE + virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string const &DscFile) const APT_OVERRIDE { return new debDscRecordParser(DscFile, NULL); }; @@ -519,9 +311,9 @@ class APT_HIDDEN debIFTypeDscFile : public pkgIndexFile::Type class APT_HIDDEN debIFTypeDebianSourceDir : public pkgIndexFile::Type { public: - virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string SourceDir) const APT_OVERRIDE + virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string const &SourceDir) const APT_OVERRIDE { - return new debDscRecordParser(SourceDir + string("/debian/control"), NULL); + return new debDscRecordParser(SourceDir + std::string("/debian/control"), NULL); }; debIFTypeDebianSourceDir() {Label = "Debian control file";}; }; diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h index 4a818121a..02708b558 100644 --- a/apt-pkg/deb/debindexfile.h +++ b/apt-pkg/deb/debindexfile.h @@ -26,69 +26,73 @@ class OpProgress; class pkgAcquire; class pkgCacheGenerator; - -class debStatusIndex : public pkgIndexFile +class debStatusIndex : public pkgDebianIndexRealFile { void * const d; - protected: - std::string File; +protected: + virtual std::string GetArchitecture() const APT_OVERRIDE; + virtual std::string GetComponent() const APT_OVERRIDE; + virtual uint8_t GetIndexFlags() const APT_OVERRIDE; - public: +public: virtual const Type *GetType() const APT_CONST; - // Interface for acquire - virtual std::string Describe(bool /*Short*/) const APT_OVERRIDE {return File;}; - // Interface for the Cache Generator - virtual bool Exists() const APT_OVERRIDE; virtual bool HasPackages() const APT_OVERRIDE {return true;}; - virtual unsigned long Size() const APT_OVERRIDE; - virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE; - virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE; + // Abort if the file does not exist. + virtual bool Exists() const APT_OVERRIDE {return true;}; - debStatusIndex(std::string File); + debStatusIndex(std::string const &File); virtual ~debStatusIndex(); }; -class debPackagesIndex : public pkgIndexTargetFile +class debPackagesIndex : public pkgDebianIndexTargetFile { void * const d; - public: +protected: + virtual uint8_t GetIndexFlags() const; +public: virtual const Type *GetType() const APT_CONST; // Stuff for accessing files on remote items - virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const APT_OVERRIDE; + virtual std::string ArchiveInfo(pkgCache::VerIterator const &Ver) const APT_OVERRIDE; // Interface for the Cache Generator virtual bool HasPackages() const APT_OVERRIDE {return true;}; - virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE; - virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE; debPackagesIndex(IndexTarget const &Target, bool const Trusted); virtual ~debPackagesIndex(); }; -class debTranslationsIndex : public pkgIndexTargetFile +class debTranslationsIndex : public pkgDebianIndexTargetFile { void * const d; - public: +protected: + virtual std::string GetArchitecture() const APT_OVERRIDE; + virtual uint8_t GetIndexFlags() const APT_OVERRIDE; + virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE; + APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE; + +public: virtual const Type *GetType() const APT_CONST; // Interface for the Cache Generator virtual bool HasPackages() const APT_OVERRIDE; - virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE; - virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE; debTranslationsIndex(IndexTarget const &Target); virtual ~debTranslationsIndex(); }; -class debSourcesIndex : public pkgIndexTargetFile +class debSourcesIndex : public pkgDebianIndexTargetFile { void * const d; + virtual uint8_t GetIndexFlags() const; + virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE; + APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE; + public: virtual const Type *GetType() const APT_CONST; @@ -107,19 +111,20 @@ class debSourcesIndex : public pkgIndexTargetFile virtual ~debSourcesIndex(); }; -class debDebPkgFileIndex : public pkgIndexFile +class debDebPkgFileIndex : public pkgDebianIndexRealFile { - private: void * const d; std::string DebFile; - std::string DebFileFullPath; - public: - virtual const Type *GetType() const APT_CONST; +protected: + virtual std::string GetComponent() const APT_OVERRIDE; + virtual std::string GetArchitecture() const APT_OVERRIDE; + virtual uint8_t GetIndexFlags() const APT_OVERRIDE; + virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE; + APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE; - virtual std::string Describe(bool /*Short*/) const APT_OVERRIDE { - return DebFile; - } +public: + virtual const Type *GetType() const APT_CONST; /** get the control (file) content of the deb file * @@ -130,35 +135,22 @@ class debDebPkgFileIndex : public pkgIndexFile static bool GetContent(std::ostream &content, std::string const &debfile); // Interface for the Cache Generator - virtual bool Exists() const APT_OVERRIDE; - virtual bool HasPackages() const APT_OVERRIDE { - return true; - }; - virtual unsigned long Size() const APT_OVERRIDE; - virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE; + virtual bool HasPackages() const APT_OVERRIDE {return true;} virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE; // Interface for acquire - virtual std::string ArchiveURI(std::string /*File*/) const APT_OVERRIDE; debDebPkgFileIndex(std::string const &DebFile); virtual ~debDebPkgFileIndex(); }; -class debDscFileIndex : public pkgIndexFile +class debDscFileIndex : public pkgDebianIndexRealFile { - private: void * const d; - std::string DscFile; public: virtual const Type *GetType() const APT_CONST; virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE; - virtual bool Exists() const APT_OVERRIDE; virtual bool HasPackages() const APT_OVERRIDE {return false;}; - virtual unsigned long Size() const APT_OVERRIDE; - virtual std::string Describe(bool /*Short*/) const APT_OVERRIDE { - return DscFile; - }; debDscFileIndex(std::string const &DscFile); virtual ~debDscFileIndex(); diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b7988d499..cb2b15668 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -50,8 +50,9 @@ static debListParser::WordList PrioList[] = { /* Provide an architecture and only this one and "all" will be accepted in Step(), if no Architecture is given we will accept every arch we would accept in general with checkArchitecture() */ -debListParser::debListParser(FileFd *File, string const &Arch) : d(NULL), Tags(File), - Arch(Arch) { +debListParser::debListParser(FileFd *File, string const &Arch) : + pkgCacheListParser(), d(NULL), Tags(File), Arch(Arch) +{ if (Arch == "native") this->Arch = _config->Find("APT::Architecture"); Architectures = APT::Configuration::getArchitectures(); @@ -931,7 +932,7 @@ unsigned char debListParser::GetPrio(string Str) bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/ pkgCache::VerIterator const &Ver) { - if (pkgCacheGenerator::ListParser::SameVersion(Hash, Ver) == false) + if (pkgCacheListParser::SameVersion(Hash, Ver) == false) return false; // status file has no (Download)Size, but all others are fair game // status file is parsed last, so the first version we encounter is diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 30e52718d..975620070 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -26,7 +26,7 @@ class FileFd; -class APT_HIDDEN debListParser : public pkgCacheGenerator::ListParser +class APT_HIDDEN debListParser : public pkgCacheListParser { public: |