]>
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 class edspListParserPrivate
/*{{{*/
29 FileFd extendedstates
;
32 edspListParserPrivate()
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);
43 // ListParser::edspListParser - Constructor /*{{{*/
44 edspListParser::edspListParser(FileFd
*File
) : debListParser(File
), d(new edspListParserPrivate())
48 // ListParser::NewVersion - Fill in the version structure /*{{{*/
49 bool edspListParser::NewVersion(pkgCache::VerIterator
&Ver
)
51 _system
->SetVersionMapping(Ver
->ID
, Section
.FindI("APT-ID", Ver
->ID
));
52 return debListParser::NewVersion(Ver
);
55 // ListParser::Description - Return the description string /*{{{*/
56 // ---------------------------------------------------------------------
57 /* Sorry, no description for the resolvers… */
58 std::vector
<std::string
> edspListParser::AvailableDescriptionLanguages()
62 MD5SumValue
edspListParser::Description_md5()
64 return MD5SumValue("");
67 // ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
68 // ---------------------------------------------------------------------
70 unsigned short edspListParser::VersionHash()
72 if (Section
.Exists("APT-Hash") == true)
73 return Section
.FindI("APT-Hash");
74 else if (Section
.Exists("APT-ID") == true)
75 return Section
.FindI("APT-ID");
79 // ListParser::ParseStatus - Parse the status field /*{{{*/
80 // ---------------------------------------------------------------------
81 /* The Status: line here is not a normal dpkg one but just one which tells
82 use if the package is installed or not, where missing means not. */
83 bool edspListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
84 pkgCache::VerIterator
&Ver
)
86 unsigned long state
= 0;
87 if (Section
.FindFlag("Hold",state
,pkgCache::State::Hold
) == false)
90 Pkg
->SelectedState
= pkgCache::State::Hold
;
93 if (Section
.FindFlag("Installed",state
,pkgCache::State::Installed
) == false)
97 Pkg
->CurrentState
= pkgCache::State::Installed
;
98 Pkg
->CurrentVer
= Ver
.Index();
101 if (Section
.FindB("APT-Automatic", false))
104 strprintf(out
, "Package: %s\nArchitecture: %s\nAuto-Installed: 1\n\n", Pkg
.Name(), Pkg
.Arch());
105 if (d
->extendedstates
.Write(out
.c_str(), out
.length()) == false)
109 // FIXME: Using an overriding pin is wrong.
110 if (Section
.FindB("APT-Candidate", false))
113 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: 9999\n\n", Pkg
.FullName().c_str(), Ver
.VerStr());
114 if (d
->preferences
.Write(out
.c_str(), out
.length()) == false)
118 signed short const pinvalue
= Section
.FindI("APT-Pin", 500);
122 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: %d\n\n", Pkg
.FullName().c_str(), Ver
.VerStr(), pinvalue
);
123 if (d
->preferences
.Write(out
.c_str(), out
.length()) == false)
130 // ListParser::LoadReleaseInfo - Load the release information /*{{{*/
131 APT_CONST
bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator
& /*FileI*/,
132 FileFd
& /*File*/, std::string
const &/*component*/)
137 edspListParser::~edspListParser() /*{{{*/