]>
git.saurik.com Git - apt.git/blob - apt-pkg/edsp/edsplistparser.cc
1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
5 Package Cache Generator - Generator for the cache structure.
7 This builds the cache structure from the abstract package list parser.
9 ##################################################################### */
11 // Include Files /*{{{*/
14 #include <apt-pkg/configuration.h>
15 #include <apt-pkg/edsplistparser.h>
16 #include <apt-pkg/md5.h>
17 #include <apt-pkg/deblistparser.h>
18 #include <apt-pkg/pkgcache.h>
19 #include <apt-pkg/cacheiterators.h>
20 #include <apt-pkg/tagfile.h>
21 #include <apt-pkg/fileutl.h>
22 #include <apt-pkg/pkgsystem.h>
28 // ListParser::edspListParser - Constructor /*{{{*/
29 edspLikeListParser::edspLikeListParser(FileFd
* const File
) : debListParser(File
)
32 edspListParser::edspListParser(FileFd
* const File
) : edspLikeListParser(File
)
34 std::string
const states
= _config
->FindFile("Dir::State::extended_states");
35 RemoveFile("edspListParserPrivate", states
);
36 extendedstates
.Open(states
, FileFd::WriteOnly
| FileFd::Create
| FileFd::Exclusive
, 0600);
37 std::string
const prefs
= _config
->FindFile("Dir::Etc::preferences");
38 RemoveFile("edspListParserPrivate", prefs
);
39 preferences
.Open(prefs
, FileFd::WriteOnly
| FileFd::Create
| FileFd::Exclusive
, 0600);
42 // ListParser::NewVersion - Fill in the version structure /*{{{*/
43 bool edspLikeListParser::NewVersion(pkgCache::VerIterator
&Ver
)
45 _system
->SetVersionMapping(Ver
->ID
, Section
.FindI("APT-ID", Ver
->ID
));
46 return debListParser::NewVersion(Ver
);
49 // ListParser::Description - Return the description string /*{{{*/
50 // ---------------------------------------------------------------------
51 /* Sorry, no description for the resolvers… */
52 std::vector
<std::string
> edspLikeListParser::AvailableDescriptionLanguages()
56 MD5SumValue
edspLikeListParser::Description_md5()
58 return MD5SumValue("");
61 // ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
62 unsigned short edspLikeListParser::VersionHash()
64 if (Section
.Exists("APT-Hash") == true)
65 return Section
.FindI("APT-Hash");
66 else if (Section
.Exists("APT-ID") == true)
67 return Section
.FindI("APT-ID");
71 // ListParser::LoadReleaseInfo - Load the release information /*{{{*/
72 APT_CONST
bool edspLikeListParser::LoadReleaseInfo(pkgCache::RlsFileIterator
& /*FileI*/,
73 FileFd
& /*File*/, std::string
const &/*component*/)
78 // ListParser::ParseStatus - Parse the status field /*{{{*/
79 // ---------------------------------------------------------------------
80 /* The Status: line here is not a normal dpkg one but just one which tells
81 use if the package is installed or not, where missing means not. */
82 bool edspListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
83 pkgCache::VerIterator
&Ver
)
85 unsigned long state
= 0;
86 if (Section
.FindFlag("Hold",state
,pkgCache::State::Hold
) == false)
89 Pkg
->SelectedState
= pkgCache::State::Hold
;
92 if (Section
.FindFlag("Installed",state
,pkgCache::State::Installed
) == false)
96 Pkg
->CurrentState
= pkgCache::State::Installed
;
97 Pkg
->CurrentVer
= Ver
.Index();
100 if (Section
.FindB("APT-Automatic", false))
103 strprintf(out
, "Package: %s\nArchitecture: %s\nAuto-Installed: 1\n\n", Pkg
.Name(), Pkg
.Arch());
104 if (extendedstates
.Write(out
.c_str(), out
.length()) == false)
108 // FIXME: Using an overriding pin is wrong.
109 if (Section
.FindB("APT-Candidate", false))
112 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: 9999\n\n", Pkg
.FullName().c_str(), Ver
.VerStr());
113 if (preferences
.Write(out
.c_str(), out
.length()) == false)
117 signed short const pinvalue
= Section
.FindI("APT-Pin", 500);
121 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: %d\n\n", Pkg
.FullName().c_str(), Ver
.VerStr(), pinvalue
);
122 if (preferences
.Write(out
.c_str(), out
.length()) == false)
130 // ListParser::eippListParser - Constructor /*{{{*/
131 eippListParser::eippListParser(FileFd
*File
) : edspLikeListParser(File
)
135 // ListParser::ParseStatus - Parse the status field /*{{{*/
136 // ---------------------------------------------------------------------
137 /* The Status: line here is not a normal dpkg one but just one which tells
138 use if the package is installed or not, where missing means not. */
139 bool eippListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
140 pkgCache::VerIterator
&Ver
)
142 // Process the flag field
143 static std::array
<WordList
, 8> const statusvalues
= {{
144 {"not-installed",pkgCache::State::NotInstalled
},
145 {"config-files",pkgCache::State::ConfigFiles
},
146 {"half-installed",pkgCache::State::HalfInstalled
},
147 {"unpacked",pkgCache::State::UnPacked
},
148 {"half-configured",pkgCache::State::HalfConfigured
},
149 {"triggers-awaited",pkgCache::State::TriggersAwaited
},
150 {"triggers-pending",pkgCache::State::TriggersPending
},
151 {"installed",pkgCache::State::Installed
},
153 auto const status
= Section
.Find("Status");
154 if (status
.empty() == false)
156 for (auto && sv
: statusvalues
)
158 if (status
!= sv
.Str
)
160 Pkg
->CurrentState
= sv
.Val
;
161 switch (Pkg
->CurrentState
)
163 case pkgCache::State::NotInstalled
:
164 case pkgCache::State::ConfigFiles
:
166 case pkgCache::State::HalfInstalled
:
167 case pkgCache::State::UnPacked
:
168 case pkgCache::State::HalfConfigured
:
169 case pkgCache::State::TriggersAwaited
:
170 case pkgCache::State::TriggersPending
:
171 case pkgCache::State::Installed
:
172 Pkg
->CurrentVer
= Ver
.Index();
183 edspLikeListParser::~edspLikeListParser() {}
184 edspListParser::~edspListParser() {}
185 eippListParser::~eippListParser() {}