diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-09-08 22:14:11 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-09-14 15:22:18 +0200 |
commit | 188a6fcf4f13df1fd362a0aff27a23493ddd1ec5 (patch) | |
tree | d7d29209986acf989484cd0050601b55d5e40dba /apt-pkg/edsp/edsplistparser.cc | |
parent | 8fec289ad8a2c42350c24d5c97b0f104fbbea176 (diff) |
implement autobit and pinning in EDSP solver 'apt'
The parser creates a preferences as well as an extended states file
based on the EDSP scenario file, which isn't the most efficient way of
dealing with this as thes text files have to be parsed again by another
layer of the code, but it needs the least changes and works good enough
for now. The 'apt' solver is in the end just a test solver like dump.
Diffstat (limited to 'apt-pkg/edsp/edsplistparser.cc')
-rw-r--r-- | apt-pkg/edsp/edsplistparser.cc | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index ff79b537e..5c90cf1fc 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -11,18 +11,40 @@ // Include Files /*{{{*/ #include <config.h> +#include <apt-pkg/configuration.h> #include <apt-pkg/edsplistparser.h> #include <apt-pkg/md5.h> #include <apt-pkg/deblistparser.h> #include <apt-pkg/pkgcache.h> #include <apt-pkg/cacheiterators.h> #include <apt-pkg/tagfile.h> +#include <apt-pkg/fileutl.h> /*}}}*/ +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) : debListParser(File), d(NULL) -{} +edspListParser::edspListParser(FileFd *File) : debListParser(File), d(new edspListParserPrivate()) +{ +} /*}}}*/ // ListParser::NewVersion - Fill in the version structure /*{{{*/ bool edspListParser::NewVersion(pkgCache::VerIterator &Ver) @@ -81,6 +103,23 @@ 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; + } + + 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; } /*}}}*/ @@ -91,5 +130,8 @@ APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*Fil return true; } /*}}}*/ - -edspListParser::~edspListParser() {} +edspListParser::~edspListParser() /*{{{*/ +{ + delete d; +} + /*}}}*/ |