]> git.saurik.com Git - apt.git/blame - apt-pkg/deb/debindexfile.cc
* apt-pkg/contrib/error.{cc,h}
[apt.git] / apt-pkg / deb / debindexfile.cc
CommitLineData
b2e465d6
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
7db98ffc 3// $Id: debindexfile.cc,v 1.5.2.3 2004/01/04 19:11:00 mdz Exp $
b2e465d6
AL
4/* ######################################################################
5
6 Debian Specific sources.list types and the three sorts of Debian
7 index files.
8
9 ##################################################################### */
10 /*}}}*/
11// Include Files /*{{{*/
b2e465d6
AL
12#include <apt-pkg/debindexfile.h>
13#include <apt-pkg/debsrcrecords.h>
14#include <apt-pkg/deblistparser.h>
15#include <apt-pkg/debrecords.h>
16#include <apt-pkg/sourcelist.h>
17#include <apt-pkg/configuration.h>
18#include <apt-pkg/progress.h>
19#include <apt-pkg/error.h>
20#include <apt-pkg/strutl.h>
21#include <apt-pkg/acquire-item.h>
7db98ffc 22#include <apt-pkg/debmetaindex.h>
e011829d 23
b2e465d6
AL
24#include <sys/stat.h>
25 /*}}}*/
26
27// SourcesIndex::debSourcesIndex - Constructor /*{{{*/
28// ---------------------------------------------------------------------
29/* */
7db98ffc
MZ
30debSourcesIndex::debSourcesIndex(string URI,string Dist,string Section,bool Trusted) :
31 pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section)
b2e465d6
AL
32{
33}
34 /*}}}*/
35// SourcesIndex::SourceInfo - Short 1 liner describing a source /*{{{*/
36// ---------------------------------------------------------------------
37/* The result looks like:
5e02df82 38 http://foo/debian/ stable/main src 1.1.1 (dsc) */
b2e465d6
AL
39string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
40 pkgSrcRecords::File const &File) const
41{
42 string Res;
5e02df82 43 Res = ::URI::NoUserPassword(URI) + ' ';
b2e465d6
AL
44 if (Dist[Dist.size() - 1] == '/')
45 {
46 if (Dist != "/")
47 Res += Dist;
48 }
49 else
50 Res += Dist + '/' + Section;
51
52 Res += " ";
53 Res += Record.Package();
54 Res += " ";
55 Res += Record.Version();
56 if (File.Type.empty() == false)
57 Res += " (" + File.Type + ")";
58 return Res;
59}
60 /*}}}*/
61// SourcesIndex::CreateSrcParser - Get a parser for the source files /*{{{*/
62// ---------------------------------------------------------------------
63/* */
64pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const
65{
94e8c9d4 66 string SourcesURI = _config->FindDir("Dir::State::lists") +
67 URItoFileName(IndexURI("Sources"));
68 string SourcesURIgzip = SourcesURI + ".gz";
69 if (!FileExists(SourcesURI) && FileExists(SourcesURIgzip))
70 SourcesURI = SourcesURIgzip;
71
72 return new debSrcRecordParser(SourcesURI,this);
b2e465d6
AL
73}
74 /*}}}*/
75// SourcesIndex::Describe - Give a descriptive path to the index /*{{{*/
76// ---------------------------------------------------------------------
77/* */
af87ab54 78string debSourcesIndex::Describe(bool Short) const
b2e465d6
AL
79{
80 char S[300];
af87ab54 81 if (Short == true)
cc742108 82 snprintf(S,sizeof(S),"%s",Info("Sources").c_str());
af87ab54 83 else
cc742108 84 snprintf(S,sizeof(S),"%s (%s)",Info("Sources").c_str(),
af87ab54
AL
85 IndexFile("Sources").c_str());
86
b2e465d6
AL
87 return S;
88}
89 /*}}}*/
90// SourcesIndex::Info - One liner describing the index URI /*{{{*/
91// ---------------------------------------------------------------------
92/* */
93string debSourcesIndex::Info(const char *Type) const
94{
5e02df82 95 string Info = ::URI::NoUserPassword(URI) + ' ';
b2e465d6
AL
96 if (Dist[Dist.size() - 1] == '/')
97 {
98 if (Dist != "/")
99 Info += Dist;
100 }
101 else
102 Info += Dist + '/' + Section;
103 Info += " ";
104 Info += Type;
105 return Info;
106}
107 /*}}}*/
108// SourcesIndex::Index* - Return the URI to the index files /*{{{*/
109// ---------------------------------------------------------------------
110/* */
111inline string debSourcesIndex::IndexFile(const char *Type) const
112{
ec7a129e 113 string s = URItoFileName(IndexURI(Type));
114 string sgzip = s + ".gz";
115 if (!FileExists(s) && FileExists(sgzip))
116 return sgzip;
117 else
118 return s;
b2e465d6 119}
ec7a129e 120
b2e465d6
AL
121string debSourcesIndex::IndexURI(const char *Type) const
122{
123 string Res;
124 if (Dist[Dist.size() - 1] == '/')
125 {
126 if (Dist != "/")
127 Res = URI + Dist;
128 else
129 Res = URI;
130 }
131 else
132 Res = URI + "dists/" + Dist + '/' + Section +
133 "/source/";
134
135 Res += Type;
136 return Res;
137}
138 /*}}}*/
b2e465d6
AL
139// SourcesIndex::Exists - Check if the index is available /*{{{*/
140// ---------------------------------------------------------------------
141/* */
142bool debSourcesIndex::Exists() const
143{
144 return FileExists(IndexFile("Sources"));
145}
146 /*}}}*/
147// SourcesIndex::Size - Return the size of the index /*{{{*/
148// ---------------------------------------------------------------------
149/* */
150unsigned long debSourcesIndex::Size() const
151{
152 struct stat S;
153 if (stat(IndexFile("Sources").c_str(),&S) != 0)
154 return 0;
155 return S.st_size;
156}
157 /*}}}*/
158
159// PackagesIndex::debPackagesIndex - Contructor /*{{{*/
160// ---------------------------------------------------------------------
161/* */
5dd4c8b8
DK
162debPackagesIndex::debPackagesIndex(string const &URI, string const &Dist, string const &Section,
163 bool const &Trusted, string const &Arch) :
164 pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section), Architecture(Arch)
b2e465d6 165{
5dd4c8b8
DK
166 if (Architecture == "native")
167 Architecture = _config->Find("APT::Architecture");
b2e465d6
AL
168}
169 /*}}}*/
170// PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/
171// ---------------------------------------------------------------------
172/* This is a shorter version that is designed to be < 60 chars or so */
173string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
174{
5e02df82 175 string Res = ::URI::NoUserPassword(URI) + ' ';
b2e465d6
AL
176 if (Dist[Dist.size() - 1] == '/')
177 {
178 if (Dist != "/")
179 Res += Dist;
180 }
181 else
182 Res += Dist + '/' + Section;
183
184 Res += " ";
185 Res += Ver.ParentPkg().Name();
186 Res += " ";
dd13742e
DK
187 if (Dist[Dist.size() - 1] != '/')
188 Res.append(Ver.Arch()).append(" ");
b2e465d6
AL
189 Res += Ver.VerStr();
190 return Res;
191}
192 /*}}}*/
193// PackagesIndex::Describe - Give a descriptive path to the index /*{{{*/
194// ---------------------------------------------------------------------
195/* This should help the user find the index in the sources.list and
196 in the filesystem for problem solving */
af87ab54 197string debPackagesIndex::Describe(bool Short) const
b2e465d6
AL
198{
199 char S[300];
af87ab54
AL
200 if (Short == true)
201 snprintf(S,sizeof(S),"%s",Info("Packages").c_str());
202 else
203 snprintf(S,sizeof(S),"%s (%s)",Info("Packages").c_str(),
204 IndexFile("Packages").c_str());
b2e465d6
AL
205 return S;
206}
207 /*}}}*/
208// PackagesIndex::Info - One liner describing the index URI /*{{{*/
209// ---------------------------------------------------------------------
210/* */
211string debPackagesIndex::Info(const char *Type) const
212{
5e02df82 213 string Info = ::URI::NoUserPassword(URI) + ' ';
b2e465d6
AL
214 if (Dist[Dist.size() - 1] == '/')
215 {
216 if (Dist != "/")
217 Info += Dist;
218 }
219 else
220 Info += Dist + '/' + Section;
221 Info += " ";
dd13742e
DK
222 if (Dist[Dist.size() - 1] != '/')
223 Info += Architecture + " ";
b2e465d6
AL
224 Info += Type;
225 return Info;
226}
227 /*}}}*/
228// PackagesIndex::Index* - Return the URI to the index files /*{{{*/
229// ---------------------------------------------------------------------
230/* */
231inline string debPackagesIndex::IndexFile(const char *Type) const
232{
ec7a129e 233 string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
234 string sgzip = s + ".gz";
235 if (!FileExists(s) && FileExists(sgzip))
236 return sgzip;
237 else
238 return s;
b2e465d6
AL
239}
240string debPackagesIndex::IndexURI(const char *Type) const
241{
242 string Res;
243 if (Dist[Dist.size() - 1] == '/')
244 {
245 if (Dist != "/")
246 Res = URI + Dist;
247 else
248 Res = URI;
249 }
250 else
251 Res = URI + "dists/" + Dist + '/' + Section +
5dd4c8b8 252 "/binary-" + Architecture + '/';
b2e465d6
AL
253
254 Res += Type;
255 return Res;
256}
257 /*}}}*/
b2e465d6
AL
258// PackagesIndex::Exists - Check if the index is available /*{{{*/
259// ---------------------------------------------------------------------
260/* */
261bool debPackagesIndex::Exists() const
262{
263 return FileExists(IndexFile("Packages"));
264}
265 /*}}}*/
266// PackagesIndex::Size - Return the size of the index /*{{{*/
267// ---------------------------------------------------------------------
268/* This is really only used for progress reporting. */
269unsigned long debPackagesIndex::Size() const
270{
271 struct stat S;
272 if (stat(IndexFile("Packages").c_str(),&S) != 0)
273 return 0;
274 return S.st_size;
275}
276 /*}}}*/
277// PackagesIndex::Merge - Load the index file into a cache /*{{{*/
278// ---------------------------------------------------------------------
279/* */
2e5f4e45 280bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
b2e465d6
AL
281{
282 string PackageFile = IndexFile("Packages");
c4fc2fd7 283 FileFd Pkg(PackageFile,FileFd::ReadOnlyGzip);
5dd4c8b8 284 debListParser Parser(&Pkg, Architecture);
3184b4cf 285
b2e465d6
AL
286 if (_error->PendingError() == true)
287 return _error->Error("Problem opening %s",PackageFile.c_str());
2e5f4e45
DK
288 if (Prog != NULL)
289 Prog->SubProgress(0,Info("Packages"));
b2e465d6
AL
290 ::URI Tmp(URI);
291 if (Gen.SelectFile(PackageFile,Tmp.Host,*this) == false)
292 return _error->Error("Problem with SelectFile %s",PackageFile.c_str());
293
294 // Store the IMS information
295 pkgCache::PkgFileIterator File = Gen.GetCurFile();
a9fe5928 296 pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(File);
b2e465d6
AL
297 struct stat St;
298 if (fstat(Pkg.Fd(),&St) != 0)
299 return _error->Errno("fstat","Failed to stat");
300 File->Size = St.st_size;
301 File->mtime = St.st_mtime;
302
303 if (Gen.MergeList(Parser) == false)
304 return _error->Error("Problem with MergeList %s",PackageFile.c_str());
305
306 // Check the release file
7db98ffc 307 string ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("Release");
b2e465d6
AL
308 if (FileExists(ReleaseFile) == true)
309 {
310 FileFd Rel(ReleaseFile,FileFd::ReadOnly);
311 if (_error->PendingError() == true)
312 return false;
e011829d 313 Parser.LoadReleaseInfo(File,Rel,Section);
b2e465d6
AL
314 }
315
316 return true;
317}
318 /*}}}*/
319// PackagesIndex::FindInCache - Find this index /*{{{*/
320// ---------------------------------------------------------------------
321/* */
322pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
323{
324 string FileName = IndexFile("Packages");
325 pkgCache::PkgFileIterator File = Cache.FileBegin();
326 for (; File.end() == false; File++)
327 {
f6442c77 328 if (File.FileName() == NULL || FileName != File.FileName())
b2e465d6
AL
329 continue;
330
331 struct stat St;
332 if (stat(File.FileName(),&St) != 0)
c8e572e3
MV
333 {
334 if (_config->FindB("Debug::pkgCacheGen", false))
335 std::clog << "PackagesIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
b2e465d6 336 return pkgCache::PkgFileIterator(Cache);
c8e572e3 337 }
b2e465d6 338 if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
c8e572e3
MV
339 {
340 if (_config->FindB("Debug::pkgCacheGen", false))
341 std::clog << "PackagesIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
342 << ") or mtime (" << St.st_mtime << " <> " << File->mtime
343 << ") doesn't match for " << File.FileName() << std::endl;
b2e465d6 344 return pkgCache::PkgFileIterator(Cache);
c8e572e3 345 }
b2e465d6
AL
346 return File;
347 }
348
349 return File;
350}
351 /*}}}*/
352
a52f938b
OS
353// TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/
354// ---------------------------------------------------------------------
355/* */
45df0ad2
DK
356debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section,
357 char const * const Translation) :
358 pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section),
359 Language(Translation)
360{}
a52f938b
OS
361 /*}}}*/
362// TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
363// ---------------------------------------------------------------------
364/* */
365inline string debTranslationsIndex::IndexFile(const char *Type) const
366{
ec7a129e 367 string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
368 string sgzip = s + ".gz";
369 if (!FileExists(s) && FileExists(sgzip))
370 return sgzip;
371 else
372 return s;
a52f938b
OS
373}
374string debTranslationsIndex::IndexURI(const char *Type) const
375{
376 string Res;
377 if (Dist[Dist.size() - 1] == '/')
378 {
379 if (Dist != "/")
422eeaaa 380 Res = URI + Dist;
a52f938b 381 else
422eeaaa 382 Res = URI;
a52f938b
OS
383 }
384 else
422eeaaa 385 Res = URI + "dists/" + Dist + '/' + Section +
a52f938b
OS
386 "/i18n/Translation-";
387
388 Res += Type;
389 return Res;
390}
391 /*}}}*/
392// TranslationsIndex::GetIndexes - Fetch the index files /*{{{*/
393// ---------------------------------------------------------------------
394/* */
395bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
396{
770c32ec 397 if (TranslationsAvailable()) {
45df0ad2
DK
398 string const TranslationFile = string("Translation-").append(Language);
399 new pkgAcqIndexTrans(Owner, IndexURI(Language),
a52f938b
OS
400 Info(TranslationFile.c_str()),
401 TranslationFile);
402 }
403
404 return true;
405}
406 /*}}}*/
407// TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
408// ---------------------------------------------------------------------
409/* This should help the user find the index in the sources.list and
410 in the filesystem for problem solving */
411string debTranslationsIndex::Describe(bool Short) const
412{
413 char S[300];
414 if (Short == true)
415 snprintf(S,sizeof(S),"%s",Info(TranslationFile().c_str()).c_str());
416 else
417 snprintf(S,sizeof(S),"%s (%s)",Info(TranslationFile().c_str()).c_str(),
45df0ad2 418 IndexFile(Language).c_str());
a52f938b
OS
419 return S;
420}
421 /*}}}*/
422// TranslationsIndex::Info - One liner describing the index URI /*{{{*/
423// ---------------------------------------------------------------------
424/* */
425string debTranslationsIndex::Info(const char *Type) const
426{
5e02df82 427 string Info = ::URI::NoUserPassword(URI) + ' ';
a52f938b
OS
428 if (Dist[Dist.size() - 1] == '/')
429 {
430 if (Dist != "/")
431 Info += Dist;
432 }
433 else
434 Info += Dist + '/' + Section;
435 Info += " ";
436 Info += Type;
437 return Info;
438}
439 /*}}}*/
45df0ad2 440bool debTranslationsIndex::HasPackages() const /*{{{*/
11680bfd 441{
770c32ec 442 if(!TranslationsAvailable())
11680bfd
MV
443 return false;
444
45df0ad2 445 return FileExists(IndexFile(Language));
11680bfd 446}
45df0ad2 447 /*}}}*/
a52f938b
OS
448// TranslationsIndex::Exists - Check if the index is available /*{{{*/
449// ---------------------------------------------------------------------
450/* */
451bool debTranslationsIndex::Exists() const
452{
45df0ad2 453 return FileExists(IndexFile(Language));
a52f938b
OS
454}
455 /*}}}*/
456// TranslationsIndex::Size - Return the size of the index /*{{{*/
457// ---------------------------------------------------------------------
458/* This is really only used for progress reporting. */
459unsigned long debTranslationsIndex::Size() const
460{
461 struct stat S;
45df0ad2 462 if (stat(IndexFile(Language).c_str(),&S) != 0)
a52f938b
OS
463 return 0;
464 return S.st_size;
465}
466 /*}}}*/
467// TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
468// ---------------------------------------------------------------------
469/* */
2e5f4e45 470bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
a52f938b
OS
471{
472 // Check the translation file, if in use
45df0ad2 473 string TranslationFile = IndexFile(Language);
770c32ec 474 if (TranslationsAvailable() && FileExists(TranslationFile))
a52f938b 475 {
c4fc2fd7 476 FileFd Trans(TranslationFile,FileFd::ReadOnlyGzip);
a52f938b
OS
477 debListParser TransParser(&Trans);
478 if (_error->PendingError() == true)
479 return false;
480
2e5f4e45
DK
481 if (Prog != NULL)
482 Prog->SubProgress(0, Info(TranslationFile.c_str()));
a52f938b
OS
483 if (Gen.SelectFile(TranslationFile,string(),*this) == false)
484 return _error->Error("Problem with SelectFile %s",TranslationFile.c_str());
485
486 // Store the IMS information
487 pkgCache::PkgFileIterator TransFile = Gen.GetCurFile();
488 struct stat TransSt;
489 if (fstat(Trans.Fd(),&TransSt) != 0)
490 return _error->Errno("fstat","Failed to stat");
491 TransFile->Size = TransSt.st_size;
492 TransFile->mtime = TransSt.st_mtime;
493
494 if (Gen.MergeList(TransParser) == false)
495 return _error->Error("Problem with MergeList %s",TranslationFile.c_str());
496 }
497
498 return true;
499}
500 /*}}}*/
c51c6f08
OS
501// TranslationsIndex::FindInCache - Find this index /*{{{*/
502// ---------------------------------------------------------------------
503/* */
504pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
505{
45df0ad2 506 string FileName = IndexFile(Language);
4d34acf1 507
c51c6f08 508 pkgCache::PkgFileIterator File = Cache.FileBegin();
f416d22e
MV
509 for (; File.end() == false; File++)
510 {
511 if (FileName != File.FileName())
512 continue;
4d34acf1 513
f416d22e
MV
514 struct stat St;
515 if (stat(File.FileName(),&St) != 0)
c8e572e3
MV
516 {
517 if (_config->FindB("Debug::pkgCacheGen", false))
518 std::clog << "TranslationIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
f416d22e 519 return pkgCache::PkgFileIterator(Cache);
c8e572e3 520 }
f416d22e 521 if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
c8e572e3
MV
522 {
523 if (_config->FindB("Debug::pkgCacheGen", false))
524 std::clog << "TranslationIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
525 << ") or mtime (" << St.st_mtime << " <> " << File->mtime
526 << ") doesn't match for " << File.FileName() << std::endl;
f416d22e 527 return pkgCache::PkgFileIterator(Cache);
c8e572e3 528 }
f416d22e
MV
529 return File;
530 }
c51c6f08
OS
531 return File;
532}
533 /*}}}*/
b2e465d6
AL
534// StatusIndex::debStatusIndex - Constructor /*{{{*/
535// ---------------------------------------------------------------------
536/* */
7db98ffc 537debStatusIndex::debStatusIndex(string File) : pkgIndexFile(true), File(File)
b2e465d6
AL
538{
539}
540 /*}}}*/
541// StatusIndex::Size - Return the size of the index /*{{{*/
542// ---------------------------------------------------------------------
543/* */
544unsigned long debStatusIndex::Size() const
545{
546 struct stat S;
547 if (stat(File.c_str(),&S) != 0)
548 return 0;
549 return S.st_size;
550}
551 /*}}}*/
552// StatusIndex::Merge - Load the index file into a cache /*{{{*/
553// ---------------------------------------------------------------------
554/* */
2e5f4e45 555bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
b2e465d6 556{
c4fc2fd7 557 FileFd Pkg(File,FileFd::ReadOnlyGzip);
b2e465d6
AL
558 if (_error->PendingError() == true)
559 return false;
560 debListParser Parser(&Pkg);
561 if (_error->PendingError() == true)
562 return false;
2e5f4e45
DK
563
564 if (Prog != NULL)
565 Prog->SubProgress(0,File);
b2e465d6
AL
566 if (Gen.SelectFile(File,string(),*this,pkgCache::Flag::NotSource) == false)
567 return _error->Error("Problem with SelectFile %s",File.c_str());
568
569 // Store the IMS information
570 pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
571 struct stat St;
572 if (fstat(Pkg.Fd(),&St) != 0)
573 return _error->Errno("fstat","Failed to stat");
574 CFile->Size = St.st_size;
575 CFile->mtime = St.st_mtime;
576 CFile->Archive = Gen.WriteUniqString("now");
577
578 if (Gen.MergeList(Parser) == false)
579 return _error->Error("Problem with MergeList %s",File.c_str());
580 return true;
581}
582 /*}}}*/
583// StatusIndex::FindInCache - Find this index /*{{{*/
584// ---------------------------------------------------------------------
585/* */
586pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
587{
588 pkgCache::PkgFileIterator File = Cache.FileBegin();
589 for (; File.end() == false; File++)
590 {
591 if (this->File != File.FileName())
592 continue;
593
594 struct stat St;
595 if (stat(File.FileName(),&St) != 0)
c8e572e3
MV
596 {
597 if (_config->FindB("Debug::pkgCacheGen", false))
598 std::clog << "StatusIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
b2e465d6 599 return pkgCache::PkgFileIterator(Cache);
c8e572e3 600 }
b2e465d6 601 if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
c8e572e3
MV
602 {
603 if (_config->FindB("Debug::pkgCacheGen", false))
604 std::clog << "StatusIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
605 << ") or mtime (" << St.st_mtime << " <> " << File->mtime
606 << ") doesn't match for " << File.FileName() << std::endl;
b2e465d6 607 return pkgCache::PkgFileIterator(Cache);
c8e572e3 608 }
b2e465d6
AL
609 return File;
610 }
611 return File;
612}
613 /*}}}*/
614// StatusIndex::Exists - Check if the index is available /*{{{*/
615// ---------------------------------------------------------------------
616/* */
617bool debStatusIndex::Exists() const
618{
619 // Abort if the file does not exist.
620 return true;
621}
622 /*}}}*/
623
b2e465d6
AL
624// Index File types for Debian /*{{{*/
625class debIFTypeSrc : public pkgIndexFile::Type
626{
627 public:
628
629 debIFTypeSrc() {Label = "Debian Source Index";};
630};
631class debIFTypePkg : public pkgIndexFile::Type
632{
633 public:
634
635 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
636 {
637 return new debRecordParser(File.FileName(),*File.Cache());
638 };
639 debIFTypePkg() {Label = "Debian Package Index";};
640};
97234432
MV
641class debIFTypeTrans : public debIFTypePkg
642{
643 public:
644 debIFTypeTrans() {Label = "Debian Translation Index";};
645};
b2e465d6
AL
646class debIFTypeStatus : public pkgIndexFile::Type
647{
648 public:
649
650 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
651 {
652 return new debRecordParser(File.FileName(),*File.Cache());
653 };
654 debIFTypeStatus() {Label = "Debian dpkg status file";};
655};
656static debIFTypeSrc _apt_Src;
657static debIFTypePkg _apt_Pkg;
97234432 658static debIFTypeTrans _apt_Trans;
b2e465d6
AL
659static debIFTypeStatus _apt_Status;
660
661const pkgIndexFile::Type *debSourcesIndex::GetType() const
662{
663 return &_apt_Src;
664}
665const pkgIndexFile::Type *debPackagesIndex::GetType() const
666{
667 return &_apt_Pkg;
668}
a52f938b
OS
669const pkgIndexFile::Type *debTranslationsIndex::GetType() const
670{
97234432 671 return &_apt_Trans;
a52f938b 672}
b2e465d6
AL
673const pkgIndexFile::Type *debStatusIndex::GetType() const
674{
675 return &_apt_Status;
676}
677
678 /*}}}*/