You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

709 lines
21 KiB

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