]> git.saurik.com Git - apt.git/blame - apt-pkg/edsp/edsplistparser.cc
reenable gcc warnings for deprecated functions
[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");
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);
41 }
42};
43 /*}}}*/
6d38011b 44// ListParser::edspListParser - Constructor /*{{{*/
188a6fcf
DK
45edspListParser::edspListParser(FileFd *File) : debListParser(File), d(new edspListParserPrivate())
46{
47}
6d38011b
DK
48 /*}}}*/
49// ListParser::NewVersion - Fill in the version structure /*{{{*/
50bool edspListParser::NewVersion(pkgCache::VerIterator &Ver)
51{
52 Ver->ID = Section.FindI("APT-ID", Ver->ID);
53 return debListParser::NewVersion(Ver);
54}
55 /*}}}*/
56// ListParser::Description - Return the description string /*{{{*/
57// ---------------------------------------------------------------------
58/* Sorry, no description for the resolvers… */
8f3ba4e8 59std::string edspListParser::Description()
6d38011b
DK
60{
61 return "";
62}
8f3ba4e8 63std::string edspListParser::DescriptionLanguage()
6d38011b
DK
64{
65 return "";
66}
67MD5SumValue edspListParser::Description_md5()
68{
69 return MD5SumValue("");
70}
71 /*}}}*/
72// ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
73// ---------------------------------------------------------------------
74/* */
75unsigned short edspListParser::VersionHash()
76{
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");
81 return 0;
82}
83 /*}}}*/
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. */
88bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
89 pkgCache::VerIterator &Ver)
90{
9221da7e
DK
91 unsigned long state = 0;
92 if (Section.FindFlag("Hold",state,pkgCache::State::Hold) == false)
6d38011b 93 return false;
9221da7e
DK
94 if (state != 0)
95 Pkg->SelectedState = pkgCache::State::Hold;
6d38011b 96
9221da7e 97 state = 0;
b195733d
DK
98 if (Section.FindFlag("Installed",state,pkgCache::State::Installed) == false)
99 return false;
100 if (state != 0)
6d38011b 101 {
b195733d
DK
102 Pkg->CurrentState = pkgCache::State::Installed;
103 Pkg->CurrentVer = Ver.Index();
6d38011b 104 }
b195733d 105
188a6fcf
DK
106 if (Section.FindB("APT-Automatic", false))
107 {
108 std::string out;
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)
111 return false;
112 }
113
294a8020
DK
114 // FIXME: Using an overriding pin is wrong.
115 if (Section.FindB("APT-Candidate", false))
116 {
117 std::string out;
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)
120 return false;
121 }
122
188a6fcf
DK
123 signed short const pinvalue = Section.FindI("APT-Pin", 500);
124 if (pinvalue != 500)
125 {
126 std::string out;
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)
129 return false;
130 }
131
6d38011b
DK
132 return true;
133}
134 /*}}}*/
135// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
b07aeb1a
DK
136APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*FileI*/,
137 FileFd & /*File*/, std::string const &/*component*/)
6d38011b
DK
138{
139 return true;
140}
141 /*}}}*/
188a6fcf
DK
142edspListParser::~edspListParser() /*{{{*/
143{
144 delete d;
145}
146 /*}}}*/