From 6d38011bb93451dd9da3294614d821c77ac91687 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 30 Mar 2011 17:23:43 +0200 Subject: add a first round of stuff needed for talking between APT and solvers based on a very early draft for EDSP by Stefano APT can now write a scenario as well as load most stuff from it. --- apt-pkg/edsp/edsplistparser.cc | 109 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 apt-pkg/edsp/edsplistparser.cc (limited to 'apt-pkg/edsp/edsplistparser.cc') diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc new file mode 100644 index 000000000..3e57ea822 --- /dev/null +++ b/apt-pkg/edsp/edsplistparser.cc @@ -0,0 +1,109 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Package Cache Generator - Generator for the cache structure. + + This builds the cache structure from the abstract package list parser. + + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include +#include +#include +#include +#include +#include + /*}}}*/ + +// ListParser::edspListParser - Constructor /*{{{*/ +edspListParser::edspListParser(FileFd *File, string const &Arch) : debListParser(File, Arch) +{} + /*}}}*/ +// ListParser::NewVersion - Fill in the version structure /*{{{*/ +bool edspListParser::NewVersion(pkgCache::VerIterator &Ver) +{ + Ver->ID = Section.FindI("APT-ID", Ver->ID); + return debListParser::NewVersion(Ver); +} + /*}}}*/ +// ListParser::Description - Return the description string /*{{{*/ +// --------------------------------------------------------------------- +/* Sorry, no description for the resolvers… */ +string edspListParser::Description() +{ + return ""; +} +string edspListParser::DescriptionLanguage() +{ + return ""; +} +MD5SumValue edspListParser::Description_md5() +{ + return MD5SumValue(""); +} + /*}}}*/ +// ListParser::VersionHash - Compute a unique hash for this version /*{{{*/ +// --------------------------------------------------------------------- +/* */ +unsigned short edspListParser::VersionHash() +{ + if (Section.Exists("APT-Hash") == true) + return Section.FindI("APT-Hash"); + else if (Section.Exists("APT-ID") == true) + return Section.FindI("APT-ID"); + return 0; +} + /*}}}*/ +// 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 edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg, + pkgCache::VerIterator &Ver) +{ + const char *Start; + const char *Stop; + if (Section.Find("Status",Start,Stop) == false) + return true; + + // UsePackage() is responsible for setting the flag in the default case + bool const static essential = _config->Find("pkgCacheGen::Essential", "") == "installed"; + if (essential == true && + Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false) + return false; + + // Isolate the first word + const char *I = Start; + for(; I < Stop && *I != ' '; I++); + + // Process the flag field + WordList StatusList[] = {{"installed",pkgCache::State::Installed}, + {}}; + if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false) + return _error->Error("Malformed Status line"); + + /* A Status line marks the package as indicating the current + version as well. Only if it is actually installed.. Otherwise + the interesting dpkg handling of the status file creates bogus + entries. */ + if (!(Pkg->CurrentState == pkgCache::State::NotInstalled || + Pkg->CurrentState == pkgCache::State::ConfigFiles)) + { + if (Ver.end() == true) + _error->Warning("Encountered status field in a non-version description"); + else + Pkg->CurrentVer = Ver.Index(); + } + + return true; +} + /*}}}*/ +// ListParser::LoadReleaseInfo - Load the release information /*{{{*/ +bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, + FileFd &File, string component) +{ + return true; +} + /*}}}*/ -- cgit v1.2.3 From b195733d0f3476ae92f2689ba5c584a69171f170 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 31 Mar 2011 12:17:39 +0200 Subject: parse the state of the package from the scenario file correctly --- apt-pkg/edsp/edsplistparser.cc | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'apt-pkg/edsp/edsplistparser.cc') diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index 3e57ea822..913455efa 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -63,40 +63,18 @@ unsigned short edspListParser::VersionHash() bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver) { - const char *Start; - const char *Stop; - if (Section.Find("Status",Start,Stop) == false) - return true; - - // UsePackage() is responsible for setting the flag in the default case - bool const static essential = _config->Find("pkgCacheGen::Essential", "") == "installed"; - if (essential == true && - Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false) + if (Section.FindFlag("Hold",Pkg->Flags,pkgCache::State::Installed) == false) return false; - // Isolate the first word - const char *I = Start; - for(; I < Stop && *I != ' '; I++); - - // Process the flag field - WordList StatusList[] = {{"installed",pkgCache::State::Installed}, - {}}; - if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false) - return _error->Error("Malformed Status line"); - - /* A Status line marks the package as indicating the current - version as well. Only if it is actually installed.. Otherwise - the interesting dpkg handling of the status file creates bogus - entries. */ - if (!(Pkg->CurrentState == pkgCache::State::NotInstalled || - Pkg->CurrentState == pkgCache::State::ConfigFiles)) + unsigned long state = 0; + if (Section.FindFlag("Installed",state,pkgCache::State::Installed) == false) + return false; + if (state != 0) { - if (Ver.end() == true) - _error->Warning("Encountered status field in a non-version description"); - else - Pkg->CurrentVer = Ver.Index(); + Pkg->CurrentState = pkgCache::State::Installed; + Pkg->CurrentVer = Ver.Index(); } - + return true; } /*}}}*/ -- cgit v1.2.3 From 9221da7e1d5516494d17043a4d0b063a1d6b95c2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 2 May 2011 18:08:13 +0200 Subject: parse correctly the Hold: lines into Pkg->SelectedState = Hold --- apt-pkg/edsp/edsplistparser.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'apt-pkg/edsp/edsplistparser.cc') diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index 913455efa..3349e8cce 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -63,10 +63,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) -- cgit v1.2.3