~jr/ubuntu/oneiric/apt/bzr-get-rename

« back to all changes in this revision

Viewing changes to apt-pkg/sourcelist.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2005-03-07 20:08:33 UTC
  • Revision ID: james.westby@ubuntu.com-20050307200833-0lxdgg2cb4oculdv
Tags: 0.6.35
* Merge apt--mvo--0 (incorporates 0.6.34ubuntu1):
  - Implement MaxSize and MaxAge in apt.cron.daily, to prevent the cache
    from growing too large (Ubuntu #6761)
  - some comments about the pkgAcqMetaSig::Custom600Headers() added
  - use gpg --with-colons
  - commented the ftp no_proxy unseting in methods/ftp.cc
  - added support for "Acquire::gpgv::options" in methods/gpgv.cc
* Merge bubulle@debian.org--2005/apt--main--0
  - Make capitalization more consistent
  - Un-fuzzy translations resulting from capitalization changes
  - Italian translation update

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
/* ######################################################################
5
5
 
6
6
   List of Sources
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>
20
20
 
21
21
#include <apti18n.h>
22
22
 
23
 
#include <fstream.h>
 
23
#include <fstream>
24
24
                                                                        /*}}}*/
25
25
 
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,
78
 
                                    Vendor const *Vendor,
 
77
bool pkgSourceList::Type::ParseLine(vector<metaIndex *> &List,
79
78
                                    const char *Buffer,
80
79
                                    unsigned long CurLine,
81
80
                                    string File) const
96
95
   if (Dist.empty() == false && Dist[Dist.size() - 1] == '/')
97
96
   {
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);
102
101
   }
103
102
   
104
103
   // Grab the rest of the dists
107
106
   
108
107
   do
109
108
   {
110
 
      if (CreateItem(List,URI,Dist,Section,Vendor) == false)
 
109
      if (CreateItem(List,URI,Dist,Section) == false)
111
110
         return false;
112
111
   }
113
112
   while (ParseQuoteWord(Buffer,Section) == true);
128
127
   Read(File);
129
128
}
130
129
                                                                        /*}}}*/
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()
 
132
/* */
 
133
pkgSourceList::~pkgSourceList()
138
134
{
139
 
   Configuration Cnf;
140
 
 
141
 
   string CnfFile = _config->FindDir("Dir::Etc::vendorparts");
142
 
   if (FileExists(CnfFile) == true)
143
 
      if (ReadConfigDir(Cnf,CnfFile,true) == false)
144
 
         return false;
145
 
   CnfFile = _config->FindFile("Dir::Etc::vendorlist");
146
 
   if (FileExists(CnfFile) == true)
147
 
      if (ReadConfigFile(Cnf,CnfFile,true) == false)
148
 
         return false;
149
 
 
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)
153
 
   {
154
 
      Configuration Block(Top);
155
 
      Vendor *Vendor;
156
 
      
157
 
      Vendor = new pkgSourceList::Vendor;
158
 
      
159
 
      Vendor->VendorID = Top->Tag;
160
 
      Vendor->FingerPrint = Block.Find("Fingerprint");
161
 
      Vendor->Description = Block.Find("Name");
162
 
      
163
 
      if (Vendor->FingerPrint.empty() == true || 
164
 
          Vendor->Description.empty() == true)
165
 
      {
166
 
         _error->Error(_("Vendor block %s is invalid"), Vendor->VendorID.c_str());
167
 
         delete Vendor;
168
 
         continue;
169
 
      }
170
 
      
171
 
      VendorList.push_back(Vendor);
172
 
   }
173
 
 
174
 
   return !_error->PendingError();
 
135
   for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
 
136
      delete *I;
175
137
}
176
138
                                                                        /*}}}*/
 
139
                                                                        /*}}}*/
177
140
// SourceList::ReadMainList - Read the main source list from etc        /*{{{*/
178
141
// ---------------------------------------------------------------------
179
142
/* */
180
143
bool pkgSourceList::ReadMainList()
181
144
{
182
 
   return ReadVendors() && Read(_config->FindFile("Dir::Etc::sourcelist"));
 
145
   return Read(_config->FindFile("Dir::Etc::sourcelist"));
183
146
}
184
147
                                                                        /*}}}*/
185
148
// SourceList::Read - Parse the sourcelist file                         /*{{{*/
192
155
   if (!F != 0)
193
156
      return _error->Errno("ifstream::ifstream",_("Opening %s"),File.c_str());
194
157
   
 
158
   for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
 
159
      delete *I;
195
160
   SrcList.erase(SrcList.begin(),SrcList.end());
196
161
   char Buffer[300];
197
162
 
201
166
      F.getline(Buffer,sizeof(Buffer));
202
167
      CurLine++;
203
168
      _strtabexpand(Buffer,sizeof(Buffer));
204
 
      
 
169
      if (F.fail() && !F.eof())
 
170
         return _error->Error(_("Line %u too long in source list %s."),
 
171
                              CurLine,File.c_str());
 
172
 
205
173
      
206
174
      char *I;
207
175
      for (I = Buffer; *I != 0 && *I != '#'; I++);
220
188
 
221
189
      Type *Parse = Type::GetType(LineType.c_str());
222
190
      if (Parse == 0)
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());
224
192
      
225
 
      // Authenticated repository
226
 
      Vendor const *Vndr = 0;
 
193
      // Vendor name specified
227
194
      if (C[0] == '[')
228
195
      {
229
196
         string VendorID;
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);
237
204
         
238
 
         for (vector<Vendor const *>::const_iterator iter = VendorList.begin();
239
 
              iter != VendorList.end(); iter++) 
240
 
         {
241
 
            if ((*iter)->VendorID == VendorID)
242
 
            {
243
 
               Vndr = *iter;
244
 
               break;
245
 
            }
246
 
         }
 
205
//       for (vector<const Vendor *>::const_iterator iter = VendorList.begin();
 
206
//            iter != VendorList.end(); iter++) 
 
207
//       {
 
208
//          if ((*iter)->GetVendorID() == VendorID)
 
209
//          {
 
210
//            if (_config->FindB("Debug::sourceList", false)) 
 
211
//              std::cerr << "Comparing VendorID \"" << VendorID << "\" with \"" << (*iter)->GetVendorID() << '"' << std::endl;
 
212
//             Verifier = *iter;
 
213
//             break;
 
214
//          }
 
215
//       }
247
216
 
248
 
         if (Vndr == 0)
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());
251
220
      }
252
 
      
253
 
      if (Parse->ParseLine(SrcList,Vndr,C,CurLine,File) == false)
 
221
 
 
222
      if (Parse->ParseLine(SrcList,C,CurLine,File) == false)
254
223
         return false;
255
224
   }
256
225
   return true;
264
233
{
265
234
   for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
266
235
   {
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++)
268
239
      {
269
 
         Found = *I;
270
 
         return true;
 
240
         if ((*J)->FindInCache(*File.Cache()) == File)
 
241
         {
 
242
            Found = (*J);
 
243
            return true;
 
244
         }
271
245
      }
272
246
   }
273
 
   
 
247
 
274
248
   return false;
275
249
}
276
250
                                                                        /*}}}*/
277
251
// SourceList::GetIndexes - Load the index files into the downloader    /*{{{*/
278
252
// ---------------------------------------------------------------------
279
253
/* */
280
 
bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const
 
254
bool pkgSourceList::GetIndexes(pkgAcquire *Owner, bool GetAll) const
281
255
{
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)
284
258
         return false;
285
259
   return true;
286
260
}