debindexfile.cc 20 KB

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