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>
44 // SourcesIndex::debSourcesIndex - Constructor /*{{{*/
45 // ---------------------------------------------------------------------
47 debSourcesIndex::debSourcesIndex(string URI
,string Dist
,string Section
,bool Trusted
) :
48 pkgIndexFile(Trusted
), URI(URI
), Dist(Dist
), Section(Section
)
52 // SourcesIndex::SourceInfo - Short 1 liner describing a source /*{{{*/
53 // ---------------------------------------------------------------------
54 /* The result looks like:
55 http://foo/debian/ stable/main src 1.1.1 (dsc) */
56 string
debSourcesIndex::SourceInfo(pkgSrcRecords::Parser
const &Record
,
57 pkgSrcRecords::File
const &File
) const
60 Res
= ::URI::NoUserPassword(URI
) + ' ';
61 if (Dist
[Dist
.size() - 1] == '/')
67 Res
+= Dist
+ '/' + Section
;
70 Res
+= Record
.Package();
72 Res
+= Record
.Version();
73 if (File
.Type
.empty() == false)
74 Res
+= " (" + File
.Type
+ ")";
78 // SourcesIndex::CreateSrcParser - Get a parser for the source files /*{{{*/
79 // ---------------------------------------------------------------------
81 pkgSrcRecords::Parser
*debSourcesIndex::CreateSrcParser() const
83 string SourcesURI
= _config
->FindDir("Dir::State::lists") +
84 URItoFileName(IndexURI("Sources"));
86 std::vector
<std::string
> types
= APT::Configuration::getCompressionTypes();
87 for (std::vector
<std::string
>::const_iterator t
= types
.begin(); t
!= types
.end(); ++t
)
90 p
= SourcesURI
+ '.' + *t
;
92 return new debSrcRecordParser(p
, this);
94 if (FileExists(SourcesURI
))
95 return new debSrcRecordParser(SourcesURI
, this);
99 // SourcesIndex::Describe - Give a descriptive path to the index /*{{{*/
100 // ---------------------------------------------------------------------
102 string
debSourcesIndex::Describe(bool Short
) const
106 snprintf(S
,sizeof(S
),"%s",Info("Sources").c_str());
108 snprintf(S
,sizeof(S
),"%s (%s)",Info("Sources").c_str(),
109 IndexFile("Sources").c_str());
114 // SourcesIndex::Info - One liner describing the index URI /*{{{*/
115 // ---------------------------------------------------------------------
117 string
debSourcesIndex::Info(const char *Type
) const
119 string Info
= ::URI::NoUserPassword(URI
) + ' ';
120 if (Dist
[Dist
.size() - 1] == '/')
126 Info
+= Dist
+ '/' + Section
;
132 // SourcesIndex::Index* - Return the URI to the index files /*{{{*/
133 // ---------------------------------------------------------------------
135 string
debSourcesIndex::IndexFile(const char *Type
) const
137 string s
= URItoFileName(IndexURI(Type
));
139 std::vector
<std::string
> types
= APT::Configuration::getCompressionTypes();
140 for (std::vector
<std::string
>::const_iterator t
= types
.begin(); t
!= types
.end(); ++t
)
142 string p
= s
+ '.' + *t
;
149 string
debSourcesIndex::IndexURI(const char *Type
) const
152 if (Dist
[Dist
.size() - 1] == '/')
160 Res
= URI
+ "dists/" + Dist
+ '/' + Section
+
167 // SourcesIndex::Exists - Check if the index is available /*{{{*/
168 // ---------------------------------------------------------------------
170 bool debSourcesIndex::Exists() const
172 return FileExists(IndexFile("Sources"));
175 // SourcesIndex::Size - Return the size of the index /*{{{*/
176 // ---------------------------------------------------------------------
178 unsigned long debSourcesIndex::Size() const
180 unsigned long size
= 0;
182 /* we need to ignore errors here; if the lists are absent, just return 0 */
183 _error
->PushToStack();
185 FileFd
f(IndexFile("Sources"), FileFd::ReadOnly
, FileFd::Extension
);
189 if (_error
->PendingError() == true)
191 _error
->RevertToStack();
197 // PackagesIndex::debPackagesIndex - Contructor /*{{{*/
198 // ---------------------------------------------------------------------
200 debPackagesIndex::debPackagesIndex(string
const &URI
, string
const &Dist
, string
const &Section
,
201 bool const &Trusted
, string
const &Arch
) :
202 pkgIndexFile(Trusted
), URI(URI
), Dist(Dist
), Section(Section
), Architecture(Arch
)
204 if (Architecture
== "native")
205 Architecture
= _config
->Find("APT::Architecture");
208 // PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/
209 // ---------------------------------------------------------------------
210 /* This is a shorter version that is designed to be < 60 chars or so */
211 string
debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver
) const
213 string Res
= ::URI::NoUserPassword(URI
) + ' ';
214 if (Dist
[Dist
.size() - 1] == '/')
220 Res
+= Dist
+ '/' + Section
;
223 Res
+= Ver
.ParentPkg().Name();
225 if (Dist
[Dist
.size() - 1] != '/')
226 Res
.append(Ver
.Arch()).append(" ");
231 // PackagesIndex::Describe - Give a descriptive path to the index /*{{{*/
232 // ---------------------------------------------------------------------
233 /* This should help the user find the index in the sources.list and
234 in the filesystem for problem solving */
235 string
debPackagesIndex::Describe(bool Short
) const
239 snprintf(S
,sizeof(S
),"%s",Info("Packages").c_str());
241 snprintf(S
,sizeof(S
),"%s (%s)",Info("Packages").c_str(),
242 IndexFile("Packages").c_str());
246 // PackagesIndex::Info - One liner describing the index URI /*{{{*/
247 // ---------------------------------------------------------------------
249 string
debPackagesIndex::Info(const char *Type
) const
251 string Info
= ::URI::NoUserPassword(URI
) + ' ';
252 if (Dist
[Dist
.size() - 1] == '/')
258 Info
+= Dist
+ '/' + Section
;
260 if (Dist
[Dist
.size() - 1] != '/')
261 Info
+= Architecture
+ " ";
266 // PackagesIndex::Index* - Return the URI to the index files /*{{{*/
267 // ---------------------------------------------------------------------
269 string
debPackagesIndex::IndexFile(const char *Type
) const
271 string s
=_config
->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type
));
273 std::vector
<std::string
> types
= APT::Configuration::getCompressionTypes();
274 for (std::vector
<std::string
>::const_iterator t
= types
.begin(); t
!= types
.end(); ++t
)
276 string p
= s
+ '.' + *t
;
282 string
debPackagesIndex::IndexURI(const char *Type
) const
285 if (Dist
[Dist
.size() - 1] == '/')
293 Res
= URI
+ "dists/" + Dist
+ '/' + Section
+
294 "/binary-" + Architecture
+ '/';
300 // PackagesIndex::Exists - Check if the index is available /*{{{*/
301 // ---------------------------------------------------------------------
303 bool debPackagesIndex::Exists() const
305 return FileExists(IndexFile("Packages"));
308 // PackagesIndex::Size - Return the size of the index /*{{{*/
309 // ---------------------------------------------------------------------
310 /* This is really only used for progress reporting. */
311 unsigned long debPackagesIndex::Size() const
313 unsigned long size
= 0;
315 /* we need to ignore errors here; if the lists are absent, just return 0 */
316 _error
->PushToStack();
318 FileFd
f(IndexFile("Packages"), FileFd::ReadOnly
, FileFd::Extension
);
322 if (_error
->PendingError() == true)
324 _error
->RevertToStack();
329 // PackagesIndex::Merge - Load the index file into a cache /*{{{*/
330 // ---------------------------------------------------------------------
332 bool debPackagesIndex::Merge(pkgCacheGenerator
&Gen
,OpProgress
*Prog
) const
334 string PackageFile
= IndexFile("Packages");
335 FileFd
Pkg(PackageFile
,FileFd::ReadOnly
, FileFd::Extension
);
336 debListParser
Parser(&Pkg
, Architecture
);
338 if (_error
->PendingError() == true)
339 return _error
->Error("Problem opening %s",PackageFile
.c_str());
341 Prog
->SubProgress(0,Info("Packages"));
343 if (Gen
.SelectFile(PackageFile
,Tmp
.Host
,*this) == false)
344 return _error
->Error("Problem with SelectFile %s",PackageFile
.c_str());
346 // Store the IMS information
347 pkgCache::PkgFileIterator File
= Gen
.GetCurFile();
348 pkgCacheGenerator::Dynamic
<pkgCache::PkgFileIterator
> DynFile(File
);
349 File
->Size
= Pkg
.FileSize();
350 File
->mtime
= Pkg
.ModificationTime();
352 if (Gen
.MergeList(Parser
) == false)
353 return _error
->Error("Problem with MergeList %s",PackageFile
.c_str());
355 // Check the release file
356 string ReleaseFile
= debReleaseIndex(URI
,Dist
).MetaIndexFile("InRelease");
357 bool releaseExists
= false;
358 if (FileExists(ReleaseFile
) == true)
359 releaseExists
= true;
361 ReleaseFile
= debReleaseIndex(URI
,Dist
).MetaIndexFile("Release");
363 if (releaseExists
== true || FileExists(ReleaseFile
) == true)
366 // Beware: The 'Release' file might be clearsigned in case the
367 // signature for an 'InRelease' file couldn't be checked
368 if (OpenMaybeClearSignedFile(ReleaseFile
, Rel
) == false)
371 if (_error
->PendingError() == true)
373 Parser
.LoadReleaseInfo(File
,Rel
,Section
);
379 // PackagesIndex::FindInCache - Find this index /*{{{*/
380 // ---------------------------------------------------------------------
382 pkgCache::PkgFileIterator
debPackagesIndex::FindInCache(pkgCache
&Cache
) const
384 string FileName
= IndexFile("Packages");
385 pkgCache::PkgFileIterator File
= Cache
.FileBegin();
386 for (; File
.end() == false; ++File
)
388 if (File
.FileName() == NULL
|| FileName
!= File
.FileName())
392 if (stat(File
.FileName(),&St
) != 0)
394 if (_config
->FindB("Debug::pkgCacheGen", false))
395 std::clog
<< "PackagesIndex::FindInCache - stat failed on " << File
.FileName() << std::endl
;
396 return pkgCache::PkgFileIterator(Cache
);
398 if ((unsigned)St
.st_size
!= File
->Size
|| St
.st_mtime
!= File
->mtime
)
400 if (_config
->FindB("Debug::pkgCacheGen", false))
401 std::clog
<< "PackagesIndex::FindInCache - size (" << St
.st_size
<< " <> " << File
->Size
402 << ") or mtime (" << St
.st_mtime
<< " <> " << File
->mtime
403 << ") doesn't match for " << File
.FileName() << std::endl
;
404 return pkgCache::PkgFileIterator(Cache
);
413 // TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/
414 // ---------------------------------------------------------------------
416 debTranslationsIndex::debTranslationsIndex(std::string
const &URI
, std::string
const &Dist
,
417 std::string
const &Section
, std::string
const &Translation
) :
418 pkgIndexFile(true), URI(URI
), Dist(Dist
), Section(Section
),
419 Language(Translation
)
422 // TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
423 // ---------------------------------------------------------------------
425 string
debTranslationsIndex::IndexFile(const char *Type
) const
427 string s
=_config
->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type
));
429 std::vector
<std::string
> types
= APT::Configuration::getCompressionTypes();
430 for (std::vector
<std::string
>::const_iterator t
= types
.begin(); t
!= types
.end(); ++t
)
432 string p
= s
+ '.' + *t
;
438 string
debTranslationsIndex::IndexURI(const char *Type
) const
441 if (Dist
[Dist
.size() - 1] == '/')
449 Res
= URI
+ "dists/" + Dist
+ '/' + Section
+
450 "/i18n/Translation-";
456 // TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
457 // ---------------------------------------------------------------------
458 /* This should help the user find the index in the sources.list and
459 in the filesystem for problem solving */
460 string
debTranslationsIndex::Describe(bool Short
) const
464 strprintf(S
,"%s",Info(TranslationFile().c_str()).c_str());
466 strprintf(S
,"%s (%s)",Info(TranslationFile().c_str()).c_str(),
467 IndexFile(Language
.c_str()).c_str());
471 // TranslationsIndex::Info - One liner describing the index URI /*{{{*/
472 // ---------------------------------------------------------------------
474 string
debTranslationsIndex::Info(const char *Type
) const
476 string Info
= ::URI::NoUserPassword(URI
) + ' ';
477 if (Dist
[Dist
.size() - 1] == '/')
483 Info
+= Dist
+ '/' + Section
;
489 bool debTranslationsIndex::HasPackages() const /*{{{*/
491 return FileExists(IndexFile(Language
.c_str()));
494 // TranslationsIndex::Exists - Check if the index is available /*{{{*/
495 // ---------------------------------------------------------------------
497 bool debTranslationsIndex::Exists() const
499 return FileExists(IndexFile(Language
.c_str()));
502 // TranslationsIndex::Size - Return the size of the index /*{{{*/
503 // ---------------------------------------------------------------------
504 /* This is really only used for progress reporting. */
505 unsigned long debTranslationsIndex::Size() const
507 unsigned long size
= 0;
509 /* we need to ignore errors here; if the lists are absent, just return 0 */
510 _error
->PushToStack();
512 FileFd
f(IndexFile(Language
.c_str()), FileFd::ReadOnly
, FileFd::Extension
);
516 if (_error
->PendingError() == true)
518 _error
->RevertToStack();
523 // TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
524 // ---------------------------------------------------------------------
526 bool debTranslationsIndex::Merge(pkgCacheGenerator
&Gen
,OpProgress
*Prog
) const
528 // Check the translation file, if in use
529 string TranslationFile
= IndexFile(Language
.c_str());
530 if (FileExists(TranslationFile
))
532 FileFd
Trans(TranslationFile
,FileFd::ReadOnly
, FileFd::Extension
);
533 debTranslationsParser
TransParser(&Trans
);
534 if (_error
->PendingError() == true)
538 Prog
->SubProgress(0, Info(TranslationFile
.c_str()));
539 if (Gen
.SelectFile(TranslationFile
,string(),*this) == false)
540 return _error
->Error("Problem with SelectFile %s",TranslationFile
.c_str());
542 // Store the IMS information
543 pkgCache::PkgFileIterator TransFile
= Gen
.GetCurFile();
544 TransFile
->Size
= Trans
.FileSize();
545 TransFile
->mtime
= Trans
.ModificationTime();
547 if (Gen
.MergeList(TransParser
) == false)
548 return _error
->Error("Problem with MergeList %s",TranslationFile
.c_str());
554 // TranslationsIndex::FindInCache - Find this index /*{{{*/
555 // ---------------------------------------------------------------------
557 pkgCache::PkgFileIterator
debTranslationsIndex::FindInCache(pkgCache
&Cache
) const
559 string FileName
= IndexFile(Language
.c_str());
561 pkgCache::PkgFileIterator File
= Cache
.FileBegin();
562 for (; File
.end() == false; ++File
)
564 if (FileName
!= File
.FileName())
568 if (stat(File
.FileName(),&St
) != 0)
570 if (_config
->FindB("Debug::pkgCacheGen", false))
571 std::clog
<< "TranslationIndex::FindInCache - stat failed on " << File
.FileName() << std::endl
;
572 return pkgCache::PkgFileIterator(Cache
);
574 if ((unsigned)St
.st_size
!= File
->Size
|| St
.st_mtime
!= File
->mtime
)
576 if (_config
->FindB("Debug::pkgCacheGen", false))
577 std::clog
<< "TranslationIndex::FindInCache - size (" << St
.st_size
<< " <> " << File
->Size
578 << ") or mtime (" << St
.st_mtime
<< " <> " << File
->mtime
579 << ") doesn't match for " << File
.FileName() << std::endl
;
580 return pkgCache::PkgFileIterator(Cache
);
587 // StatusIndex::debStatusIndex - Constructor /*{{{*/
588 // ---------------------------------------------------------------------
590 debStatusIndex::debStatusIndex(string File
) : pkgIndexFile(true), File(File
)
594 // StatusIndex::Size - Return the size of the index /*{{{*/
595 // ---------------------------------------------------------------------
597 unsigned long debStatusIndex::Size() const
600 if (stat(File
.c_str(),&S
) != 0)
605 // StatusIndex::Merge - Load the index file into a cache /*{{{*/
606 // ---------------------------------------------------------------------
608 bool debStatusIndex::Merge(pkgCacheGenerator
&Gen
,OpProgress
*Prog
) const
610 FileFd
Pkg(File
,FileFd::ReadOnly
, FileFd::Extension
);
611 if (_error
->PendingError() == true)
613 debListParser
Parser(&Pkg
);
614 if (_error
->PendingError() == true)
618 Prog
->SubProgress(0,File
);
619 if (Gen
.SelectFile(File
,string(),*this,pkgCache::Flag::NotSource
) == false)
620 return _error
->Error("Problem with SelectFile %s",File
.c_str());
622 // Store the IMS information
623 pkgCache::PkgFileIterator CFile
= Gen
.GetCurFile();
624 CFile
->Size
= Pkg
.FileSize();
625 CFile
->mtime
= Pkg
.ModificationTime();
626 map_stringitem_t
const storage
= Gen
.StoreString(pkgCacheGenerator::MIXED
, "now");
627 CFile
->Archive
= storage
;
629 if (Gen
.MergeList(Parser
) == false)
630 return _error
->Error("Problem with MergeList %s",File
.c_str());
634 // StatusIndex::FindInCache - Find this index /*{{{*/
635 // ---------------------------------------------------------------------
637 pkgCache::PkgFileIterator
debStatusIndex::FindInCache(pkgCache
&Cache
) const
639 pkgCache::PkgFileIterator File
= Cache
.FileBegin();
640 for (; File
.end() == false; ++File
)
642 if (this->File
!= File
.FileName())
646 if (stat(File
.FileName(),&St
) != 0)
648 if (_config
->FindB("Debug::pkgCacheGen", false))
649 std::clog
<< "StatusIndex::FindInCache - stat failed on " << File
.FileName() << std::endl
;
650 return pkgCache::PkgFileIterator(Cache
);
652 if ((unsigned)St
.st_size
!= File
->Size
|| St
.st_mtime
!= File
->mtime
)
654 if (_config
->FindB("Debug::pkgCacheGen", false))
655 std::clog
<< "StatusIndex::FindInCache - size (" << St
.st_size
<< " <> " << File
->Size
656 << ") or mtime (" << St
.st_mtime
<< " <> " << File
->mtime
657 << ") doesn't match for " << File
.FileName() << std::endl
;
658 return pkgCache::PkgFileIterator(Cache
);
665 // StatusIndex::Exists - Check if the index is available /*{{{*/
666 // ---------------------------------------------------------------------
668 APT_CONST
bool debStatusIndex::Exists() const
670 // Abort if the file does not exist.
675 // debDebPkgFile - Single .deb file /*{{{*/
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::GetContent(std::ostream
&content
, std::string
const &debfile
)
693 // get the control data out of the deb file via dpkg-deb -I
694 std::string dpkg
= _config
->Find("Dir::Bin::dpkg","dpkg-deb");
695 std::vector
<const char *> Args
;
696 Args
.push_back(dpkg
.c_str());
697 Args
.push_back("-I");
698 Args
.push_back(debfile
.c_str());
699 Args
.push_back("control");
700 Args
.push_back(NULL
);
703 if(Popen((const char**)&Args
[0], PipeFd
, Child
, FileFd::ReadOnly
) == false)
704 return _error
->Error("Popen failed");
708 unsigned long long actual
= 0;
709 if (PipeFd
.Read(buffer
, sizeof(buffer
)-1, &actual
) == false)
710 return _error
->Errno("read", "Failed to read dpkg pipe");
713 buffer
[actual
] = '\0';
716 ExecWait(Child
, "Popen");
718 content
<< "Filename: " << debfile
<< "\n";
720 if (stat(debfile
.c_str(), &Buf
) != 0)
722 content
<< "Size: " << Buf
.st_size
<< "\n";
726 bool debDebPkgFileIndex::Merge(pkgCacheGenerator
& Gen
, OpProgress
* Prog
) const
729 Prog
->SubProgress(0, "Reading deb file");
731 // write the control data to a tempfile
732 SPtr
<FileFd
> DebControl
= GetTempFile("deb-file-" + flNotDir(DebFile
));
733 if(DebControl
== NULL
)
735 std::ostringstream content
;
736 if (GetContent(content
, DebFile
) == false)
738 std::string
const contentstr
= content
.str();
739 DebControl
->Write(contentstr
.c_str(), contentstr
.length());
740 // rewind for the listparser
743 // and give it to the list parser
744 debDebFileParser
Parser(DebControl
, DebFile
);
745 if(Gen
.SelectFile(DebFile
, "local", *this, pkgCache::Flag::LocalSource
) == false)
746 return _error
->Error("Problem with SelectFile %s", DebFile
.c_str());
748 pkgCache::PkgFileIterator File
= Gen
.GetCurFile();
749 File
->Size
= DebControl
->Size();
750 File
->mtime
= DebControl
->ModificationTime();
752 if (Gen
.MergeList(Parser
) == false)
753 return _error
->Error("Problem with MergeLister for %s", DebFile
.c_str());
757 pkgCache::PkgFileIterator
debDebPkgFileIndex::FindInCache(pkgCache
&Cache
) const
759 pkgCache::PkgFileIterator File
= Cache
.FileBegin();
760 for (; File
.end() == false; ++File
)
762 if (File
.FileName() == NULL
|| DebFile
!= File
.FileName())
770 unsigned long debDebPkgFileIndex::Size() const
773 if(stat(DebFile
.c_str(), &buf
) != 0)
779 // debDscFileIndex stuff
780 debDscFileIndex::debDscFileIndex(std::string
&DscFile
)
781 : pkgIndexFile(true), DscFile(DscFile
)
785 bool debDscFileIndex::Exists() const
787 return FileExists(DscFile
);
790 unsigned long debDscFileIndex::Size() const
793 if(stat(DscFile
.c_str(), &buf
) == 0)
798 // DscFileIndex::CreateSrcParser - Get a parser for the .dsc file /*{{{*/
799 pkgSrcRecords::Parser
*debDscFileIndex::CreateSrcParser() const
801 if (!FileExists(DscFile
))
804 return new debDscRecordParser(DscFile
,this);
807 // Index File types for Debian /*{{{*/
808 class APT_HIDDEN debIFTypeSrc
: public pkgIndexFile::Type
812 debIFTypeSrc() {Label
= "Debian Source Index";};
814 class APT_HIDDEN debIFTypePkg
: public pkgIndexFile::Type
818 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator File
) const
820 return new debRecordParser(File
.FileName(),*File
.Cache());
822 debIFTypePkg() {Label
= "Debian Package Index";};
824 class APT_HIDDEN debIFTypeTrans
: public debIFTypePkg
827 debIFTypeTrans() {Label
= "Debian Translation Index";};
829 class APT_HIDDEN debIFTypeStatus
: public pkgIndexFile::Type
833 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator File
) const
835 return new debRecordParser(File
.FileName(),*File
.Cache());
837 debIFTypeStatus() {Label
= "Debian dpkg status file";};
839 class APT_HIDDEN debIFTypeDebPkgFile
: public pkgIndexFile::Type
842 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator File
) const
844 return new debDebFileRecordParser(File
.FileName());
846 debIFTypeDebPkgFile() {Label
= "deb Package file";};
848 class APT_HIDDEN debIFTypeDscFile
: public pkgIndexFile::Type
851 virtual pkgSrcRecords::Parser
*CreateSrcPkgParser(std::string DscFile
) const
853 return new debDscRecordParser(DscFile
, NULL
);
855 debIFTypeDscFile() {Label
= "dsc File Source Index";};
857 class APT_HIDDEN debIFTypeDebianSourceDir
: public pkgIndexFile::Type
860 virtual pkgSrcRecords::Parser
*CreateSrcPkgParser(std::string SourceDir
) const
862 return new debDscRecordParser(SourceDir
+ string("/debian/control"), NULL
);
864 debIFTypeDebianSourceDir() {Label
= "debian/control File Source Index";};
867 APT_HIDDEN debIFTypeSrc _apt_Src
;
868 APT_HIDDEN debIFTypePkg _apt_Pkg
;
869 APT_HIDDEN debIFTypeTrans _apt_Trans
;
870 APT_HIDDEN debIFTypeStatus _apt_Status
;
871 APT_HIDDEN debIFTypeDebPkgFile _apt_DebPkgFile
;
872 // file based pseudo indexes
873 APT_HIDDEN debIFTypeDscFile _apt_DscFile
;
874 APT_HIDDEN debIFTypeDebianSourceDir _apt_DebianSourceDir
;
876 const pkgIndexFile::Type
*debSourcesIndex::GetType() const
880 const pkgIndexFile::Type
*debPackagesIndex::GetType() const
884 const pkgIndexFile::Type
*debTranslationsIndex::GetType() const
888 const pkgIndexFile::Type
*debStatusIndex::GetType() const
892 const pkgIndexFile::Type
*debDebPkgFileIndex::GetType() const
894 return &_apt_DebPkgFile
;
896 const pkgIndexFile::Type
*debDscFileIndex::GetType() const
898 return &_apt_DscFile
;
900 const pkgIndexFile::Type
*debDebianSourceDirIndex::GetType() const
902 return &_apt_DebianSourceDir
;
906 debStatusIndex::~debStatusIndex() {}
907 debPackagesIndex::~debPackagesIndex() {}
908 debTranslationsIndex::~debTranslationsIndex() {}
909 debSourcesIndex::~debSourcesIndex() {}
911 debDebPkgFileIndex::~debDebPkgFileIndex() {}