#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/string_view.h>
- /*}}}*/
-
-class edspListParserPrivate /*{{{*/
-{
-public:
- FileFd extendedstates;
- FileFd preferences;
+#include <array>
- edspListParserPrivate()
- {
- std::string const states = _config->FindFile("Dir::State::extended_states");
- RemoveFile("edspListParserPrivate", states);
- extendedstates.Open(states, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
- std::string const prefs = _config->FindFile("Dir::Etc::preferences");
- RemoveFile("edspListParserPrivate", prefs);
- preferences.Open(prefs, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
- }
-};
/*}}}*/
+
// ListParser::edspListParser - Constructor /*{{{*/
-edspListParser::edspListParser(FileFd *File) : debListParser(File), d(new edspListParserPrivate())
+edspLikeListParser::edspLikeListParser(FileFd * const File) : debListParser(File)
+{
+}
+edspListParser::edspListParser(FileFd * const File) : edspLikeListParser(File)
{
+ std::string const states = _config->FindFile("Dir::State::extended_states");
+ RemoveFile("edspListParserPrivate", states);
+ extendedstates.Open(states, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
+ std::string const prefs = _config->FindFile("Dir::Etc::preferences");
+ RemoveFile("edspListParserPrivate", prefs);
+ preferences.Open(prefs, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
}
/*}}}*/
// ListParser::NewVersion - Fill in the version structure /*{{{*/
-bool edspListParser::NewVersion(pkgCache::VerIterator &Ver)
+bool edspLikeListParser::NewVersion(pkgCache::VerIterator &Ver)
{
- Ver->ID = Section.FindI("APT-ID", Ver->ID);
+ _system->SetVersionMapping(Ver->ID, Section.FindI("APT-ID", Ver->ID));
return debListParser::NewVersion(Ver);
}
/*}}}*/
// ListParser::Description - Return the description string /*{{{*/
// ---------------------------------------------------------------------
/* Sorry, no description for the resolvers… */
-std::string edspListParser::Description()
+std::vector<std::string> edspLikeListParser::AvailableDescriptionLanguages()
{
- return "";
+ return {};
}
-std::string edspListParser::DescriptionLanguage()
+APT::StringView edspLikeListParser::Description_md5()
{
- return "";
-}
-MD5SumValue edspListParser::Description_md5()
-{
- return MD5SumValue("");
+ return APT::StringView();
}
/*}}}*/
// ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-unsigned short edspListParser::VersionHash()
+unsigned short edspLikeListParser::VersionHash()
{
if (Section.Exists("APT-Hash") == true)
return Section.FindI("APT-Hash");
return 0;
}
/*}}}*/
+// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
+APT_CONST bool edspLikeListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*FileI*/,
+ FileFd & /*File*/, std::string const &/*component*/)
+{
+ return true;
+}
+ /*}}}*/
// ListParser::ParseStatus - Parse the status field /*{{{*/
// ---------------------------------------------------------------------
/* The Status: line here is not a normal dpkg one but just one which tells
{
std::string out;
strprintf(out, "Package: %s\nArchitecture: %s\nAuto-Installed: 1\n\n", Pkg.Name(), Pkg.Arch());
- if (d->extendedstates.Write(out.c_str(), out.length()) == false)
+ if (extendedstates.Write(out.c_str(), out.length()) == false)
return false;
}
{
std::string out;
strprintf(out, "Package: %s\nPin: version %s\nPin-Priority: 9999\n\n", Pkg.FullName().c_str(), Ver.VerStr());
- if (d->preferences.Write(out.c_str(), out.length()) == false)
+ if (preferences.Write(out.c_str(), out.length()) == false)
return false;
}
{
std::string out;
strprintf(out, "Package: %s\nPin: version %s\nPin-Priority: %d\n\n", Pkg.FullName().c_str(), Ver.VerStr(), pinvalue);
- if (d->preferences.Write(out.c_str(), out.length()) == false)
+ if (preferences.Write(out.c_str(), out.length()) == false)
return false;
}
return true;
}
/*}}}*/
-// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
-APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*FileI*/,
- FileFd & /*File*/, std::string const &/*component*/)
+
+// ListParser::eippListParser - Constructor /*{{{*/
+eippListParser::eippListParser(FileFd *File) : edspLikeListParser(File)
{
- return true;
}
/*}}}*/
-edspListParser::~edspListParser() /*{{{*/
+// 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)
{
- delete d;
+ // 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() {}