1
1
// -*- mode: cpp; mode: fold -*-
2
2
// Description /*{{{*/
3
// $Id: sourcelist.cc,v 1.20 2001/05/15 05:46:11 jgg Exp $
3
// $Id: sourcelist.cc,v 1.25 2004/06/07 23:08:00 mdz Exp $
4
4
/* ######################################################################
15
15
#include <apt-pkg/sourcelist.h>
16
16
#include <apt-pkg/error.h>
17
17
#include <apt-pkg/fileutl.h>
18
#include <apt-pkg/strutl.h>
18
19
#include <apt-pkg/configuration.h>
19
#include <apt-pkg/strutl.h>
21
21
#include <apti18n.h>
26
26
using namespace std;
74
74
// ---------------------------------------------------------------------
75
75
/* This is a generic one that is the 'usual' format for sources.list
76
76
Weird types may override this. */
77
bool pkgSourceList::Type::ParseLine(vector<pkgIndexFile *> &List,
77
bool pkgSourceList::Type::ParseLine(vector<metaIndex *> &List,
79
78
const char *Buffer,
80
79
unsigned long CurLine,
96
95
if (Dist.empty() == false && Dist[Dist.size() - 1] == '/')
98
97
if (ParseQuoteWord(Buffer,Section) == true)
99
return _error->Error(_("Malformed line %lu in source list %s (Absolute dist)"),CurLine,File.c_str());
98
return _error->Error(_("Malformed line %lu in source list %s (absolute dist)"),CurLine,File.c_str());
100
99
Dist = SubstVar(Dist,"$(ARCH)",_config->Find("APT::Architecture"));
101
return CreateItem(List,URI,Dist,Section,Vendor);
100
return CreateItem(List,URI,Dist,Section);
104
103
// Grab the rest of the dists
110
if (CreateItem(List,URI,Dist,Section,Vendor) == false)
109
if (CreateItem(List,URI,Dist,Section) == false)
113
112
while (ParseQuoteWord(Buffer,Section) == true);
131
// SourceList::ReadVendors - Read list of known package vendors /*{{{*/
130
// SourceList::~pkgSourceList - Destructor /*{{{*/
132
131
// ---------------------------------------------------------------------
133
/* This also scans a directory of vendor files similar to apt.conf.d
134
which can contain the usual suspects of distribution provided data.
135
The APT config mechanism allows the user to override these in their
136
configuration file. */
137
bool pkgSourceList::ReadVendors()
133
pkgSourceList::~pkgSourceList()
141
string CnfFile = _config->FindDir("Dir::Etc::vendorparts");
142
if (FileExists(CnfFile) == true)
143
if (ReadConfigDir(Cnf,CnfFile,true) == false)
145
CnfFile = _config->FindFile("Dir::Etc::vendorlist");
146
if (FileExists(CnfFile) == true)
147
if (ReadConfigFile(Cnf,CnfFile,true) == false)
150
// Process 'simple-key' type sections
151
const Configuration::Item *Top = Cnf.Tree("simple-key");
152
for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next)
154
Configuration Block(Top);
157
Vendor = new pkgSourceList::Vendor;
159
Vendor->VendorID = Top->Tag;
160
Vendor->FingerPrint = Block.Find("Fingerprint");
161
Vendor->Description = Block.Find("Name");
163
if (Vendor->FingerPrint.empty() == true ||
164
Vendor->Description.empty() == true)
166
_error->Error(_("Vendor block %s is invalid"), Vendor->VendorID.c_str());
171
VendorList.push_back(Vendor);
174
return !_error->PendingError();
135
for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
177
140
// SourceList::ReadMainList - Read the main source list from etc /*{{{*/
178
141
// ---------------------------------------------------------------------
180
143
bool pkgSourceList::ReadMainList()
182
return ReadVendors() && Read(_config->FindFile("Dir::Etc::sourcelist"));
145
return Read(_config->FindFile("Dir::Etc::sourcelist"));
185
148
// SourceList::Read - Parse the sourcelist file /*{{{*/
193
156
return _error->Errno("ifstream::ifstream",_("Opening %s"),File.c_str());
158
for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
195
160
SrcList.erase(SrcList.begin(),SrcList.end());
196
161
char Buffer[300];
201
166
F.getline(Buffer,sizeof(Buffer));
203
168
_strtabexpand(Buffer,sizeof(Buffer));
169
if (F.fail() && !F.eof())
170
return _error->Error(_("Line %u too long in source list %s."),
171
CurLine,File.c_str());
207
175
for (I = Buffer; *I != 0 && *I != '#'; I++);
221
189
Type *Parse = Type::GetType(LineType.c_str());
223
return _error->Error(_("Type '%s' is not known in on line %u in source list %s"),LineType.c_str(),CurLine,File.c_str());
191
return _error->Error(_("Type '%s' is not known on line %u in source list %s"),LineType.c_str(),CurLine,File.c_str());
225
// Authenticated repository
226
Vendor const *Vndr = 0;
193
// Vendor name specified
235
202
return _error->Error(_("Malformed line %u in source list %s (vendor id)"),CurLine,File.c_str());
236
203
VendorID = string(VendorID,1,VendorID.size()-2);
238
for (vector<Vendor const *>::const_iterator iter = VendorList.begin();
239
iter != VendorList.end(); iter++)
241
if ((*iter)->VendorID == VendorID)
205
// for (vector<const Vendor *>::const_iterator iter = VendorList.begin();
206
// iter != VendorList.end(); iter++)
208
// if ((*iter)->GetVendorID() == VendorID)
210
// if (_config->FindB("Debug::sourceList", false))
211
// std::cerr << "Comparing VendorID \"" << VendorID << "\" with \"" << (*iter)->GetVendorID() << '"' << std::endl;
249
return _error->Error(_("Unknown vendor ID '%s' in line %u of source list %s"),
250
VendorID.c_str(),CurLine,File.c_str());
217
// if (Verifier == 0)
218
// return _error->Error(_("Unknown vendor ID '%s' in line %u of source list %s"),
219
// VendorID.c_str(),CurLine,File.c_str());
253
if (Parse->ParseLine(SrcList,Vndr,C,CurLine,File) == false)
222
if (Parse->ParseLine(SrcList,C,CurLine,File) == false)
265
234
for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
267
if ((*I)->FindInCache(*File.Cache()) == File)
236
vector<pkgIndexFile *> *Indexes = (*I)->GetIndexFiles();
237
for (vector<pkgIndexFile *>::const_iterator J = Indexes->begin();
238
J != Indexes->end(); J++)
240
if ((*J)->FindInCache(*File.Cache()) == File)
277
251
// SourceList::GetIndexes - Load the index files into the downloader /*{{{*/
278
252
// ---------------------------------------------------------------------
280
bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const
254
bool pkgSourceList::GetIndexes(pkgAcquire *Owner, bool GetAll) const
282
256
for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
283
if ((*I)->GetIndexes(Owner) == false)
257
if ((*I)->GetIndexes(Owner,GetAll) == false)