]> git.saurik.com Git - apt.git/blame - apt-pkg/edsp/edsplistparser.cc
debian/gbp.conf: point debian-branch to master
[apt.git] / apt-pkg / edsp / edsplistparser.cc
CommitLineData
6d38011b
DK
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Package Cache Generator - Generator for the cache structure.
6
7 This builds the cache structure from the abstract package list parser.
8
9 ##################################################################### */
10 /*}}}*/
11// Include Files /*{{{*/
ea542140
DK
12#include <config.h>
13
188a6fcf 14#include <apt-pkg/configuration.h>
6d38011b 15#include <apt-pkg/edsplistparser.h>
6d38011b 16#include <apt-pkg/md5.h>
453b82a3
DK
17#include <apt-pkg/deblistparser.h>
18#include <apt-pkg/pkgcache.h>
19#include <apt-pkg/cacheiterators.h>
20#include <apt-pkg/tagfile.h>
188a6fcf 21#include <apt-pkg/fileutl.h>
453b82a3 22
6d38011b
DK
23 /*}}}*/
24
188a6fcf
DK
25class edspListParserPrivate /*{{{*/
26{
27public:
28 FileFd extendedstates;
29 FileFd preferences;
30
31 edspListParserPrivate()
32 {
33 std::string const states = _config->FindFile("Dir::State::extended_states");
ce1f3a2c 34 RemoveFile("edspListParserPrivate", states);
188a6fcf
DK
35 extendedstates.Open(states, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
36 std::string const prefs = _config->FindFile("Dir::Etc::preferences");
ce1f3a2c 37 RemoveFile("edspListParserPrivate", prefs);
188a6fcf
DK
38 preferences.Open(prefs, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
39 }
40};
41 /*}}}*/
6d38011b 42// ListParser::edspListParser - Constructor /*{{{*/
188a6fcf
DK
43edspListParser::edspListParser(FileFd *File) : debListParser(File), d(new edspListParserPrivate())
44{
45}
6d38011b
DK
46 /*}}}*/
47// ListParser::NewVersion - Fill in the version structure /*{{{*/
48bool edspListParser::NewVersion(pkgCache::VerIterator &Ver)
49{
50 Ver->ID = Section.FindI("APT-ID", Ver->ID);
51 return debListParser::NewVersion(Ver);
52}
53 /*}}}*/
54// ListParser::Description - Return the description string /*{{{*/
55// ---------------------------------------------------------------------
56/* Sorry, no description for the resolvers… */
8f3ba4e8 57std::string edspListParser::Description()
6d38011b
DK
58{
59 return "";
60}
8f3ba4e8 61std::string edspListParser::DescriptionLanguage()
6d38011b
DK
62{
63 return "";
64}
65MD5SumValue edspListParser::Description_md5()
66{
67 return MD5SumValue("");
68}
69 /*}}}*/
70// ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
71// ---------------------------------------------------------------------
72/* */
73unsigned short edspListParser::VersionHash()
74{
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");
79 return 0;
80}
81 /*}}}*/
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. */
86bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
87 pkgCache::VerIterator &Ver)
88{
9221da7e
DK
89 unsigned long state = 0;
90 if (Section.FindFlag("Hold",state,pkgCache::State::Hold) == false)
6d38011b 91 return false;
9221da7e
DK
92 if (state != 0)
93 Pkg->SelectedState = pkgCache::State::Hold;
6d38011b 94
9221da7e 95 state = 0;
b195733d
DK
96 if (Section.FindFlag("Installed",state,pkgCache::State::Installed) == false)
97 return false;
98 if (state != 0)
6d38011b 99 {
b195733d
DK
100 Pkg->CurrentState = pkgCache::State::Installed;
101 Pkg->CurrentVer = Ver.Index();
6d38011b 102 }
b195733d 103
188a6fcf
DK
104 if (Section.FindB("APT-Automatic", false))
105 {
106 std::string out;
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)
109 return false;
110 }
111
294a8020
DK
112 // FIXME: Using an overriding pin is wrong.
113 if (Section.FindB("APT-Candidate", false))
114 {
115 std::string out;
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)
118 return false;
119 }
120
188a6fcf
DK
121 signed short const pinvalue = Section.FindI("APT-Pin", 500);
122 if (pinvalue != 500)
123 {
124 std::string out;
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)
127 return false;
128 }
129
6d38011b
DK
130 return true;
131}
132 /*}}}*/
133// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
b07aeb1a
DK
134APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*FileI*/,
135 FileFd & /*File*/, std::string const &/*component*/)
6d38011b
DK
136{
137 return true;
138}
139 /*}}}*/
188a6fcf
DK
140edspListParser::~edspListParser() /*{{{*/
141{
142 delete d;
143}
144 /*}}}*/