merged from http://code.launchpad.net/~donkult/apt/sid
[ntk/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{
5473df3f
MP
152 FileFd f = FileFd (IndexFile("Sources"), FileFd::ReadOnlyGzip);
153
154 if (f.Failed())
b2e465d6 155 return 0;
5473df3f 156 return f.Size();
b2e465d6
AL
157}
158 /*}}}*/
159
160// PackagesIndex::debPackagesIndex - Contructor /*{{{*/
161// ---------------------------------------------------------------------
162/* */
5dd4c8b8
DK
163debPackagesIndex::debPackagesIndex(string const &URI, string const &Dist, string const &Section,
164 bool const &Trusted, string const &Arch) :
165 pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section), Architecture(Arch)
b2e465d6 166{
5dd4c8b8
DK
167 if (Architecture == "native")
168 Architecture = _config->Find("APT::Architecture");
b2e465d6
AL
169}
170 /*}}}*/
171// PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/
172// ---------------------------------------------------------------------
173/* This is a shorter version that is designed to be < 60 chars or so */
174string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
175{
5e02df82 176 string Res = ::URI::NoUserPassword(URI) + ' ';
b2e465d6
AL
177 if (Dist[Dist.size() - 1] == '/')
178 {
179 if (Dist != "/")
180 Res += Dist;
181 }
182 else
183 Res += Dist + '/' + Section;
184
185 Res += " ";
186 Res += Ver.ParentPkg().Name();
187 Res += " ";
dd13742e
DK
188 if (Dist[Dist.size() - 1] != '/')
189 Res.append(Ver.Arch()).append(" ");
b2e465d6
AL
190 Res += Ver.VerStr();
191 return Res;
192}
193 /*}}}*/
194// PackagesIndex::Describe - Give a descriptive path to the index /*{{{*/
195// ---------------------------------------------------------------------
196/* This should help the user find the index in the sources.list and
197 in the filesystem for problem solving */
af87ab54 198string debPackagesIndex::Describe(bool Short) const
b2e465d6
AL
199{
200 char S[300];
af87ab54
AL
201 if (Short == true)
202 snprintf(S,sizeof(S),"%s",Info("Packages").c_str());
203 else
204 snprintf(S,sizeof(S),"%s (%s)",Info("Packages").c_str(),
205 IndexFile("Packages").c_str());
b2e465d6
AL
206 return S;
207}
208 /*}}}*/
209// PackagesIndex::Info - One liner describing the index URI /*{{{*/
210// ---------------------------------------------------------------------
211/* */
212string debPackagesIndex::Info(const char *Type) const
213{
5e02df82 214 string Info = ::URI::NoUserPassword(URI) + ' ';
b2e465d6
AL
215 if (Dist[Dist.size() - 1] == '/')
216 {
217 if (Dist != "/")
218 Info += Dist;
219 }
220 else
221 Info += Dist + '/' + Section;
222 Info += " ";
dd13742e
DK
223 if (Dist[Dist.size() - 1] != '/')
224 Info += Architecture + " ";
b2e465d6
AL
225 Info += Type;
226 return Info;
227}
228 /*}}}*/
229// PackagesIndex::Index* - Return the URI to the index files /*{{{*/
230// ---------------------------------------------------------------------
231/* */
232inline string debPackagesIndex::IndexFile(const char *Type) const
233{
ec7a129e 234 string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
235 string sgzip = s + ".gz";
236 if (!FileExists(s) && FileExists(sgzip))
237 return sgzip;
238 else
239 return s;
b2e465d6
AL
240}
241string debPackagesIndex::IndexURI(const char *Type) const
242{
243 string Res;
244 if (Dist[Dist.size() - 1] == '/')
245 {
246 if (Dist != "/")
247 Res = URI + Dist;
248 else
249 Res = URI;
250 }
251 else
252 Res = URI + "dists/" + Dist + '/' + Section +
5dd4c8b8 253 "/binary-" + Architecture + '/';
b2e465d6
AL
254
255 Res += Type;
256 return Res;
257}
258 /*}}}*/
b2e465d6
AL
259// PackagesIndex::Exists - Check if the index is available /*{{{*/
260// ---------------------------------------------------------------------
261/* */
262bool debPackagesIndex::Exists() const
263{
264 return FileExists(IndexFile("Packages"));
265}
266 /*}}}*/
267// PackagesIndex::Size - Return the size of the index /*{{{*/
268// ---------------------------------------------------------------------
269/* This is really only used for progress reporting. */
270unsigned long debPackagesIndex::Size() const
271{
5473df3f
MP
272 FileFd f = FileFd (IndexFile("Packages"), FileFd::ReadOnlyGzip);
273
274 if (f.Failed())
b2e465d6 275 return 0;
5473df3f 276 return f.Size();
b2e465d6
AL
277}
278 /*}}}*/
279// PackagesIndex::Merge - Load the index file into a cache /*{{{*/
280// ---------------------------------------------------------------------
281/* */
2e5f4e45 282bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
b2e465d6
AL
283{
284 string PackageFile = IndexFile("Packages");
c4fc2fd7 285 FileFd Pkg(PackageFile,FileFd::ReadOnlyGzip);
5dd4c8b8 286 debListParser Parser(&Pkg, Architecture);
3184b4cf 287
b2e465d6
AL
288 if (_error->PendingError() == true)
289 return _error->Error("Problem opening %s",PackageFile.c_str());
2e5f4e45
DK
290 if (Prog != NULL)
291 Prog->SubProgress(0,Info("Packages"));
b2e465d6
AL
292 ::URI Tmp(URI);
293 if (Gen.SelectFile(PackageFile,Tmp.Host,*this) == false)
294 return _error->Error("Problem with SelectFile %s",PackageFile.c_str());
295
296 // Store the IMS information
297 pkgCache::PkgFileIterator File = Gen.GetCurFile();
a9fe5928 298 pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(File);
b2e465d6
AL
299 struct stat St;
300 if (fstat(Pkg.Fd(),&St) != 0)
301 return _error->Errno("fstat","Failed to stat");
302 File->Size = St.st_size;
303 File->mtime = St.st_mtime;
304
305 if (Gen.MergeList(Parser) == false)
306 return _error->Error("Problem with MergeList %s",PackageFile.c_str());
307
308 // Check the release file
7db98ffc 309 string ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("Release");
b2e465d6
AL
310 if (FileExists(ReleaseFile) == true)
311 {
312 FileFd Rel(ReleaseFile,FileFd::ReadOnly);
313 if (_error->PendingError() == true)
314 return false;
e011829d 315 Parser.LoadReleaseInfo(File,Rel,Section);
b2e465d6
AL
316 }
317
318 return true;
319}
320 /*}}}*/
321// PackagesIndex::FindInCache - Find this index /*{{{*/
322// ---------------------------------------------------------------------
323/* */
324pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
325{
326 string FileName = IndexFile("Packages");
327 pkgCache::PkgFileIterator File = Cache.FileBegin();
328 for (; File.end() == false; File++)
329 {
f6442c77 330 if (File.FileName() == NULL || FileName != File.FileName())
b2e465d6
AL
331 continue;
332
333 struct stat St;
334 if (stat(File.FileName(),&St) != 0)
c8e572e3
MV
335 {
336 if (_config->FindB("Debug::pkgCacheGen", false))
337 std::clog << "PackagesIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
b2e465d6 338 return pkgCache::PkgFileIterator(Cache);
c8e572e3 339 }
b2e465d6 340 if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
c8e572e3
MV
341 {
342 if (_config->FindB("Debug::pkgCacheGen", false))
343 std::clog << "PackagesIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
344 << ") or mtime (" << St.st_mtime << " <> " << File->mtime
345 << ") doesn't match for " << File.FileName() << std::endl;
b2e465d6 346 return pkgCache::PkgFileIterator(Cache);
c8e572e3 347 }
b2e465d6
AL
348 return File;
349 }
350
351 return File;
352}
353 /*}}}*/
354
a52f938b
OS
355// TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/
356// ---------------------------------------------------------------------
357/* */
45df0ad2
DK
358debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section,
359 char const * const Translation) :
360 pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section),
361 Language(Translation)
362{}
a52f938b
OS
363 /*}}}*/
364// TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
365// ---------------------------------------------------------------------
366/* */
367inline string debTranslationsIndex::IndexFile(const char *Type) const
368{
ec7a129e 369 string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
370 string sgzip = s + ".gz";
371 if (!FileExists(s) && FileExists(sgzip))
372 return sgzip;
373 else
374 return s;
a52f938b
OS
375}
376string debTranslationsIndex::IndexURI(const char *Type) const
377{
378 string Res;
379 if (Dist[Dist.size() - 1] == '/')
380 {
381 if (Dist != "/")
422eeaaa 382 Res = URI + Dist;
a52f938b 383 else
422eeaaa 384 Res = URI;
a52f938b
OS
385 }
386 else
422eeaaa 387 Res = URI + "dists/" + Dist + '/' + Section +
a52f938b
OS
388 "/i18n/Translation-";
389
390 Res += Type;
391 return Res;
392}
393 /*}}}*/
394// TranslationsIndex::GetIndexes - Fetch the index files /*{{{*/
395// ---------------------------------------------------------------------
396/* */
397bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
398{
770c32ec 399 if (TranslationsAvailable()) {
45df0ad2
DK
400 string const TranslationFile = string("Translation-").append(Language);
401 new pkgAcqIndexTrans(Owner, IndexURI(Language),
a52f938b
OS
402 Info(TranslationFile.c_str()),
403 TranslationFile);
404 }
405
406 return true;
407}
408 /*}}}*/
409// TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
410// ---------------------------------------------------------------------
411/* This should help the user find the index in the sources.list and
412 in the filesystem for problem solving */
413string debTranslationsIndex::Describe(bool Short) const
414{
415 char S[300];
416 if (Short == true)
417 snprintf(S,sizeof(S),"%s",Info(TranslationFile().c_str()).c_str());
418 else
419 snprintf(S,sizeof(S),"%s (%s)",Info(TranslationFile().c_str()).c_str(),
45df0ad2 420 IndexFile(Language).c_str());
a52f938b
OS
421 return S;
422}
423 /*}}}*/
424// TranslationsIndex::Info - One liner describing the index URI /*{{{*/
425// ---------------------------------------------------------------------
426/* */
427string debTranslationsIndex::Info(const char *Type) const
428{
5e02df82 429 string Info = ::URI::NoUserPassword(URI) + ' ';
a52f938b
OS
430 if (Dist[Dist.size() - 1] == '/')
431 {
432 if (Dist != "/")
433 Info += Dist;
434 }
435 else
436 Info += Dist + '/' + Section;
437 Info += " ";
438 Info += Type;
439 return Info;
440}
441 /*}}}*/
45df0ad2 442bool debTranslationsIndex::HasPackages() const /*{{{*/
11680bfd 443{
770c32ec 444 if(!TranslationsAvailable())
11680bfd
MV
445 return false;
446
45df0ad2 447 return FileExists(IndexFile(Language));
11680bfd 448}
45df0ad2 449 /*}}}*/
a52f938b
OS
450// TranslationsIndex::Exists - Check if the index is available /*{{{*/
451// ---------------------------------------------------------------------
452/* */
453bool debTranslationsIndex::Exists() const
454{
45df0ad2 455 return FileExists(IndexFile(Language));
a52f938b
OS
456}
457 /*}}}*/
458// TranslationsIndex::Size - Return the size of the index /*{{{*/
459// ---------------------------------------------------------------------
460/* This is really only used for progress reporting. */
461unsigned long debTranslationsIndex::Size() const
462{
5473df3f
MP
463 FileFd f = FileFd (IndexFile(Language), FileFd::ReadOnlyGzip);
464
465 if (f.Failed())
a52f938b 466 return 0;
5473df3f
MP
467
468 return f.Size();
a52f938b
OS
469}
470 /*}}}*/
471// TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
472// ---------------------------------------------------------------------
473/* */
2e5f4e45 474bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
a52f938b
OS
475{
476 // Check the translation file, if in use
45df0ad2 477 string TranslationFile = IndexFile(Language);
770c32ec 478 if (TranslationsAvailable() && FileExists(TranslationFile))
a52f938b 479 {
c4fc2fd7 480 FileFd Trans(TranslationFile,FileFd::ReadOnlyGzip);
a52f938b
OS
481 debListParser TransParser(&Trans);
482 if (_error->PendingError() == true)
483 return false;
484
2e5f4e45
DK
485 if (Prog != NULL)
486 Prog->SubProgress(0, Info(TranslationFile.c_str()));
a52f938b
OS
487 if (Gen.SelectFile(TranslationFile,string(),*this) == false)
488 return _error->Error("Problem with SelectFile %s",TranslationFile.c_str());
489
490 // Store the IMS information
491 pkgCache::PkgFileIterator TransFile = Gen.GetCurFile();
492 struct stat TransSt;
493 if (fstat(Trans.Fd(),&TransSt) != 0)
494 return _error->Errno("fstat","Failed to stat");
495 TransFile->Size = TransSt.st_size;
496 TransFile->mtime = TransSt.st_mtime;
497
498 if (Gen.MergeList(TransParser) == false)
499 return _error->Error("Problem with MergeList %s",TranslationFile.c_str());
500 }
501
502 return true;
503}
504 /*}}}*/
c51c6f08
OS
505// TranslationsIndex::FindInCache - Find this index /*{{{*/
506// ---------------------------------------------------------------------
507/* */
508pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
509{
45df0ad2 510 string FileName = IndexFile(Language);
4d34acf1 511
c51c6f08 512 pkgCache::PkgFileIterator File = Cache.FileBegin();
f416d22e
MV
513 for (; File.end() == false; File++)
514 {
515 if (FileName != File.FileName())
516 continue;
4d34acf1 517
f416d22e
MV
518 struct stat St;
519 if (stat(File.FileName(),&St) != 0)
c8e572e3
MV
520 {
521 if (_config->FindB("Debug::pkgCacheGen", false))
522 std::clog << "TranslationIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
f416d22e 523 return pkgCache::PkgFileIterator(Cache);
c8e572e3 524 }
f416d22e 525 if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
c8e572e3
MV
526 {
527 if (_config->FindB("Debug::pkgCacheGen", false))
528 std::clog << "TranslationIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
529 << ") or mtime (" << St.st_mtime << " <> " << File->mtime
530 << ") doesn't match for " << File.FileName() << std::endl;
f416d22e 531 return pkgCache::PkgFileIterator(Cache);
c8e572e3 532 }
f416d22e
MV
533 return File;
534 }
c51c6f08
OS
535 return File;
536}
537 /*}}}*/
b2e465d6
AL
538// StatusIndex::debStatusIndex - Constructor /*{{{*/
539// ---------------------------------------------------------------------
540/* */
7db98ffc 541debStatusIndex::debStatusIndex(string File) : pkgIndexFile(true), File(File)
b2e465d6
AL
542{
543}
544 /*}}}*/
545// StatusIndex::Size - Return the size of the index /*{{{*/
546// ---------------------------------------------------------------------
547/* */
548unsigned long debStatusIndex::Size() const
549{
550 struct stat S;
551 if (stat(File.c_str(),&S) != 0)
552 return 0;
553 return S.st_size;
554}
555 /*}}}*/
556// StatusIndex::Merge - Load the index file into a cache /*{{{*/
557// ---------------------------------------------------------------------
558/* */
2e5f4e45 559bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
b2e465d6 560{
c4fc2fd7 561 FileFd Pkg(File,FileFd::ReadOnlyGzip);
b2e465d6
AL
562 if (_error->PendingError() == true)
563 return false;
564 debListParser Parser(&Pkg);
565 if (_error->PendingError() == true)
566 return false;
2e5f4e45
DK
567
568 if (Prog != NULL)
569 Prog->SubProgress(0,File);
b2e465d6
AL
570 if (Gen.SelectFile(File,string(),*this,pkgCache::Flag::NotSource) == false)
571 return _error->Error("Problem with SelectFile %s",File.c_str());
572
573 // Store the IMS information
574 pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
575 struct stat St;
576 if (fstat(Pkg.Fd(),&St) != 0)
577 return _error->Errno("fstat","Failed to stat");
578 CFile->Size = St.st_size;
579 CFile->mtime = St.st_mtime;
580 CFile->Archive = Gen.WriteUniqString("now");
581
582 if (Gen.MergeList(Parser) == false)
583 return _error->Error("Problem with MergeList %s",File.c_str());
584 return true;
585}
586 /*}}}*/
587// StatusIndex::FindInCache - Find this index /*{{{*/
588// ---------------------------------------------------------------------
589/* */
590pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
591{
592 pkgCache::PkgFileIterator File = Cache.FileBegin();
593 for (; File.end() == false; File++)
594 {
595 if (this->File != File.FileName())
596 continue;
597
598 struct stat St;
599 if (stat(File.FileName(),&St) != 0)
c8e572e3
MV
600 {
601 if (_config->FindB("Debug::pkgCacheGen", false))
602 std::clog << "StatusIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
b2e465d6 603 return pkgCache::PkgFileIterator(Cache);
c8e572e3 604 }
b2e465d6 605 if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
c8e572e3
MV
606 {
607 if (_config->FindB("Debug::pkgCacheGen", false))
608 std::clog << "StatusIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
609 << ") or mtime (" << St.st_mtime << " <> " << File->mtime
610 << ") doesn't match for " << File.FileName() << std::endl;
b2e465d6 611 return pkgCache::PkgFileIterator(Cache);
c8e572e3 612 }
b2e465d6
AL
613 return File;
614 }
615 return File;
616}
617 /*}}}*/
618// StatusIndex::Exists - Check if the index is available /*{{{*/
619// ---------------------------------------------------------------------
620/* */
621bool debStatusIndex::Exists() const
622{
623 // Abort if the file does not exist.
624 return true;
625}
626 /*}}}*/
627
b2e465d6
AL
628// Index File types for Debian /*{{{*/
629class debIFTypeSrc : public pkgIndexFile::Type
630{
631 public:
632
633 debIFTypeSrc() {Label = "Debian Source Index";};
634};
635class debIFTypePkg : public pkgIndexFile::Type
636{
637 public:
638
639 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
640 {
641 return new debRecordParser(File.FileName(),*File.Cache());
642 };
643 debIFTypePkg() {Label = "Debian Package Index";};
644};
97234432
MV
645class debIFTypeTrans : public debIFTypePkg
646{
647 public:
648 debIFTypeTrans() {Label = "Debian Translation Index";};
649};
b2e465d6
AL
650class debIFTypeStatus : public pkgIndexFile::Type
651{
652 public:
653
654 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
655 {
656 return new debRecordParser(File.FileName(),*File.Cache());
657 };
658 debIFTypeStatus() {Label = "Debian dpkg status file";};
659};
660static debIFTypeSrc _apt_Src;
661static debIFTypePkg _apt_Pkg;
97234432 662static debIFTypeTrans _apt_Trans;
b2e465d6
AL
663static debIFTypeStatus _apt_Status;
664
665const pkgIndexFile::Type *debSourcesIndex::GetType() const
666{
667 return &_apt_Src;
668}
669const pkgIndexFile::Type *debPackagesIndex::GetType() const
670{
671 return &_apt_Pkg;
672}
a52f938b
OS
673const pkgIndexFile::Type *debTranslationsIndex::GetType() const
674{
97234432 675 return &_apt_Trans;
a52f938b 676}
b2e465d6
AL
677const pkgIndexFile::Type *debStatusIndex::GetType() const
678{
679 return &_apt_Status;
680}
681
682 /*}}}*/