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