debindexfile.cc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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. string s = URItoFileName(IndexURI(Type));
  104. string sgzip = s + ".gz";
  105. if (!FileExists(s) && FileExists(sgzip))
  106. return sgzip;
  107. else
  108. return s;
  109. }
  110. string debSourcesIndex::IndexURI(const char *Type) const
  111. {
  112. string Res;
  113. if (Dist[Dist.size() - 1] == '/')
  114. {
  115. if (Dist != "/")
  116. Res = URI + Dist;
  117. else
  118. Res = URI;
  119. }
  120. else
  121. Res = URI + "dists/" + Dist + '/' + Section +
  122. "/source/";
  123. Res += Type;
  124. return Res;
  125. }
  126. /*}}}*/
  127. // SourcesIndex::Exists - Check if the index is available /*{{{*/
  128. // ---------------------------------------------------------------------
  129. /* */
  130. bool debSourcesIndex::Exists() const
  131. {
  132. return FileExists(IndexFile("Sources"));
  133. }
  134. /*}}}*/
  135. // SourcesIndex::Size - Return the size of the index /*{{{*/
  136. // ---------------------------------------------------------------------
  137. /* */
  138. unsigned long debSourcesIndex::Size() const
  139. {
  140. struct stat S;
  141. if (stat(IndexFile("Sources").c_str(),&S) != 0)
  142. return 0;
  143. return S.st_size;
  144. }
  145. /*}}}*/
  146. // PackagesIndex::debPackagesIndex - Contructor /*{{{*/
  147. // ---------------------------------------------------------------------
  148. /* */
  149. debPackagesIndex::debPackagesIndex(string URI,string Dist,string Section,bool Trusted) :
  150. pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section)
  151. {
  152. }
  153. /*}}}*/
  154. // PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/
  155. // ---------------------------------------------------------------------
  156. /* This is a shorter version that is designed to be < 60 chars or so */
  157. string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
  158. {
  159. string Res = ::URI::NoUserPassword(URI) + ' ';
  160. if (Dist[Dist.size() - 1] == '/')
  161. {
  162. if (Dist != "/")
  163. Res += Dist;
  164. }
  165. else
  166. Res += Dist + '/' + Section;
  167. Res += " ";
  168. Res += Ver.ParentPkg().Name();
  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 += Type;
  204. return Info;
  205. }
  206. /*}}}*/
  207. // PackagesIndex::Index* - Return the URI to the index files /*{{{*/
  208. // ---------------------------------------------------------------------
  209. /* */
  210. inline string debPackagesIndex::IndexFile(const char *Type) const
  211. {
  212. string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
  213. string sgzip = s + ".gz";
  214. if (!FileExists(s) && FileExists(sgzip))
  215. return sgzip;
  216. else
  217. return s;
  218. }
  219. string debPackagesIndex::IndexURI(const char *Type) const
  220. {
  221. string Res;
  222. if (Dist[Dist.size() - 1] == '/')
  223. {
  224. if (Dist != "/")
  225. Res = URI + Dist;
  226. else
  227. Res = URI;
  228. }
  229. else
  230. Res = URI + "dists/" + Dist + '/' + Section +
  231. "/binary-" + _config->Find("APT::Architecture") + '/';
  232. Res += Type;
  233. return Res;
  234. }
  235. /*}}}*/
  236. // PackagesIndex::Exists - Check if the index is available /*{{{*/
  237. // ---------------------------------------------------------------------
  238. /* */
  239. bool debPackagesIndex::Exists() const
  240. {
  241. return FileExists(IndexFile("Packages"));
  242. }
  243. /*}}}*/
  244. // PackagesIndex::Size - Return the size of the index /*{{{*/
  245. // ---------------------------------------------------------------------
  246. /* This is really only used for progress reporting. */
  247. unsigned long debPackagesIndex::Size() const
  248. {
  249. struct stat S;
  250. if (stat(IndexFile("Packages").c_str(),&S) != 0)
  251. return 0;
  252. return S.st_size;
  253. }
  254. /*}}}*/
  255. // PackagesIndex::Merge - Load the index file into a cache /*{{{*/
  256. // ---------------------------------------------------------------------
  257. /* */
  258. bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
  259. {
  260. string PackageFile = IndexFile("Packages");
  261. FileFd Pkg(PackageFile,FileFd::ReadOnly);
  262. debListParser Parser(&Pkg);
  263. if (_error->PendingError() == true)
  264. return _error->Error("Problem opening %s",PackageFile.c_str());
  265. Prog.SubProgress(0,Info("Packages"));
  266. ::URI Tmp(URI);
  267. if (Gen.SelectFile(PackageFile,Tmp.Host,*this) == false)
  268. return _error->Error("Problem with SelectFile %s",PackageFile.c_str());
  269. // Store the IMS information
  270. pkgCache::PkgFileIterator File = Gen.GetCurFile();
  271. struct stat St;
  272. if (fstat(Pkg.Fd(),&St) != 0)
  273. return _error->Errno("fstat","Failed to stat");
  274. File->Size = St.st_size;
  275. File->mtime = St.st_mtime;
  276. if (Gen.MergeList(Parser) == false)
  277. return _error->Error("Problem with MergeList %s",PackageFile.c_str());
  278. // Check the release file
  279. string ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("Release");
  280. if (FileExists(ReleaseFile) == true)
  281. {
  282. FileFd Rel(ReleaseFile,FileFd::ReadOnly);
  283. if (_error->PendingError() == true)
  284. return false;
  285. Parser.LoadReleaseInfo(File,Rel,Section);
  286. }
  287. return true;
  288. }
  289. /*}}}*/
  290. // PackagesIndex::FindInCache - Find this index /*{{{*/
  291. // ---------------------------------------------------------------------
  292. /* */
  293. pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
  294. {
  295. string FileName = IndexFile("Packages");
  296. pkgCache::PkgFileIterator File = Cache.FileBegin();
  297. for (; File.end() == false; File++)
  298. {
  299. if (File.FileName() == NULL || FileName != File.FileName())
  300. continue;
  301. struct stat St;
  302. if (stat(File.FileName(),&St) != 0)
  303. {
  304. if (_config->FindB("Debug::pkgCacheGen", false))
  305. std::clog << "PackagesIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
  306. return pkgCache::PkgFileIterator(Cache);
  307. }
  308. if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
  309. {
  310. if (_config->FindB("Debug::pkgCacheGen", false))
  311. std::clog << "PackagesIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
  312. << ") or mtime (" << St.st_mtime << " <> " << File->mtime
  313. << ") doesn't match for " << File.FileName() << std::endl;
  314. return pkgCache::PkgFileIterator(Cache);
  315. }
  316. return File;
  317. }
  318. return File;
  319. }
  320. /*}}}*/
  321. // TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/
  322. // ---------------------------------------------------------------------
  323. /* */
  324. debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section,
  325. char const * const Translation) :
  326. pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section),
  327. Language(Translation)
  328. {}
  329. /*}}}*/
  330. // TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
  331. // ---------------------------------------------------------------------
  332. /* */
  333. inline string debTranslationsIndex::IndexFile(const char *Type) const
  334. {
  335. string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
  336. string sgzip = s + ".gz";
  337. if (!FileExists(s) && FileExists(sgzip))
  338. return sgzip;
  339. else
  340. return s;
  341. }
  342. string debTranslationsIndex::IndexURI(const char *Type) const
  343. {
  344. string Res;
  345. if (Dist[Dist.size() - 1] == '/')
  346. {
  347. if (Dist != "/")
  348. Res = URI + Dist;
  349. else
  350. Res = URI;
  351. }
  352. else
  353. Res = URI + "dists/" + Dist + '/' + Section +
  354. "/i18n/Translation-";
  355. Res += Type;
  356. return Res;
  357. }
  358. /*}}}*/
  359. // TranslationsIndex::GetIndexes - Fetch the index files /*{{{*/
  360. // ---------------------------------------------------------------------
  361. /* */
  362. bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
  363. {
  364. if (TranslationsAvailable()) {
  365. string const TranslationFile = string("Translation-").append(Language);
  366. new pkgAcqIndexTrans(Owner, IndexURI(Language),
  367. Info(TranslationFile.c_str()),
  368. TranslationFile);
  369. }
  370. return true;
  371. }
  372. /*}}}*/
  373. // TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
  374. // ---------------------------------------------------------------------
  375. /* This should help the user find the index in the sources.list and
  376. in the filesystem for problem solving */
  377. string debTranslationsIndex::Describe(bool Short) const
  378. {
  379. char S[300];
  380. if (Short == true)
  381. snprintf(S,sizeof(S),"%s",Info(TranslationFile().c_str()).c_str());
  382. else
  383. snprintf(S,sizeof(S),"%s (%s)",Info(TranslationFile().c_str()).c_str(),
  384. IndexFile(Language).c_str());
  385. return S;
  386. }
  387. /*}}}*/
  388. // TranslationsIndex::Info - One liner describing the index URI /*{{{*/
  389. // ---------------------------------------------------------------------
  390. /* */
  391. string debTranslationsIndex::Info(const char *Type) const
  392. {
  393. string Info = ::URI::NoUserPassword(URI) + ' ';
  394. if (Dist[Dist.size() - 1] == '/')
  395. {
  396. if (Dist != "/")
  397. Info += Dist;
  398. }
  399. else
  400. Info += Dist + '/' + Section;
  401. Info += " ";
  402. Info += Type;
  403. return Info;
  404. }
  405. /*}}}*/
  406. bool debTranslationsIndex::HasPackages() const /*{{{*/
  407. {
  408. if(!TranslationsAvailable())
  409. return false;
  410. return FileExists(IndexFile(Language));
  411. }
  412. /*}}}*/
  413. // TranslationsIndex::Exists - Check if the index is available /*{{{*/
  414. // ---------------------------------------------------------------------
  415. /* */
  416. bool debTranslationsIndex::Exists() const
  417. {
  418. return FileExists(IndexFile(Language));
  419. }
  420. /*}}}*/
  421. // TranslationsIndex::Size - Return the size of the index /*{{{*/
  422. // ---------------------------------------------------------------------
  423. /* This is really only used for progress reporting. */
  424. unsigned long debTranslationsIndex::Size() const
  425. {
  426. struct stat S;
  427. if (stat(IndexFile(Language).c_str(),&S) != 0)
  428. return 0;
  429. return S.st_size;
  430. }
  431. /*}}}*/
  432. // TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
  433. // ---------------------------------------------------------------------
  434. /* */
  435. bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
  436. {
  437. // Check the translation file, if in use
  438. string TranslationFile = IndexFile(Language);
  439. if (TranslationsAvailable() && FileExists(TranslationFile))
  440. {
  441. FileFd Trans(TranslationFile,FileFd::ReadOnly);
  442. debListParser TransParser(&Trans);
  443. if (_error->PendingError() == true)
  444. return false;
  445. Prog.SubProgress(0, Info(TranslationFile.c_str()));
  446. if (Gen.SelectFile(TranslationFile,string(),*this) == false)
  447. return _error->Error("Problem with SelectFile %s",TranslationFile.c_str());
  448. // Store the IMS information
  449. pkgCache::PkgFileIterator TransFile = Gen.GetCurFile();
  450. struct stat TransSt;
  451. if (fstat(Trans.Fd(),&TransSt) != 0)
  452. return _error->Errno("fstat","Failed to stat");
  453. TransFile->Size = TransSt.st_size;
  454. TransFile->mtime = TransSt.st_mtime;
  455. if (Gen.MergeList(TransParser) == false)
  456. return _error->Error("Problem with MergeList %s",TranslationFile.c_str());
  457. }
  458. return true;
  459. }
  460. /*}}}*/
  461. // TranslationsIndex::FindInCache - Find this index /*{{{*/
  462. // ---------------------------------------------------------------------
  463. /* */
  464. pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
  465. {
  466. string FileName = IndexFile(Language);
  467. pkgCache::PkgFileIterator File = Cache.FileBegin();
  468. for (; File.end() == false; File++)
  469. {
  470. if (FileName != File.FileName())
  471. continue;
  472. struct stat St;
  473. if (stat(File.FileName(),&St) != 0)
  474. {
  475. if (_config->FindB("Debug::pkgCacheGen", false))
  476. std::clog << "TranslationIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
  477. return pkgCache::PkgFileIterator(Cache);
  478. }
  479. if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
  480. {
  481. if (_config->FindB("Debug::pkgCacheGen", false))
  482. std::clog << "TranslationIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
  483. << ") or mtime (" << St.st_mtime << " <> " << File->mtime
  484. << ") doesn't match for " << File.FileName() << std::endl;
  485. return pkgCache::PkgFileIterator(Cache);
  486. }
  487. return File;
  488. }
  489. return File;
  490. }
  491. /*}}}*/
  492. // StatusIndex::debStatusIndex - Constructor /*{{{*/
  493. // ---------------------------------------------------------------------
  494. /* */
  495. debStatusIndex::debStatusIndex(string File) : pkgIndexFile(true), File(File)
  496. {
  497. }
  498. /*}}}*/
  499. // StatusIndex::Size - Return the size of the index /*{{{*/
  500. // ---------------------------------------------------------------------
  501. /* */
  502. unsigned long debStatusIndex::Size() const
  503. {
  504. struct stat S;
  505. if (stat(File.c_str(),&S) != 0)
  506. return 0;
  507. return S.st_size;
  508. }
  509. /*}}}*/
  510. // StatusIndex::Merge - Load the index file into a cache /*{{{*/
  511. // ---------------------------------------------------------------------
  512. /* */
  513. bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
  514. {
  515. FileFd Pkg(File,FileFd::ReadOnly);
  516. if (_error->PendingError() == true)
  517. return false;
  518. debListParser Parser(&Pkg);
  519. if (_error->PendingError() == true)
  520. return false;
  521. Prog.SubProgress(0,File);
  522. if (Gen.SelectFile(File,string(),*this,pkgCache::Flag::NotSource) == false)
  523. return _error->Error("Problem with SelectFile %s",File.c_str());
  524. // Store the IMS information
  525. pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
  526. struct stat St;
  527. if (fstat(Pkg.Fd(),&St) != 0)
  528. return _error->Errno("fstat","Failed to stat");
  529. CFile->Size = St.st_size;
  530. CFile->mtime = St.st_mtime;
  531. CFile->Archive = Gen.WriteUniqString("now");
  532. if (Gen.MergeList(Parser) == false)
  533. return _error->Error("Problem with MergeList %s",File.c_str());
  534. return true;
  535. }
  536. /*}}}*/
  537. // StatusIndex::FindInCache - Find this index /*{{{*/
  538. // ---------------------------------------------------------------------
  539. /* */
  540. pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
  541. {
  542. pkgCache::PkgFileIterator File = Cache.FileBegin();
  543. for (; File.end() == false; File++)
  544. {
  545. if (this->File != File.FileName())
  546. continue;
  547. struct stat St;
  548. if (stat(File.FileName(),&St) != 0)
  549. {
  550. if (_config->FindB("Debug::pkgCacheGen", false))
  551. std::clog << "StatusIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
  552. return pkgCache::PkgFileIterator(Cache);
  553. }
  554. if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
  555. {
  556. if (_config->FindB("Debug::pkgCacheGen", false))
  557. std::clog << "StatusIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
  558. << ") or mtime (" << St.st_mtime << " <> " << File->mtime
  559. << ") doesn't match for " << File.FileName() << std::endl;
  560. return pkgCache::PkgFileIterator(Cache);
  561. }
  562. return File;
  563. }
  564. return File;
  565. }
  566. /*}}}*/
  567. // StatusIndex::Exists - Check if the index is available /*{{{*/
  568. // ---------------------------------------------------------------------
  569. /* */
  570. bool debStatusIndex::Exists() const
  571. {
  572. // Abort if the file does not exist.
  573. return true;
  574. }
  575. /*}}}*/
  576. // Index File types for Debian /*{{{*/
  577. class debIFTypeSrc : public pkgIndexFile::Type
  578. {
  579. public:
  580. debIFTypeSrc() {Label = "Debian Source Index";};
  581. };
  582. class debIFTypePkg : public pkgIndexFile::Type
  583. {
  584. public:
  585. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
  586. {
  587. return new debRecordParser(File.FileName(),*File.Cache());
  588. };
  589. debIFTypePkg() {Label = "Debian Package Index";};
  590. };
  591. class debIFTypeTrans : public debIFTypePkg
  592. {
  593. public:
  594. debIFTypeTrans() {Label = "Debian Translation Index";};
  595. };
  596. class debIFTypeStatus : public pkgIndexFile::Type
  597. {
  598. public:
  599. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
  600. {
  601. return new debRecordParser(File.FileName(),*File.Cache());
  602. };
  603. debIFTypeStatus() {Label = "Debian dpkg status file";};
  604. };
  605. static debIFTypeSrc _apt_Src;
  606. static debIFTypePkg _apt_Pkg;
  607. static debIFTypeTrans _apt_Trans;
  608. static debIFTypeStatus _apt_Status;
  609. const pkgIndexFile::Type *debSourcesIndex::GetType() const
  610. {
  611. return &_apt_Src;
  612. }
  613. const pkgIndexFile::Type *debPackagesIndex::GetType() const
  614. {
  615. return &_apt_Pkg;
  616. }
  617. const pkgIndexFile::Type *debTranslationsIndex::GetType() const
  618. {
  619. return &_apt_Trans;
  620. }
  621. const pkgIndexFile::Type *debStatusIndex::GetType() const
  622. {
  623. return &_apt_Status;
  624. }
  625. /*}}}*/