]>
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 edspLikeListParser::~edspLikeListParser() {}
129 edspListParser::~edspListParser() {}