summaryrefslogtreecommitdiff
path: root/apt-pkg/edsp
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2015-08-18 11:57:35 +0200
committerMichael Vogt <mvo@debian.org>2015-08-18 11:57:35 +0200
commitb53c9cea2902572822bbbece5bac236c1bbf846e (patch)
tree6c6b0524e0971c0623ccbff71383523ee0b2a5cc /apt-pkg/edsp
parent21248c0f00ee71412dbadc6ebf84011cf974346d (diff)
parent2a22cd60f04c4291ea9b9b72e15b6d2ec378b001 (diff)
Merge remote-tracking branch 'upstream/debian/experimental' into feature/srv-records
Diffstat (limited to 'apt-pkg/edsp')
-rw-r--r--apt-pkg/edsp/edspindexfile.cc83
-rw-r--r--apt-pkg/edsp/edspindexfile.h27
-rw-r--r--apt-pkg/edsp/edsplistparser.cc9
-rw-r--r--apt-pkg/edsp/edsplistparser.h16
-rw-r--r--apt-pkg/edsp/edspsystem.cc21
-rw-r--r--apt-pkg/edsp/edspsystem.h22
6 files changed, 91 insertions, 87 deletions
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc
index d00536362..409117c5e 100644
--- a/apt-pkg/edsp/edspindexfile.cc
+++ b/apt-pkg/edsp/edspindexfile.cc
@@ -12,13 +12,8 @@
#include <apt-pkg/edsplistparser.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/debindexfile.h>
#include <apt-pkg/indexfile.h>
-#include <apt-pkg/mmap.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
-#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/pkgrecords.h>
#include <stddef.h>
@@ -26,59 +21,67 @@
#include <string>
/*}}}*/
-// edspIndex::edspIndex - Constructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-edspIndex::edspIndex(std::string File) : debStatusIndex(File)
+// EDSP Index /*{{{*/
+edspIndex::edspIndex(std::string const &File) : pkgDebianIndexRealFile(File, true), d(NULL)
{
}
- /*}}}*/
-// StatusIndex::Merge - Load the index file into a cache /*{{{*/
-bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
+std::string edspIndex::GetComponent() const
+{
+ return "edsp";
+}
+std::string edspIndex::GetArchitecture() const
+{
+ return std::string();
+}
+bool edspIndex::HasPackages() const
+{
+ return true;
+}
+bool edspIndex::Exists() const
{
- FileFd Pkg;
- if (File != "stdin")
- Pkg.Open(File, FileFd::ReadOnly);
- else
- Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly);
- if (_error->PendingError() == true)
- return false;
- edspListParser Parser(&Pkg);
- if (_error->PendingError() == true)
- return false;
-
- if (Prog != NULL)
- Prog->SubProgress(0,File);
- if (Gen.SelectFile(File,std::string(),*this) == false)
- return _error->Error("Problem with SelectFile %s",File.c_str());
-
- // Store the IMS information
- pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
- CFile->Size = Pkg.FileSize();
- CFile->mtime = Pkg.ModificationTime();
- map_stringitem_t const storage = Gen.StoreString(pkgCacheGenerator::MIXED, "edsp::scenario");
- CFile->Archive = storage;
-
- if (Gen.MergeList(Parser) == false)
- return _error->Error("Problem with MergeList %s",File.c_str());
return true;
}
+uint8_t edspIndex::GetIndexFlags() const
+{
+ return 0;
+}
+bool edspIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
+{
+ if (FileName.empty() == false && FileName != "stdin")
+ return pkgDebianIndexRealFile::OpenListFile(Pkg, FileName);
+ if (Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false)
+ return _error->Error("Problem opening %s",FileName.c_str());
+ return true;
+}
+pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg)
+{
+ if (Pkg.IsOpen() == false)
+ return NULL;
+ _error->PushToStack();
+ pkgCacheListParser * const Parser = new edspListParser(&Pkg);
+ bool const newError = _error->PendingError();
+ _error->MergeWithStack();
+ return newError ? NULL : Parser;
+}
/*}}}*/
+
// Index File types for APT /*{{{*/
class APT_HIDDEN edspIFType: public pkgIndexFile::Type
{
public:
- virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator) const
+ virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE
{
// we don't have a record parser for this type as the file is not presistent
return NULL;
};
edspIFType() {Label = "EDSP scenario file";};
};
-APT_HIDDEN edspIFType _apt_Universe;
+APT_HIDDEN edspIFType _apt_Edsp;
const pkgIndexFile::Type *edspIndex::GetType() const
{
- return &_apt_Universe;
+ return &_apt_Edsp;
}
/*}}}*/
+
+edspIndex::~edspIndex() {}
diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h
index 8c18d8cbd..4548bff3c 100644
--- a/apt-pkg/edsp/edspindexfile.h
+++ b/apt-pkg/edsp/edspindexfile.h
@@ -18,18 +18,25 @@
class OpProgress;
class pkgCacheGenerator;
-class APT_HIDDEN edspIndex : public debStatusIndex
+class APT_HIDDEN edspIndex : public pkgDebianIndexRealFile
{
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
-
- public:
-
- virtual const Type *GetType() const APT_CONST;
-
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
-
- edspIndex(std::string File);
+ void * const d;
+
+protected:
+ APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
+ virtual bool OpenListFile(FileFd &Pkg, std::string const &File) APT_OVERRIDE;
+ virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
+ virtual std::string GetComponent() const APT_OVERRIDE;
+ virtual std::string GetArchitecture() const APT_OVERRIDE;
+public:
+
+ virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
+ virtual bool Exists() const APT_OVERRIDE;
+ virtual bool HasPackages() const APT_OVERRIDE;
+
+ edspIndex(std::string const &File);
+ virtual ~edspIndex();
};
#endif
diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc
index 212dc7840..ff79b537e 100644
--- a/apt-pkg/edsp/edsplistparser.cc
+++ b/apt-pkg/edsp/edsplistparser.cc
@@ -18,11 +18,10 @@
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/tagfile.h>
-#include <string>
/*}}}*/
// ListParser::edspListParser - Constructor /*{{{*/
-edspListParser::edspListParser(FileFd *File, std::string const &Arch) : debListParser(File, Arch)
+edspListParser::edspListParser(FileFd *File) : debListParser(File), d(NULL)
{}
/*}}}*/
// ListParser::NewVersion - Fill in the version structure /*{{{*/
@@ -86,9 +85,11 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
}
/*}}}*/
// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
-APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/,
- FileFd & /*File*/, std::string /*component*/)
+APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*FileI*/,
+ FileFd & /*File*/, std::string const &/*component*/)
{
return true;
}
/*}}}*/
+
+edspListParser::~edspListParser() {}
diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h
index 86cd77606..221229302 100644
--- a/apt-pkg/edsp/edsplistparser.h
+++ b/apt-pkg/edsp/edsplistparser.h
@@ -27,20 +27,22 @@ class FileFd;
class APT_HIDDEN edspListParser : public debListParser
{
+ void * const d;
public:
- virtual bool NewVersion(pkgCache::VerIterator &Ver);
+ virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
virtual std::string Description();
virtual std::string DescriptionLanguage();
- virtual MD5SumValue Description_md5();
- virtual unsigned short VersionHash();
+ virtual MD5SumValue Description_md5() APT_OVERRIDE;
+ virtual unsigned short VersionHash() APT_OVERRIDE;
- bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
- std::string section);
+ bool LoadReleaseInfo(pkgCache::RlsFileIterator &FileI,FileFd &File,
+ std::string const &section);
- edspListParser(FileFd *File, std::string const &Arch = "");
+ edspListParser(FileFd *File);
+ virtual ~edspListParser();
protected:
- virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
+ virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE;
};
diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc
index 063517421..f577efcbd 100644
--- a/apt-pkg/edsp/edspsystem.cc
+++ b/apt-pkg/edsp/edspsystem.cc
@@ -15,7 +15,6 @@
#include <apt-pkg/debversion.h>
#include <apt-pkg/edspindexfile.h>
#include <apt-pkg/edspsystem.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheiterators.h>
@@ -23,16 +22,11 @@
#include <string>
#include <vector>
-#include <apti18n.h>
/*}}}*/
-// System::debSystem - Constructor /*{{{*/
-edspSystem::edspSystem()
+// System::edspSystem - Constructor /*{{{*/
+edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS), d(NULL), StatusFile(NULL)
{
- StatusFile = 0;
-
- Label = "Debian APT solver interface";
- VS = &debVS;
}
/*}}}*/
// System::~debSystem - Destructor /*{{{*/
@@ -85,18 +79,13 @@ bool edspSystem::ArchiveSupported(const char * /*Type*/)
return false;
}
/*}}}*/
-// System::Score - Determine if we should use the edsp system /*{{{*/
-signed edspSystem::Score(Configuration const &Cnf)
+// System::Score - Never use the EDSP system automatically /*{{{*/
+signed edspSystem::Score(Configuration const &)
{
- if (Cnf.Find("edsp::scenario", "") == "stdin")
- return 1000;
- if (RealFileExists(Cnf.FindFile("edsp::scenario","")) == true)
- return 1000;
return -1000;
}
/*}}}*/
-// System::AddStatusFiles - Register the status files /*{{{*/
-bool edspSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List)
+bool edspSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List) /*{{{*/
{
if (StatusFile == 0)
{
diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h
index 06a63f40c..ec42bef75 100644
--- a/apt-pkg/edsp/edspsystem.h
+++ b/apt-pkg/edsp/edspsystem.h
@@ -16,6 +16,8 @@
#include <vector>
+#include <apt-pkg/macros.h>
+
class Configuration;
class pkgDepCache;
class pkgIndexFile;
@@ -25,24 +27,24 @@ class edspIndex;
class APT_HIDDEN edspSystem : public pkgSystem
{
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
edspIndex *StatusFile;
public:
- virtual bool Lock() APT_CONST;
- virtual bool UnLock(bool NoErrors = false) APT_CONST;
- virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const APT_CONST;
- virtual bool Initialize(Configuration &Cnf);
- virtual bool ArchiveSupported(const char *Type) APT_CONST;
- virtual signed Score(Configuration const &Cnf);
- virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List);
+ virtual bool Lock() APT_OVERRIDE APT_CONST;
+ virtual bool UnLock(bool NoErrors = false) APT_OVERRIDE APT_CONST;
+ virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const APT_OVERRIDE APT_CONST;
+ virtual bool Initialize(Configuration &Cnf) APT_OVERRIDE;
+ virtual bool ArchiveSupported(const char *Type) APT_OVERRIDE APT_CONST;
+ virtual signed Score(Configuration const &Cnf) APT_OVERRIDE;
+ virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) APT_OVERRIDE;
virtual bool FindIndex(pkgCache::PkgFileIterator File,
- pkgIndexFile *&Found) const;
+ pkgIndexFile *&Found) const APT_OVERRIDE;
edspSystem();
- ~edspSystem();
+ virtual ~edspSystem();
};
#endif