add a first round of stuff needed for talking between APT and solvers
[ntk/apt.git] / apt-pkg / edsp / edsplistparser.cc
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4
5 Package Cache Generator - Generator for the cache structure.
6
7 This builds the cache structure from the abstract package list parser.
8
9 ##################################################################### */
10 /*}}}*/
11 // Include Files /*{{{*/
12 #include <apt-pkg/edsplistparser.h>
13 #include <apt-pkg/error.h>
14 #include <apt-pkg/configuration.h>
15 #include <apt-pkg/strutl.h>
16 #include <apt-pkg/md5.h>
17 #include <apt-pkg/macros.h>
18 /*}}}*/
19
20 // ListParser::edspListParser - Constructor /*{{{*/
21 edspListParser::edspListParser(FileFd *File, string const &Arch) : debListParser(File, Arch)
22 {}
23 /*}}}*/
24 // ListParser::NewVersion - Fill in the version structure /*{{{*/
25 bool edspListParser::NewVersion(pkgCache::VerIterator &Ver)
26 {
27 Ver->ID = Section.FindI("APT-ID", Ver->ID);
28 return debListParser::NewVersion(Ver);
29 }
30 /*}}}*/
31 // ListParser::Description - Return the description string /*{{{*/
32 // ---------------------------------------------------------------------
33 /* Sorry, no description for the resolvers… */
34 string edspListParser::Description()
35 {
36 return "";
37 }
38 string edspListParser::DescriptionLanguage()
39 {
40 return "";
41 }
42 MD5SumValue edspListParser::Description_md5()
43 {
44 return MD5SumValue("");
45 }
46 /*}}}*/
47 // ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
48 // ---------------------------------------------------------------------
49 /* */
50 unsigned short edspListParser::VersionHash()
51 {
52 if (Section.Exists("APT-Hash") == true)
53 return Section.FindI("APT-Hash");
54 else if (Section.Exists("APT-ID") == true)
55 return Section.FindI("APT-ID");
56 return 0;
57 }
58 /*}}}*/
59 // ListParser::ParseStatus - Parse the status field /*{{{*/
60 // ---------------------------------------------------------------------
61 /* The Status: line here is not a normal dpkg one but just one which tells
62 use if the package is installed or not, where missing means not. */
63 bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
64 pkgCache::VerIterator &Ver)
65 {
66 const char *Start;
67 const char *Stop;
68 if (Section.Find("Status",Start,Stop) == false)
69 return true;
70
71 // UsePackage() is responsible for setting the flag in the default case
72 bool const static essential = _config->Find("pkgCacheGen::Essential", "") == "installed";
73 if (essential == true &&
74 Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
75 return false;
76
77 // Isolate the first word
78 const char *I = Start;
79 for(; I < Stop && *I != ' '; I++);
80
81 // Process the flag field
82 WordList StatusList[] = {{"installed",pkgCache::State::Installed},
83 {}};
84 if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false)
85 return _error->Error("Malformed Status line");
86
87 /* A Status line marks the package as indicating the current
88 version as well. Only if it is actually installed.. Otherwise
89 the interesting dpkg handling of the status file creates bogus
90 entries. */
91 if (!(Pkg->CurrentState == pkgCache::State::NotInstalled ||
92 Pkg->CurrentState == pkgCache::State::ConfigFiles))
93 {
94 if (Ver.end() == true)
95 _error->Warning("Encountered status field in a non-version description");
96 else
97 Pkg->CurrentVer = Ver.Index();
98 }
99
100 return true;
101 }
102 /*}}}*/
103 // ListParser::LoadReleaseInfo - Load the release information /*{{{*/
104 bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
105 FileFd &File, string component)
106 {
107 return true;
108 }
109 /*}}}*/