1 // -*- mode: cpp; mode: fold -*-
3 // $Id: debindexfile.cc,v 1.5.2.3 2004/01/04 19:11:00 mdz Exp $
4 /* ######################################################################
6 Debian Specific sources.list types and the three sorts of Debian
9 ##################################################################### */
11 // Include Files /*{{{*/
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 #include <apt-pkg/sptr.h>
43 // SourcesIndex::debSourcesIndex - Constructor /*{{{*/
44 // ---------------------------------------------------------------------
46 debSourcesIndex::debSourcesIndex(string URI
,string Dist
,string Section
,bool Trusted
) :
47 pkgIndexFile(Trusted
), URI(URI
), Dist(Dist
), Section(Section
)
51 // SourcesIndex::SourceInfo - Short 1 liner describing a source /*{{{*/
52 // ---------------------------------------------------------------------
53 /* The result looks like:
54 http://foo/debian/ stable/main src 1.1.1 (dsc) */
55 string
debSourcesIndex::SourceInfo(pkgSrcRecords::Parser
const &Record
,
56 pkgSrcRecords::File
const &File
) const
59 Res
= ::URI::NoUserPassword(URI
) + ' ';
60 if (Dist
[Dist
.size() - 1] == '/')
66 Res
+= Dist
+ '/' + Section
;
69 Res
+= Record
.Package();
71 Res
+= Record
.Version();
72 if (File
.Type
.empty() == false)
73 Res
+= " (" + File
.Type
+ ")";
77 // SourcesIndex::CreateSrcParser - Get a parser for the source files /*{{{*/
78 // ---------------------------------------------------------------------
80 pkgSrcRecords::Parser
*debSourcesIndex::CreateSrcParser() const
82 string SourcesURI
= _config
->FindDir("Dir::State::lists") +
83 URItoFileName(IndexURI("Sources"));
85 std::vector
<std::string
> types
= APT::Configuration::getCompressionTypes();
86 for (std::vector
<std::string
>::const_iterator t
= types
.begin(); t
!= types
.end(); ++t
)
89 p
= SourcesURI
+ '.' + *t
;
91 return new debSrcRecordParser(p
, this);
93 if (FileExists(SourcesURI
))
94 return new debSrcRecordParser(SourcesURI
, this);
98 // SourcesIndex::Describe - Give a descriptive path to the index /*{{{*/
99 // ---------------------------------------------------------------------
101 string
debSourcesIndex::Describe(bool Short
) const
105 snprintf(S
,sizeof(S
),"%s",Info("Sources").c_str());
107 snprintf(S
,sizeof(S
),"%s (%s)",Info("Sources").c_str(),
108 IndexFile("Sources").c_str());
113 // SourcesIndex::Info - One liner describing the index URI /*{{{*/
114 // ---------------------------------------------------------------------
116 string
debSourcesIndex::Info(const char *Type
) const
118 string Info
= ::URI::NoUserPassword(URI
) + ' ';
119 if (Dist
[Dist
.size() - 1] == '/')
125 Info
+= Dist
+ '/' + Section
;
131 // SourcesIndex::Index* - Return the URI to the index files /*{{{*/
132 // ---------------------------------------------------------------------
134 string
debSourcesIndex::IndexFile(const char *Type
) const
136 string s
= URItoFileName(IndexURI(Type
));
138 std::vector
<std::string
> types
= APT::Configuration::getCompressionTypes();
139 for (std::vector
<std::string
>::const_iterator t
= types
.begin(); t
!= types
.end(); ++t
)
141 string p
= s
+ '.' + *t
;
148 string
debSourcesIndex::IndexURI(const char *Type
) const
151 if (Dist
[Dist
.size() - 1] == '/')
159 Res
= URI
+ "dists/" + Dist
+ '/' + Section
+
166 // SourcesIndex::Exists - Check if the index is available /*{{{*/
167 // ---------------------------------------------------------------------
169 bool debSourcesIndex::Exists() const
171 return FileExists(IndexFile("Sources"));
174 // SourcesIndex::Size - Return the size of the index /*{{{*/
175 // ---------------------------------------------------------------------
177 unsigned long debSourcesIndex::Size() const
179 unsigned long size
= 0;
181 /* we need to ignore errors here; if the lists are absent, just return 0 */
182 _error
->PushToStack();
184 FileFd
f(IndexFile("Sources"), FileFd::ReadOnly
, FileFd::Extension
);
188 if (_error
->PendingError() == true)
190 _error
->RevertToStack();
196 // PackagesIndex::debPackagesIndex - Contructor /*{{{*/
197 // ---------------------------------------------------------------------
199 debPackagesIndex::debPackagesIndex(string
const &URI
, string
const &Dist
, string
const &Section
,
200 bool const &Trusted
, string
const &Arch
) :
201 pkgIndexFile(Trusted
), URI(URI
), Dist(Dist
), Section(Section
), Architecture(Arch
)
203 if (Architecture
== "native")
204 Architecture
= _config
->Find("APT::Architecture");
207 // PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/
208 // ---------------------------------------------------------------------
209 /* This is a shorter version that is designed to be < 60 chars or so */
210 string
debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver
) const
212 string Res
= ::URI::NoUserPassword(URI
) + ' ';
213 if (Dist
[Dist
.size() - 1] == '/')
219 Res
+= Dist
+ '/' + Section
;
222 Res
+= Ver
.ParentPkg().Name();
224 if (Dist
[Dist
.size() - 1] != '/')
225 Res
.append(Ver
.Arch()).append(" ");
230 // PackagesIndex::Describe - Give a descriptive path to the index /*{{{*/
231 // ---------------------------------------------------------------------
232 /* This should help the user find the index in the sources.list and
233 in the filesystem for problem solving */
234 string
debPackagesIndex::Describe(bool Short
) const
238 snprintf(S
,sizeof(S
),"%s",Info("Packages").c_str());
240 snprintf(S
,sizeof(S
),"%s (%s)",Info("Packages").c_str(),
241 IndexFile("Packages").c_str());
245 // PackagesIndex::Info - One liner describing the index URI /*{{{*/
246 // ---------------------------------------------------------------------
248 string
debPackagesIndex::Info(const char *Type
) const
250 string Info
= ::URI::NoUserPassword(URI
) + ' ';
251 if (Dist
[Dist
.size() - 1] == '/')
257 Info
+= Dist
+ '/' + Section
;
259 if (Dist
[Dist
.size() - 1] != '/')
260 Info
+= Architecture
+ " ";
265 // PackagesIndex::Index* - Return the URI to the index files /*{{{*/
266 // ---------------------------------------------------------------------
268 string
debPackagesIndex::IndexFile(const char *Type
) const
270 string s
=_config
->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type
));
272 std::vector
<std::string
> types
= APT::Configuration::getCompressionTypes();
273 for (std::vector
<std::string
>::const_iterator t
= types
.begin(); t
!= types
.end(); ++t
)
275 string p
= s
+ '.' + *t
;
281 string
debPackagesIndex::IndexURI(const char *Type
) const
284 if (Dist
[Dist
.size() - 1] == '/')
292 Res
= URI
+ "dists/" + Dist
+ '/' + Section
+
293 "/binary-" + Architecture
+ '/';
299 // PackagesIndex::Exists - Check if the index is available /*{{{*/
300 // ---------------------------------------------------------------------
302 bool debPackagesIndex::Exists() const
304 return FileExists(IndexFile("Packages"));
307 // PackagesIndex::Size - Return the size of the index /*{{{*/
308 // ---------------------------------------------------------------------
309 /* This is really only used for progress reporting. */
310 unsigned long debPackagesIndex::Size() const
312 unsigned long size
= 0;
314 /* we need to ignore errors here; if the lists are absent, just return 0 */
315 _error
->PushToStack();
317 FileFd
f(IndexFile("Packages"), FileFd::ReadOnly
, FileFd::Extension
);
321 if (_error
->PendingError() == true)
323 _error
->RevertToStack();
328 // PackagesIndex::Merge - Load the index file into a cache /*{{{*/
329 // ---------------------------------------------------------------------
331 bool debPackagesIndex::Merge(pkgCacheGenerator
&Gen
,OpProgress
*Prog
) const
333 string PackageFile
= IndexFile("Packages");
334 FileFd
Pkg(PackageFile
,FileFd::ReadOnly
, FileFd::Extension
);
335 debListParser
Parser(&Pkg
, Architecture
);
337 if (_error
->PendingError() == true)
338 return _error
->Error("Problem opening %s",PackageFile
.c_str());
340 Prog
->SubProgress(0,Info("Packages"));
342 if (Gen
.SelectFile(PackageFile
,Tmp
.Host
,*this) == false)
343 return _error
->Error("Problem with SelectFile %s",PackageFile
.c_str());
345 // Store the IMS information
346 pkgCache::PkgFileIterator File
= Gen
.GetCurFile();
347 pkgCacheGenerator::Dynamic
<pkgCache::PkgFileIterator
> DynFile(File
);
348 File
->Size
= Pkg
.FileSize();
349 File
->mtime
= Pkg
.ModificationTime();
351 if (Gen
.MergeList(Parser
) == false)
352 return _error
->Error("Problem with MergeList %s",PackageFile
.c_str());
354 // Check the release file
355 string ReleaseFile
= debReleaseIndex(URI
,Dist
).MetaIndexFile("InRelease");
356 bool releaseExists
= false;
357 if (FileExists(ReleaseFile
) == true)
358 releaseExists
= true;
360 ReleaseFile
= debReleaseIndex(URI
,Dist
).MetaIndexFile("Release");
362 if (releaseExists
== true || FileExists(ReleaseFile
) == true)
365 // Beware: The 'Release' file might be clearsigned in case the
366 // signature for an 'InRelease' file couldn't be checked
367 if (OpenMaybeClearSignedFile(ReleaseFile
, Rel
) == false)
370 if (_error
->PendingError() == true)
372 Parser
.LoadReleaseInfo(File
,Rel
,Section
);
378 // PackagesIndex::FindInCache - Find this index /*{{{*/
379 // ---------------------------------------------------------------------
381 pkgCache::PkgFileIterator
debPackagesIndex::FindInCache(pkgCache
&Cache
) const
383 string FileName
= IndexFile("Packages");
384 pkgCache::PkgFileIterator File
= Cache
.FileBegin();
385 for (; File
.end() == false; ++File
)
387 if (File
.FileName() == NULL
|| FileName
!= File
.FileName())
391 if (stat(File
.FileName(),&St
) != 0)
393 if (_config
->FindB("Debug::pkgCacheGen", false))
394 std::clog
<< "PackagesIndex::FindInCache - stat failed on " << File
.FileName() << std::endl
;
395 return pkgCache::PkgFileIterator(Cache
);
397 if ((unsigned)St
.st_size
!= File
->Size
|| St
.st_mtime
!= File
->mtime
)
399 if (_config
->FindB("Debug::pkgCacheGen", false))
400 std::clog
<< "PackagesIndex::FindInCache - size (" << St
.st_size
<< " <> " << File
->Size
401 << ") or mtime (" << St
.st_mtime
<< " <> " << File
->mtime
402 << ") doesn't match for " << File
.FileName() << std::endl
;
403 return pkgCache::PkgFileIterator(Cache
);
412 // TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/
413 // ---------------------------------------------------------------------
415 debTranslationsIndex::debTranslationsIndex(string URI
,string Dist
,string Section
,
416 char const * const Translation
) :
417 pkgIndexFile(true), URI(URI
), Dist(Dist
), Section(Section
),
418 Language(Translation
)
421 // TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
422 // ---------------------------------------------------------------------
424 string
debTranslationsIndex::IndexFile(const char *Type
) const
426 string s
=_config
->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type
));
428 std::vector
<std::string
> types
= APT::Configuration::getCompressionTypes();
429 for (std::vector
<std::string
>::const_iterator t
= types
.begin(); t
!= types
.end(); ++t
)
431 string p
= s
+ '.' + *t
;
437 string
debTranslationsIndex::IndexURI(const char *Type
) const
440 if (Dist
[Dist
.size() - 1] == '/')
448 Res
= URI
+ "dists/" + Dist
+ '/' + Section
+
449 "/i18n/Translation-";
455 // TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
456 // ---------------------------------------------------------------------
457 /* This should help the user find the index in the sources.list and
458 in the filesystem for problem solving */
459 string
debTranslationsIndex::Describe(bool Short
) const
463 snprintf(S
,sizeof(S
),"%s",Info(TranslationFile().c_str()).c_str());
465 snprintf(S
,sizeof(S
),"%s (%s)",Info(TranslationFile().c_str()).c_str(),
466 IndexFile(Language
).c_str());
470 // TranslationsIndex::Info - One liner describing the index URI /*{{{*/
471 // ---------------------------------------------------------------------
473 string
debTranslationsIndex::Info(const char *Type
) const
475 string Info
= ::URI::NoUserPassword(URI
) + ' ';
476 if (Dist
[Dist
.size() - 1] == '/')
482 Info
+= Dist
+ '/' + Section
;
488 bool debTranslationsIndex::HasPackages() const /*{{{*/
490 return FileExists(IndexFile(Language
));
493 // TranslationsIndex::Exists - Check if the index is available /*{{{*/
494 // ---------------------------------------------------------------------
496 bool debTranslationsIndex::Exists() const
498 return FileExists(IndexFile(Language
));
501 // TranslationsIndex::Size - Return the size of the index /*{{{*/
502 // ---------------------------------------------------------------------
503 /* This is really only used for progress reporting. */
504 unsigned long debTranslationsIndex::Size() const
506 unsigned long size
= 0;
508 /* we need to ignore errors here; if the lists are absent, just return 0 */
509 _error
->PushToStack();
511 FileFd
f(IndexFile(Language
), FileFd::ReadOnly
, FileFd::Extension
);
515 if (_error
->PendingError() == true)
517 _error
->RevertToStack();
522 // TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
523 // ---------------------------------------------------------------------
525 bool debTranslationsIndex::Merge(pkgCacheGenerator
&Gen
,OpProgress
*Prog
) const
527 // Check the translation file, if in use
528 string TranslationFile
= IndexFile(Language
);
529 if (FileExists(TranslationFile
))
531 FileFd
Trans(TranslationFile
,FileFd::ReadOnly
, FileFd::Extension
);
532 debTranslationsParser
TransParser(&Trans
);
533 if (_error
->PendingError() == true)
537 Prog
->SubProgress(0, Info(TranslationFile
.c_str()));
538 if (Gen
.SelectFile(TranslationFile
,string(),*this) == false)
539 return _error
->Error("Problem with SelectFile %s",TranslationFile
.c_str());
541 // Store the IMS information
542 pkgCache::PkgFileIterator TransFile
= Gen
.GetCurFile();
543 TransFile
->Size
= Trans
.FileSize();
544 TransFile
->mtime
= Trans
.ModificationTime();
546 if (Gen
.MergeList(TransParser
) == false)
547 return _error
->Error("Problem with MergeList %s",TranslationFile
.c_str());
553 // TranslationsIndex::FindInCache - Find this index /*{{{*/
554 // ---------------------------------------------------------------------
556 pkgCache::PkgFileIterator
debTranslationsIndex::FindInCache(pkgCache
&Cache
) const
558 string FileName
= IndexFile(Language
);
560 pkgCache::PkgFileIterator File
= Cache
.FileBegin();
561 for (; File
.end() == false; ++File
)
563 if (FileName
!= File
.FileName())
567 if (stat(File
.FileName(),&St
) != 0)
569 if (_config
->FindB("Debug::pkgCacheGen", false))
570 std::clog
<< "TranslationIndex::FindInCache - stat failed on " << File
.FileName() << std::endl
;
571 return pkgCache::PkgFileIterator(Cache
);
573 if ((unsigned)St
.st_size
!= File
->Size
|| St
.st_mtime
!= File
->mtime
)
575 if (_config
->FindB("Debug::pkgCacheGen", false))
576 std::clog
<< "TranslationIndex::FindInCache - size (" << St
.st_size
<< " <> " << File
->Size
577 << ") or mtime (" << St
.st_mtime
<< " <> " << File
->mtime
578 << ") doesn't match for " << File
.FileName() << std::endl
;
579 return pkgCache::PkgFileIterator(Cache
);
586 // StatusIndex::debStatusIndex - Constructor /*{{{*/
587 // ---------------------------------------------------------------------
589 debStatusIndex::debStatusIndex(string File
) : pkgIndexFile(true), File(File
)
593 // StatusIndex::Size - Return the size of the index /*{{{*/
594 // ---------------------------------------------------------------------
596 unsigned long debStatusIndex::Size() const
599 if (stat(File
.c_str(),&S
) != 0)
604 // StatusIndex::Merge - Load the index file into a cache /*{{{*/
605 // ---------------------------------------------------------------------
607 bool debStatusIndex::Merge(pkgCacheGenerator
&Gen
,OpProgress
*Prog
) const
609 FileFd
Pkg(File
,FileFd::ReadOnly
, FileFd::Extension
);
610 if (_error
->PendingError() == true)
612 debListParser
Parser(&Pkg
);
613 if (_error
->PendingError() == true)
617 Prog
->SubProgress(0,File
);
618 if (Gen
.SelectFile(File
,string(),*this,pkgCache::Flag::NotSource
) == false)
619 return _error
->Error("Problem with SelectFile %s",File
.c_str());
621 // Store the IMS information
622 pkgCache::PkgFileIterator CFile
= Gen
.GetCurFile();
623 CFile
->Size
= Pkg
.FileSize();
624 CFile
->mtime
= Pkg
.ModificationTime();
625 map_stringitem_t
const storage
= Gen
.StoreString(pkgCacheGenerator::MIXED
, "now");
626 CFile
->Archive
= storage
;
628 if (Gen
.MergeList(Parser
) == false)
629 return _error
->Error("Problem with MergeList %s",File
.c_str());
633 // StatusIndex::FindInCache - Find this index /*{{{*/
634 // ---------------------------------------------------------------------
636 pkgCache::PkgFileIterator
debStatusIndex::FindInCache(pkgCache
&Cache
) const
638 pkgCache::PkgFileIterator File
= Cache
.FileBegin();
639 for (; File
.end() == false; ++File
)
641 if (this->File
!= File
.FileName())
645 if (stat(File
.FileName(),&St
) != 0)
647 if (_config
->FindB("Debug::pkgCacheGen", false))
648 std::clog
<< "StatusIndex::FindInCache - stat failed on " << File
.FileName() << std::endl
;
649 return pkgCache::PkgFileIterator(Cache
);
651 if ((unsigned)St
.st_size
!= File
->Size
|| St
.st_mtime
!= File
->mtime
)
653 if (_config
->FindB("Debug::pkgCacheGen", false))
654 std::clog
<< "StatusIndex::FindInCache - size (" << St
.st_size
<< " <> " << File
->Size
655 << ") or mtime (" << St
.st_mtime
<< " <> " << File
->mtime
656 << ") doesn't match for " << File
.FileName() << std::endl
;
657 return pkgCache::PkgFileIterator(Cache
);
664 // StatusIndex::Exists - Check if the index is available /*{{{*/
665 // ---------------------------------------------------------------------
667 APT_CONST
bool debStatusIndex::Exists() const
669 // Abort if the file does not exist.
674 // debDebPkgFile - Single .deb file /*{{{*/
675 // ---------------------------------------------------------------------
676 debDebPkgFileIndex::debDebPkgFileIndex(std::string DebFile
)
677 : pkgIndexFile(true), DebFile(DebFile
)
679 DebFileFullPath
= flAbsPath(DebFile
);
682 std::string
debDebPkgFileIndex::ArchiveURI(std::string
/*File*/) const
684 return "file:" + DebFileFullPath
;
687 bool debDebPkgFileIndex::Exists() const
689 return FileExists(DebFile
);
691 bool debDebPkgFileIndex::Merge(pkgCacheGenerator
& Gen
, OpProgress
* Prog
) const
694 Prog
->SubProgress(0, "Reading deb file");
696 // get the control data out of the deb file vid dpkg -I
697 // ... can I haz libdpkg?
698 Configuration::Item
const *Opts
= _config
->Tree("DPkg::Options");
699 std::string dpkg
= _config
->Find("Dir::Bin::dpkg","dpkg");
700 std::vector
<const char *> Args
;
701 Args
.push_back(dpkg
.c_str());
705 for (; Opts
!= 0; Opts
= Opts
->Next
)
707 if (Opts
->Value
.empty() == true)
709 Args
.push_back(Opts
->Value
.c_str());
712 Args
.push_back("-I");
713 Args
.push_back(DebFile
.c_str());
714 Args
.push_back("control");
715 Args
.push_back(NULL
);
718 if(Popen((const char**)&Args
[0], PipeFd
, Child
, FileFd::ReadOnly
) == false)
719 return _error
->Error("Popen failed");
720 // FIXME: static buffer
722 unsigned long long n
= 0;
723 if(PipeFd
.Read(buf
, sizeof(buf
)-1, &n
) == false)
724 return _error
->Errno("read", "Failed to read dpkg pipe");
725 ExecWait(Child
, "Popen");
727 // now write the control data to a tempfile
728 SPtr
<FileFd
> DebControl
= GetTempFile("deb-file-" + flNotDir(DebFile
));
729 if(DebControl
== NULL
)
731 DebControl
->Write(buf
, n
);
732 // append size of the file
733 FileFd
Fd(DebFile
, FileFd::ReadOnly
);
735 strprintf(Size
, "Size: %llu\n", Fd
.Size());
736 DebControl
->Write(Size
.c_str(), Size
.size());
737 // and rewind for the listparser
740 // and give it to the list parser
741 debDebFileParser
Parser(DebControl
, DebFile
);
742 if(Gen
.SelectFile(DebFile
, "local", *this) == false)
743 return _error
->Error("Problem with SelectFile %s", DebFile
.c_str());
745 pkgCache::PkgFileIterator File
= Gen
.GetCurFile();
746 File
->Size
= DebControl
->Size();
747 File
->mtime
= DebControl
->ModificationTime();
749 if (Gen
.MergeList(Parser
) == false)
750 return _error
->Error("Problem with MergeLister for %s", DebFile
.c_str());
754 pkgCache::PkgFileIterator
debDebPkgFileIndex::FindInCache(pkgCache
&Cache
) const
756 pkgCache::PkgFileIterator File
= Cache
.FileBegin();
757 for (; File
.end() == false; ++File
)
759 if (File
.FileName() == NULL
|| DebFile
!= File
.FileName())
767 unsigned long debDebPkgFileIndex::Size() const
770 if(stat(DebFile
.c_str(), &buf
) != 0)
776 // debDscFileIndex stuff
777 debDscFileIndex::debDscFileIndex(std::string
&DscFile
)
778 : pkgIndexFile(true), DscFile(DscFile
)
782 bool debDscFileIndex::Exists() const
784 return FileExists(DscFile
);
787 unsigned long debDscFileIndex::Size() const
790 if(stat(DscFile
.c_str(), &buf
) == 0)
795 // DscFileIndex::CreateSrcParser - Get a parser for the .dsc file /*{{{*/
796 pkgSrcRecords::Parser
*debDscFileIndex::CreateSrcParser() const
798 if (!FileExists(DscFile
))
801 return new debDscRecordParser(DscFile
,this);
804 // Index File types for Debian /*{{{*/
805 class debIFTypeSrc
: public pkgIndexFile::Type
809 debIFTypeSrc() {Label
= "Debian Source Index";};
811 class debIFTypePkg
: public pkgIndexFile::Type
815 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator File
) const
817 return new debRecordParser(File
.FileName(),*File
.Cache());
819 debIFTypePkg() {Label
= "Debian Package Index";};
821 class debIFTypeTrans
: public debIFTypePkg
824 debIFTypeTrans() {Label
= "Debian Translation Index";};
826 class debIFTypeStatus
: public pkgIndexFile::Type
830 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator File
) const
832 return new debRecordParser(File
.FileName(),*File
.Cache());
834 debIFTypeStatus() {Label
= "Debian dpkg status file";};
836 class debIFTypeDebPkgFile
: public pkgIndexFile::Type
839 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator File
) const
841 return new debDebFileRecordParser(File
.FileName(),*File
.Cache());
843 debIFTypeDebPkgFile() {Label
= "deb Package file";};
845 class debIFTypeDscFile
: public pkgIndexFile::Type
848 virtual pkgSrcRecords::Parser
*CreateSrcPkgParser(std::string DscFile
) const
850 return new debDscRecordParser(DscFile
, NULL
);
852 debIFTypeDscFile() {Label
= "dsc File Source Index";};
854 class debIFTypeDebianSourceDir
: public pkgIndexFile::Type
857 virtual pkgSrcRecords::Parser
*CreateSrcPkgParser(std::string SourceDir
) const
859 return new debDscRecordParser(SourceDir
+ string("/debian/control"), NULL
);
861 debIFTypeDebianSourceDir() {Label
= "debian/control File Source Index";};
864 static debIFTypeSrc _apt_Src
;
865 static debIFTypePkg _apt_Pkg
;
866 static debIFTypeTrans _apt_Trans
;
867 static debIFTypeStatus _apt_Status
;
868 static debIFTypeDebPkgFile _apt_DebPkgFile
;
869 // file based pseudo indexes
870 static debIFTypeDscFile _apt_DscFile
;
871 static debIFTypeDebianSourceDir _apt_DebianSourceDir
;
873 const pkgIndexFile::Type
*debSourcesIndex::GetType() const
877 const pkgIndexFile::Type
*debPackagesIndex::GetType() const
881 const pkgIndexFile::Type
*debTranslationsIndex::GetType() const
885 const pkgIndexFile::Type
*debStatusIndex::GetType() const
889 const pkgIndexFile::Type
*debDebPkgFileIndex::GetType() const
891 return &_apt_DebPkgFile
;
893 const pkgIndexFile::Type
*debDscFileIndex::GetType() const
895 return &_apt_DscFile
;
897 const pkgIndexFile::Type
*debDebianSourceDirIndex::GetType() const
899 return &_apt_DebianSourceDir
;
903 debStatusIndex::~debStatusIndex() {}
904 debPackagesIndex::~debPackagesIndex() {}
905 debTranslationsIndex::~debTranslationsIndex() {}
906 debSourcesIndex::~debSourcesIndex() {}
908 debDebPkgFileIndex::~debDebPkgFileIndex() {}