summaryrefslogtreecommitdiffstats
path: root/apt-pkg/edsp/edspindexfile.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:07:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:07:13 +0000
commit636c7dc17286d93d788c741d15fd756aeda066d5 (patch)
treee7ae158cc54f591041a061b9865bcae51854f15c /apt-pkg/edsp/edspindexfile.cc
parentInitial commit. (diff)
downloadapt-upstream/1.8.2.3.tar.xz
apt-upstream/1.8.2.3.zip
Adding upstream version 1.8.2.3.upstream/1.8.2.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--apt-pkg/edsp/edspindexfile.cc129
1 files changed, 129 insertions, 0 deletions
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc
new file mode 100644
index 0000000..1a8af89
--- /dev/null
+++ b/apt-pkg/edsp/edspindexfile.cc
@@ -0,0 +1,129 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+ The scenario file is designed to work as an intermediate file between
+ APT and the resolver. Its on propose very similar to a dpkg status file
+ ##################################################################### */
+ /*}}}*/
+// Include Files /*{{{*/
+#include <config.h>
+
+#include <apt-pkg/edspindexfile.h>
+#include <apt-pkg/edsplistparser.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/pkgrecords.h>
+
+#include <memory>
+#include <string>
+#include <stddef.h>
+#include <unistd.h>
+ /*}}}*/
+
+// EDSP-like Index /*{{{*/
+edspLikeIndex::edspLikeIndex(std::string const &File) : pkgDebianIndexRealFile(File, true)
+{
+}
+std::string edspLikeIndex::GetArchitecture() const
+{
+ return std::string();
+}
+bool edspLikeIndex::HasPackages() const
+{
+ return true;
+}
+bool edspLikeIndex::Exists() const
+{
+ return true;
+}
+uint8_t edspLikeIndex::GetIndexFlags() const
+{
+ return 0;
+}
+bool edspLikeIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
+{
+ if (FileName.empty() == false && FileName != "/nonexistent/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;
+}
+ /*}}}*/
+// EDSP Index /*{{{*/
+edspIndex::edspIndex(std::string const &File) : edspLikeIndex(File)
+{
+}
+std::string edspIndex::GetComponent() const
+{
+ return "edsp";
+}
+pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg)
+{
+ if (Pkg.IsOpen() == false)
+ return nullptr;
+ _error->PushToStack();
+ std::unique_ptr<pkgCacheListParser> Parser(new edspListParser(&Pkg));
+ bool const newError = _error->PendingError();
+ _error->MergeWithStack();
+ return newError ? nullptr : Parser.release();
+}
+ /*}}}*/
+// EIPP Index /*{{{*/
+eippIndex::eippIndex(std::string const &File) : edspLikeIndex(File)
+{
+}
+std::string eippIndex::GetComponent() const
+{
+ return "eipp";
+}
+pkgCacheListParser * eippIndex::CreateListParser(FileFd &Pkg)
+{
+ if (Pkg.IsOpen() == false)
+ return nullptr;
+ _error->PushToStack();
+ std::unique_ptr<pkgCacheListParser> Parser(new eippListParser(&Pkg));
+ bool const newError = _error->PendingError();
+ _error->MergeWithStack();
+ return newError ? nullptr : Parser.release();
+}
+ /*}}}*/
+
+// Index File types for APT /*{{{*/
+class APT_HIDDEN edspIFType: public pkgIndexFile::Type
+{
+ public:
+ 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_Edsp;
+const pkgIndexFile::Type *edspIndex::GetType() const
+{
+ return &_apt_Edsp;
+}
+
+class APT_HIDDEN eippIFType: public pkgIndexFile::Type
+{
+ public:
+ 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;
+ };
+ eippIFType() {Label = "EIPP scenario file";};
+};
+APT_HIDDEN eippIFType _apt_Eipp;
+const pkgIndexFile::Type *eippIndex::GetType() const
+{
+ return &_apt_Eipp;
+}
+ /*}}}*/
+
+edspLikeIndex::~edspLikeIndex() {}
+edspIndex::~edspIndex() {}
+eippIndex::~eippIndex() {}