]>
git.saurik.com Git - apt.git/blob - apt-pkg/edsp/edsplistparser.cc
77a0edc22c8ef13d8e4112b68a2e90b969ef7f42
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>
25 class edspListParserPrivate
/*{{{*/
28 FileFd extendedstates
;
31 edspListParserPrivate()
33 std::string
const states
= _config
->FindFile("Dir::State::extended_states");
34 if (states
!= "/dev/null")
35 unlink(states
.c_str());
36 extendedstates
.Open(states
, FileFd::WriteOnly
| FileFd::Create
| FileFd::Exclusive
, 0600);
37 std::string
const prefs
= _config
->FindFile("Dir::Etc::preferences");
38 if (prefs
!= "/dev/null")
39 unlink(prefs
.c_str());
40 preferences
.Open(prefs
, FileFd::WriteOnly
| FileFd::Create
| FileFd::Exclusive
, 0600);
44 // ListParser::edspListParser - Constructor /*{{{*/
45 edspListParser::edspListParser(FileFd
*File
) : debListParser(File
), d(new edspListParserPrivate())
49 // ListParser::NewVersion - Fill in the version structure /*{{{*/
50 bool edspListParser::NewVersion(pkgCache::VerIterator
&Ver
)
52 Ver
->ID
= Section
.FindI("APT-ID", Ver
->ID
);
53 return debListParser::NewVersion(Ver
);
56 // ListParser::Description - Return the description string /*{{{*/
57 // ---------------------------------------------------------------------
58 /* Sorry, no description for the resolvers… */
59 std::string
edspListParser::Description()
63 std::string
edspListParser::DescriptionLanguage()
67 MD5SumValue
edspListParser::Description_md5()
69 return MD5SumValue("");
72 // ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
73 // ---------------------------------------------------------------------
75 unsigned short edspListParser::VersionHash()
77 if (Section
.Exists("APT-Hash") == true)
78 return Section
.FindI("APT-Hash");
79 else if (Section
.Exists("APT-ID") == true)
80 return Section
.FindI("APT-ID");
84 // ListParser::ParseStatus - Parse the status field /*{{{*/
85 // ---------------------------------------------------------------------
86 /* The Status: line here is not a normal dpkg one but just one which tells
87 use if the package is installed or not, where missing means not. */
88 bool edspListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
89 pkgCache::VerIterator
&Ver
)
91 unsigned long state
= 0;
92 if (Section
.FindFlag("Hold",state
,pkgCache::State::Hold
) == false)
95 Pkg
->SelectedState
= pkgCache::State::Hold
;
98 if (Section
.FindFlag("Installed",state
,pkgCache::State::Installed
) == false)
102 Pkg
->CurrentState
= pkgCache::State::Installed
;
103 Pkg
->CurrentVer
= Ver
.Index();
106 if (Section
.FindB("APT-Automatic", false))
109 strprintf(out
, "Package: %s\nArchitecture: %s\nAuto-Installed: 1\n\n", Pkg
.Name(), Pkg
.Arch());
110 if (d
->extendedstates
.Write(out
.c_str(), out
.length()) == false)
114 // FIXME: Using an overriding pin is wrong.
115 if (Section
.FindB("APT-Candidate", false))
118 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: 9999\n\n", Pkg
.FullName().c_str(), Ver
.VerStr());
119 if (d
->preferences
.Write(out
.c_str(), out
.length()) == false)
123 signed short const pinvalue
= Section
.FindI("APT-Pin", 500);
127 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: %d\n\n", Pkg
.FullName().c_str(), Ver
.VerStr(), pinvalue
);
128 if (d
->preferences
.Write(out
.c_str(), out
.length()) == false)
135 // ListParser::LoadReleaseInfo - Load the release information /*{{{*/
136 APT_CONST
bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator
& /*FileI*/,
137 FileFd
& /*File*/, std::string
const &/*component*/)
142 edspListParser::~edspListParser() /*{{{*/