X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b195733d0f3476ae92f2689ba5c584a69171f170..294a80209a0c6ea617a14fb2ae650d4fd329eab5:/apt-pkg/edsp/edsplistparser.cc diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index 913455efa..77a0edc22 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -9,17 +9,42 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include -#include +#include + #include -#include +#include #include -#include +#include +#include +#include +#include +#include + /*}}}*/ +class edspListParserPrivate /*{{{*/ +{ +public: + FileFd extendedstates; + FileFd preferences; + + edspListParserPrivate() + { + std::string const states = _config->FindFile("Dir::State::extended_states"); + if (states != "/dev/null") + unlink(states.c_str()); + extendedstates.Open(states, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600); + std::string const prefs = _config->FindFile("Dir::Etc::preferences"); + if (prefs != "/dev/null") + unlink(prefs.c_str()); + preferences.Open(prefs, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600); + } +}; + /*}}}*/ // ListParser::edspListParser - Constructor /*{{{*/ -edspListParser::edspListParser(FileFd *File, string const &Arch) : debListParser(File, Arch) -{} +edspListParser::edspListParser(FileFd *File) : debListParser(File), d(new edspListParserPrivate()) +{ +} /*}}}*/ // ListParser::NewVersion - Fill in the version structure /*{{{*/ bool edspListParser::NewVersion(pkgCache::VerIterator &Ver) @@ -31,11 +56,11 @@ bool edspListParser::NewVersion(pkgCache::VerIterator &Ver) // ListParser::Description - Return the description string /*{{{*/ // --------------------------------------------------------------------- /* Sorry, no description for the resolvers… */ -string edspListParser::Description() +std::string edspListParser::Description() { return ""; } -string edspListParser::DescriptionLanguage() +std::string edspListParser::DescriptionLanguage() { return ""; } @@ -63,10 +88,13 @@ unsigned short edspListParser::VersionHash() bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver) { - if (Section.FindFlag("Hold",Pkg->Flags,pkgCache::State::Installed) == false) + unsigned long state = 0; + if (Section.FindFlag("Hold",state,pkgCache::State::Hold) == false) return false; + if (state != 0) + Pkg->SelectedState = pkgCache::State::Hold; - unsigned long state = 0; + state = 0; if (Section.FindFlag("Installed",state,pkgCache::State::Installed) == false) return false; if (state != 0) @@ -75,13 +103,44 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg, Pkg->CurrentVer = Ver.Index(); } + if (Section.FindB("APT-Automatic", false)) + { + 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) + return false; + } + + // FIXME: Using an overriding pin is wrong. + if (Section.FindB("APT-Candidate", 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) + return false; + } + + signed short const pinvalue = Section.FindI("APT-Pin", 500); + if (pinvalue != 500) + { + 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) + return false; + } + return true; } /*}}}*/ // ListParser::LoadReleaseInfo - Load the release information /*{{{*/ -bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, - FileFd &File, string component) +APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*FileI*/, + FileFd & /*File*/, std::string const &/*component*/) { return true; } /*}}}*/ +edspListParser::~edspListParser() /*{{{*/ +{ + delete d; +} + /*}}}*/