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