]>
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>
26 // ListParser::edspListParser - Constructor /*{{{*/
27 edspLikeListParser::edspLikeListParser(FileFd
* const File
) : debListParser(File
)
30 edspListParser::edspListParser(FileFd
* const File
) : edspLikeListParser(File
)
32 std::string
const states
= _config
->FindFile("Dir::State::extended_states");
33 RemoveFile("edspListParserPrivate", states
);
34 extendedstates
.Open(states
, FileFd::WriteOnly
| FileFd::Create
| FileFd::Exclusive
, 0600);
35 std::string
const prefs
= _config
->FindFile("Dir::Etc::preferences");
36 RemoveFile("edspListParserPrivate", prefs
);
37 preferences
.Open(prefs
, FileFd::WriteOnly
| FileFd::Create
| FileFd::Exclusive
, 0600);
40 // ListParser::NewVersion - Fill in the version structure /*{{{*/
41 bool edspLikeListParser::NewVersion(pkgCache::VerIterator
&Ver
)
43 _system
->SetVersionMapping(Ver
->ID
, Section
.FindI("APT-ID", Ver
->ID
));
44 return debListParser::NewVersion(Ver
);
47 // ListParser::Description - Return the description string /*{{{*/
48 // ---------------------------------------------------------------------
49 /* Sorry, no description for the resolvers… */
50 std::vector
<std::string
> edspLikeListParser::AvailableDescriptionLanguages()
54 MD5SumValue
edspLikeListParser::Description_md5()
56 return MD5SumValue("");
59 // ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
60 unsigned short edspLikeListParser::VersionHash()
62 if (Section
.Exists("APT-Hash") == true)
63 return Section
.FindI("APT-Hash");
64 else if (Section
.Exists("APT-ID") == true)
65 return Section
.FindI("APT-ID");
69 // ListParser::LoadReleaseInfo - Load the release information /*{{{*/
70 APT_CONST
bool edspLikeListParser::LoadReleaseInfo(pkgCache::RlsFileIterator
& /*FileI*/,
71 FileFd
& /*File*/, std::string
const &/*component*/)
76 // ListParser::ParseStatus - Parse the status field /*{{{*/
77 // ---------------------------------------------------------------------
78 /* The Status: line here is not a normal dpkg one but just one which tells
79 use if the package is installed or not, where missing means not. */
80 bool edspListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
81 pkgCache::VerIterator
&Ver
)
83 unsigned long state
= 0;
84 if (Section
.FindFlag("Hold",state
,pkgCache::State::Hold
) == false)
87 Pkg
->SelectedState
= pkgCache::State::Hold
;
90 if (Section
.FindFlag("Installed",state
,pkgCache::State::Installed
) == false)
94 Pkg
->CurrentState
= pkgCache::State::Installed
;
95 Pkg
->CurrentVer
= Ver
.Index();
98 if (Section
.FindB("APT-Automatic", false))
101 strprintf(out
, "Package: %s\nArchitecture: %s\nAuto-Installed: 1\n\n", Pkg
.Name(), Pkg
.Arch());
102 if (extendedstates
.Write(out
.c_str(), out
.length()) == false)
106 // FIXME: Using an overriding pin is wrong.
107 if (Section
.FindB("APT-Candidate", false))
110 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: 9999\n\n", Pkg
.FullName().c_str(), Ver
.VerStr());
111 if (preferences
.Write(out
.c_str(), out
.length()) == false)
115 signed short const pinvalue
= Section
.FindI("APT-Pin", 500);
119 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: %d\n\n", Pkg
.FullName().c_str(), Ver
.VerStr(), pinvalue
);
120 if (preferences
.Write(out
.c_str(), out
.length()) == false)
128 // ListParser::eippListParser - Constructor /*{{{*/
129 eippListParser::eippListParser(FileFd
*File
) : edspLikeListParser(File
)
133 // ListParser::ParseStatus - Parse the status field /*{{{*/
134 // ---------------------------------------------------------------------
135 /* The Status: line here is not a normal dpkg one but just one which tells
136 use if the package is installed or not, where missing means not. */
137 bool eippListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
138 pkgCache::VerIterator
&Ver
)
140 // Process the flag field
141 static std::array
<WordList
, 8> const statusvalues
= {{
142 {"not-installed",pkgCache::State::NotInstalled
},
143 {"config-files",pkgCache::State::ConfigFiles
},
144 {"half-installed",pkgCache::State::HalfInstalled
},
145 {"unpacked",pkgCache::State::UnPacked
},
146 {"half-configured",pkgCache::State::HalfConfigured
},
147 {"triggers-awaited",pkgCache::State::TriggersAwaited
},
148 {"triggers-pending",pkgCache::State::TriggersPending
},
149 {"installed",pkgCache::State::Installed
},
151 auto const status
= Section
.Find("Status");
152 if (status
.empty() == false)
154 for (auto && sv
: statusvalues
)
156 if (status
!= sv
.Str
)
158 Pkg
->CurrentState
= sv
.Val
;
159 switch (Pkg
->CurrentState
)
161 case pkgCache::State::NotInstalled
:
162 case pkgCache::State::ConfigFiles
:
164 case pkgCache::State::HalfInstalled
:
165 case pkgCache::State::UnPacked
:
166 case pkgCache::State::HalfConfigured
:
167 case pkgCache::State::TriggersAwaited
:
168 case pkgCache::State::TriggersPending
:
169 case pkgCache::State::Installed
:
170 Pkg
->CurrentVer
= Ver
.Index();
181 edspLikeListParser::~edspLikeListParser() {}
182 edspListParser::~edspListParser() {}
183 eippListParser::~eippListParser() {}