]>
git.saurik.com Git - apt.git/blob - apt-pkg/edsp/edsplistparser.cc
85a57479ec2e83807857adad51d1766a8699dff4
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 RemoveFile("edspListParserPrivate", states
);
35 extendedstates
.Open(states
, FileFd::WriteOnly
| FileFd::Create
| FileFd::Exclusive
, 0600);
36 std::string
const prefs
= _config
->FindFile("Dir::Etc::preferences");
37 RemoveFile("edspListParserPrivate", prefs
);
38 preferences
.Open(prefs
, FileFd::WriteOnly
| FileFd::Create
| FileFd::Exclusive
, 0600);
42 // ListParser::edspListParser - Constructor /*{{{*/
43 edspListParser::edspListParser(FileFd
*File
) : debListParser(File
), d(new edspListParserPrivate())
47 // ListParser::NewVersion - Fill in the version structure /*{{{*/
48 bool edspListParser::NewVersion(pkgCache::VerIterator
&Ver
)
50 Ver
->ID
= Section
.FindI("APT-ID", Ver
->ID
);
51 return debListParser::NewVersion(Ver
);
54 // ListParser::Description - Return the description string /*{{{*/
55 // ---------------------------------------------------------------------
56 /* Sorry, no description for the resolvers… */
57 std::string
edspListParser::Description()
61 std::string
edspListParser::DescriptionLanguage()
65 MD5SumValue
edspListParser::Description_md5()
67 return MD5SumValue("");
70 // ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
71 // ---------------------------------------------------------------------
73 unsigned short edspListParser::VersionHash()
75 if (Section
.Exists("APT-Hash") == true)
76 return Section
.FindI("APT-Hash");
77 else if (Section
.Exists("APT-ID") == true)
78 return Section
.FindI("APT-ID");
82 // ListParser::ParseStatus - Parse the status field /*{{{*/
83 // ---------------------------------------------------------------------
84 /* The Status: line here is not a normal dpkg one but just one which tells
85 use if the package is installed or not, where missing means not. */
86 bool edspListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
87 pkgCache::VerIterator
&Ver
)
89 unsigned long state
= 0;
90 if (Section
.FindFlag("Hold",state
,pkgCache::State::Hold
) == false)
93 Pkg
->SelectedState
= pkgCache::State::Hold
;
96 if (Section
.FindFlag("Installed",state
,pkgCache::State::Installed
) == false)
100 Pkg
->CurrentState
= pkgCache::State::Installed
;
101 Pkg
->CurrentVer
= Ver
.Index();
104 if (Section
.FindB("APT-Automatic", false))
107 strprintf(out
, "Package: %s\nArchitecture: %s\nAuto-Installed: 1\n\n", Pkg
.Name(), Pkg
.Arch());
108 if (d
->extendedstates
.Write(out
.c_str(), out
.length()) == false)
112 // FIXME: Using an overriding pin is wrong.
113 if (Section
.FindB("APT-Candidate", false))
116 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: 9999\n\n", Pkg
.FullName().c_str(), Ver
.VerStr());
117 if (d
->preferences
.Write(out
.c_str(), out
.length()) == false)
121 signed short const pinvalue
= Section
.FindI("APT-Pin", 500);
125 strprintf(out
, "Package: %s\nPin: version %s\nPin-Priority: %d\n\n", Pkg
.FullName().c_str(), Ver
.VerStr(), pinvalue
);
126 if (d
->preferences
.Write(out
.c_str(), out
.length()) == false)
133 // ListParser::LoadReleaseInfo - Load the release information /*{{{*/
134 APT_CONST
bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator
& /*FileI*/,
135 FileFd
& /*File*/, std::string
const &/*component*/)
140 edspListParser::~edspListParser() /*{{{*/