diff options
Diffstat (limited to 'apt-pkg/edsp')
-rw-r--r-- | apt-pkg/edsp/edspindexfile.cc | 37 | ||||
-rw-r--r-- | apt-pkg/edsp/edspindexfile.h | 13 | ||||
-rw-r--r-- | apt-pkg/edsp/edsplistparser.cc | 54 | ||||
-rw-r--r-- | apt-pkg/edsp/edsplistparser.h | 10 | ||||
-rw-r--r-- | apt-pkg/edsp/edspsystem.cc | 18 | ||||
-rw-r--r-- | apt-pkg/edsp/edspsystem.h | 9 |
6 files changed, 140 insertions, 1 deletions
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc index e2863a2cc..042a88cf9 100644 --- a/apt-pkg/edsp/edspindexfile.cc +++ b/apt-pkg/edsp/edspindexfile.cc @@ -69,6 +69,25 @@ pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg) return newError ? NULL : Parser; } /*}}}*/ +// 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 NULL; + _error->PushToStack(); + pkgCacheListParser * const Parser = new eippListParser(&Pkg); + bool const newError = _error->PendingError(); + _error->MergeWithStack(); + return newError ? NULL : Parser; +} + /*}}}*/ // Index File types for APT /*{{{*/ class APT_HIDDEN edspIFType: public pkgIndexFile::Type @@ -82,12 +101,28 @@ class APT_HIDDEN edspIFType: public pkgIndexFile::Type 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() {} diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h index 26bd1232b..e146ca80c 100644 --- a/apt-pkg/edsp/edspindexfile.h +++ b/apt-pkg/edsp/edspindexfile.h @@ -46,4 +46,17 @@ public: virtual ~edspIndex(); }; +class APT_HIDDEN eippIndex : public edspLikeIndex +{ +protected: + APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE; + virtual std::string GetComponent() const APT_OVERRIDE; + +public: + virtual const Type *GetType() const APT_OVERRIDE APT_CONST; + + eippIndex(std::string const &File); + virtual ~eippIndex(); +}; + #endif diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index 39a6e8a6e..dd8890f0e 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -125,5 +125,59 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg, } /*}}}*/ +// ListParser::eippListParser - Constructor /*{{{*/ +eippListParser::eippListParser(FileFd *File) : edspLikeListParser(File) +{ +} + /*}}}*/ +// ListParser::ParseStatus - Parse the status field /*{{{*/ +// --------------------------------------------------------------------- +/* The Status: line here is not a normal dpkg one but just one which tells + use if the package is installed or not, where missing means not. */ +bool eippListParser::ParseStatus(pkgCache::PkgIterator &Pkg, + pkgCache::VerIterator &Ver) +{ + // Process the flag field + static std::array<WordList, 8> const statusvalues = {{ + {"not-installed",pkgCache::State::NotInstalled}, + {"config-files",pkgCache::State::ConfigFiles}, + {"half-installed",pkgCache::State::HalfInstalled}, + {"unpacked",pkgCache::State::UnPacked}, + {"half-configured",pkgCache::State::HalfConfigured}, + {"triggers-awaited",pkgCache::State::TriggersAwaited}, + {"triggers-pending",pkgCache::State::TriggersPending}, + {"installed",pkgCache::State::Installed}, + }}; + auto const status = Section.Find("Status"); + if (status.empty() == false) + { + for (auto && sv: statusvalues) + { + if (status != sv.Str) + continue; + Pkg->CurrentState = sv.Val; + switch (Pkg->CurrentState) + { + case pkgCache::State::NotInstalled: + case pkgCache::State::ConfigFiles: + break; + case pkgCache::State::HalfInstalled: + case pkgCache::State::UnPacked: + case pkgCache::State::HalfConfigured: + case pkgCache::State::TriggersAwaited: + case pkgCache::State::TriggersPending: + case pkgCache::State::Installed: + Pkg->CurrentVer = Ver.Index(); + break; + } + break; + } + } + + return true; +} + /*}}}*/ + edspLikeListParser::~edspLikeListParser() {} edspListParser::~edspListParser() {} +eippListParser::~eippListParser() {} diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h index 7cd5ab2b3..84138d6a8 100644 --- a/apt-pkg/edsp/edsplistparser.h +++ b/apt-pkg/edsp/edsplistparser.h @@ -51,4 +51,14 @@ public: edspListParser(FileFd *File); virtual ~edspListParser(); }; + +class APT_HIDDEN eippListParser : public edspLikeListParser +{ +protected: + virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE; + +public: + eippListParser(FileFd *File); + virtual ~eippListParser(); +}; #endif diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc index 2a78efe58..b0e7b8a21 100644 --- a/apt-pkg/edsp/edspsystem.cc +++ b/apt-pkg/edsp/edspsystem.cc @@ -35,6 +35,9 @@ edspLikeSystem::edspLikeSystem(char const * const Label) : pkgSystem(Label, &deb edspSystem::edspSystem() : edspLikeSystem("Debian APT solver interface") { } +eippSystem::eippSystem() : edspLikeSystem("Debian APT planer interface") +{ +} /*}}}*/ // System::Lock - Get the lock /*{{{*/ bool edspLikeSystem::Lock() @@ -134,6 +137,19 @@ bool edspSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List) /*{{{*/ return true; } /*}}}*/ +bool eippSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List) /*{{{*/ +{ + if (StatusFile == nullptr) + { + if (_config->Find("eipp::scenario", "") == "/nonexistent/stdin") + StatusFile.reset(new eippIndex("/nonexistent/stdin")); + else + StatusFile.reset(new eippIndex(_config->FindFile("eipp::scenario"))); + } + List.push_back(StatusFile.get()); + return true; +} + /*}}}*/ edspLikeSystem::~edspLikeSystem() {} edspSystem::~edspSystem() @@ -145,5 +161,7 @@ edspSystem::~edspSystem() RemoveFile("~edspSystem", tempPrefsFile); rmdir(tempDir.c_str()); } +eippSystem::~eippSystem() {} APT_HIDDEN edspSystem edspSys; +APT_HIDDEN eippSystem eippSys; diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h index 2c429c3d6..c0c9526b5 100644 --- a/apt-pkg/edsp/edspsystem.h +++ b/apt-pkg/edsp/edspsystem.h @@ -57,4 +57,13 @@ public: virtual ~edspSystem(); }; +class APT_HIDDEN eippSystem : public edspLikeSystem +{ + public: + virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) APT_OVERRIDE; + + eippSystem(); + virtual ~eippSystem(); +}; + #endif |