pkgcachegen.cc 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgcachegen.cc,v 1.53.2.1 2003/12/24 23:09:17 mdz Exp $
  4. /* ######################################################################
  5. Package Cache Generator - Generator for the cache structure.
  6. This builds the cache structure from the abstract package list parser.
  7. ##################################################################### */
  8. /*}}}*/
  9. // Include Files /*{{{*/
  10. #include <config.h>
  11. #include <apt-pkg/pkgcachegen.h>
  12. #include <apt-pkg/error.h>
  13. #include <apt-pkg/version.h>
  14. #include <apt-pkg/progress.h>
  15. #include <apt-pkg/sourcelist.h>
  16. #include <apt-pkg/configuration.h>
  17. #include <apt-pkg/strutl.h>
  18. #include <apt-pkg/sptr.h>
  19. #include <apt-pkg/pkgsystem.h>
  20. #include <apt-pkg/macros.h>
  21. #include <apt-pkg/metaindex.h>
  22. #include <apt-pkg/fileutl.h>
  23. #include <apt-pkg/hashsum_template.h>
  24. #include <apt-pkg/indexfile.h>
  25. #include <apt-pkg/md5.h>
  26. #include <apt-pkg/mmap.h>
  27. #include <apt-pkg/pkgcache.h>
  28. #include <apt-pkg/cacheiterators.h>
  29. #include <stddef.h>
  30. #include <string.h>
  31. #include <iostream>
  32. #include <string>
  33. #include <vector>
  34. #include <sys/stat.h>
  35. #include <unistd.h>
  36. #include <apti18n.h>
  37. /*}}}*/
  38. typedef std::vector<pkgIndexFile *>::iterator FileIterator;
  39. template <typename Iter> std::vector<Iter*> pkgCacheGenerator::Dynamic<Iter>::toReMap;
  40. static bool IsDuplicateDescription(pkgCache::DescIterator Desc,
  41. MD5SumValue const &CurMd5, std::string const &CurLang);
  42. using std::string;
  43. // CacheGenerator::pkgCacheGenerator - Constructor /*{{{*/
  44. // ---------------------------------------------------------------------
  45. /* We set the dirty flag and make sure that is written to the disk */
  46. pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) :
  47. Map(*pMap), Cache(pMap,false), Progress(Prog),
  48. FoundFileDeps(0)
  49. {
  50. CurrentFile = 0;
  51. memset(UniqHash,0,sizeof(UniqHash));
  52. if (_error->PendingError() == true)
  53. return;
  54. if (Map.Size() == 0)
  55. {
  56. // Setup the map interface..
  57. Cache.HeaderP = (pkgCache::Header *)Map.Data();
  58. if (Map.RawAllocate(sizeof(pkgCache::Header)) == 0 && _error->PendingError() == true)
  59. return;
  60. Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
  61. // Starting header
  62. *Cache.HeaderP = pkgCache::Header();
  63. map_ptrloc const idxVerSysName = WriteStringInMap(_system->VS->Label);
  64. Cache.HeaderP->VerSysName = idxVerSysName;
  65. // this pointer is set in ReMap, but we need it now for WriteUniqString
  66. Cache.StringItemP = (pkgCache::StringItem *)Map.Data();
  67. map_ptrloc const idxArchitecture = WriteUniqString(_config->Find("APT::Architecture"));
  68. Cache.HeaderP->Architecture = idxArchitecture;
  69. if (unlikely(idxVerSysName == 0 || idxArchitecture == 0))
  70. return;
  71. Cache.ReMap();
  72. }
  73. else
  74. {
  75. // Map directly from the existing file
  76. Cache.ReMap();
  77. Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
  78. if (Cache.VS != _system->VS)
  79. {
  80. _error->Error(_("Cache has an incompatible versioning system"));
  81. return;
  82. }
  83. }
  84. Cache.HeaderP->Dirty = true;
  85. Map.Sync(0,sizeof(pkgCache::Header));
  86. }
  87. /*}}}*/
  88. // CacheGenerator::~pkgCacheGenerator - Destructor /*{{{*/
  89. // ---------------------------------------------------------------------
  90. /* We sync the data then unset the dirty flag in two steps so as to
  91. advoid a problem during a crash */
  92. pkgCacheGenerator::~pkgCacheGenerator()
  93. {
  94. if (_error->PendingError() == true)
  95. return;
  96. if (Map.Sync() == false)
  97. return;
  98. Cache.HeaderP->Dirty = false;
  99. Cache.HeaderP->CacheFileSize = Map.Size();
  100. Map.Sync(0,sizeof(pkgCache::Header));
  101. }
  102. /*}}}*/
  103. void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newMap) {/*{{{*/
  104. if (oldMap == newMap)
  105. return;
  106. if (_config->FindB("Debug::pkgCacheGen", false))
  107. std::clog << "Remaping from " << oldMap << " to " << newMap << std::endl;
  108. Cache.ReMap(false);
  109. CurrentFile += (pkgCache::PackageFile const * const) newMap - (pkgCache::PackageFile const * const) oldMap;
  110. for (size_t i = 0; i < _count(UniqHash); ++i)
  111. if (UniqHash[i] != 0)
  112. UniqHash[i] += (pkgCache::StringItem const * const) newMap - (pkgCache::StringItem const * const) oldMap;
  113. for (std::vector<pkgCache::GrpIterator*>::const_iterator i = Dynamic<pkgCache::GrpIterator>::toReMap.begin();
  114. i != Dynamic<pkgCache::GrpIterator>::toReMap.end(); ++i)
  115. (*i)->ReMap(oldMap, newMap);
  116. for (std::vector<pkgCache::PkgIterator*>::const_iterator i = Dynamic<pkgCache::PkgIterator>::toReMap.begin();
  117. i != Dynamic<pkgCache::PkgIterator>::toReMap.end(); ++i)
  118. (*i)->ReMap(oldMap, newMap);
  119. for (std::vector<pkgCache::VerIterator*>::const_iterator i = Dynamic<pkgCache::VerIterator>::toReMap.begin();
  120. i != Dynamic<pkgCache::VerIterator>::toReMap.end(); ++i)
  121. (*i)->ReMap(oldMap, newMap);
  122. for (std::vector<pkgCache::DepIterator*>::const_iterator i = Dynamic<pkgCache::DepIterator>::toReMap.begin();
  123. i != Dynamic<pkgCache::DepIterator>::toReMap.end(); ++i)
  124. (*i)->ReMap(oldMap, newMap);
  125. for (std::vector<pkgCache::DescIterator*>::const_iterator i = Dynamic<pkgCache::DescIterator>::toReMap.begin();
  126. i != Dynamic<pkgCache::DescIterator>::toReMap.end(); ++i)
  127. (*i)->ReMap(oldMap, newMap);
  128. for (std::vector<pkgCache::PrvIterator*>::const_iterator i = Dynamic<pkgCache::PrvIterator>::toReMap.begin();
  129. i != Dynamic<pkgCache::PrvIterator>::toReMap.end(); ++i)
  130. (*i)->ReMap(oldMap, newMap);
  131. for (std::vector<pkgCache::PkgFileIterator*>::const_iterator i = Dynamic<pkgCache::PkgFileIterator>::toReMap.begin();
  132. i != Dynamic<pkgCache::PkgFileIterator>::toReMap.end(); ++i)
  133. (*i)->ReMap(oldMap, newMap);
  134. } /*}}}*/
  135. // CacheGenerator::WriteStringInMap /*{{{*/
  136. map_ptrloc pkgCacheGenerator::WriteStringInMap(const char *String,
  137. const unsigned long &Len) {
  138. void const * const oldMap = Map.Data();
  139. map_ptrloc const index = Map.WriteString(String, Len);
  140. if (index != 0)
  141. ReMap(oldMap, Map.Data());
  142. return index;
  143. }
  144. /*}}}*/
  145. // CacheGenerator::WriteStringInMap /*{{{*/
  146. map_ptrloc pkgCacheGenerator::WriteStringInMap(const char *String) {
  147. void const * const oldMap = Map.Data();
  148. map_ptrloc const index = Map.WriteString(String);
  149. if (index != 0)
  150. ReMap(oldMap, Map.Data());
  151. return index;
  152. }
  153. /*}}}*/
  154. map_ptrloc pkgCacheGenerator::AllocateInMap(const unsigned long &size) {/*{{{*/
  155. void const * const oldMap = Map.Data();
  156. map_ptrloc const index = Map.Allocate(size);
  157. if (index != 0)
  158. ReMap(oldMap, Map.Data());
  159. return index;
  160. }
  161. /*}}}*/
  162. // CacheGenerator::MergeList - Merge the package list /*{{{*/
  163. // ---------------------------------------------------------------------
  164. /* This provides the generation of the entries in the cache. Each loop
  165. goes through a single package record from the underlying parse engine. */
  166. bool pkgCacheGenerator::MergeList(ListParser &List,
  167. pkgCache::VerIterator *OutVer)
  168. {
  169. List.Owner = this;
  170. unsigned int Counter = 0;
  171. while (List.Step() == true)
  172. {
  173. string const PackageName = List.Package();
  174. if (PackageName.empty() == true)
  175. return false;
  176. Counter++;
  177. if (Counter % 100 == 0 && Progress != 0)
  178. Progress->Progress(List.Offset());
  179. string Arch = List.Architecture();
  180. string const Version = List.Version();
  181. if (Version.empty() == true && Arch.empty() == true)
  182. {
  183. // package descriptions
  184. if (MergeListGroup(List, PackageName) == false)
  185. return false;
  186. continue;
  187. }
  188. if (Arch.empty() == true)
  189. {
  190. // use the pseudo arch 'none' for arch-less packages
  191. Arch = "none";
  192. /* We might built a SingleArchCache here, which we don't want to blow up
  193. just for these :none packages to a proper MultiArchCache, so just ensure
  194. that we have always a native package structure first for SingleArch */
  195. pkgCache::PkgIterator NP;
  196. Dynamic<pkgCache::PkgIterator> DynPkg(NP);
  197. if (NewPackage(NP, PackageName, _config->Find("APT::Architecture")) == false)
  198. // TRANSLATOR: The first placeholder is a package name,
  199. // the other two should be copied verbatim as they include debug info
  200. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  201. PackageName.c_str(), "NewPackage", 0);
  202. }
  203. // Get a pointer to the package structure
  204. pkgCache::PkgIterator Pkg;
  205. Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
  206. if (NewPackage(Pkg, PackageName, Arch) == false)
  207. // TRANSLATOR: The first placeholder is a package name,
  208. // the other two should be copied verbatim as they include debug info
  209. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  210. PackageName.c_str(), "NewPackage", 1);
  211. if (Version.empty() == true)
  212. {
  213. if (MergeListPackage(List, Pkg) == false)
  214. return false;
  215. }
  216. else
  217. {
  218. if (MergeListVersion(List, Pkg, Version, OutVer) == false)
  219. return false;
  220. }
  221. if (OutVer != 0)
  222. {
  223. FoundFileDeps |= List.HasFileDeps();
  224. return true;
  225. }
  226. }
  227. if (Cache.HeaderP->PackageCount >= (1ULL<<sizeof(Cache.PkgP->ID)*8)-1)
  228. return _error->Error(_("Wow, you exceeded the number of package "
  229. "names this APT is capable of."));
  230. if (Cache.HeaderP->VersionCount >= (1ULL<<(sizeof(Cache.VerP->ID)*8))-1)
  231. return _error->Error(_("Wow, you exceeded the number of versions "
  232. "this APT is capable of."));
  233. if (Cache.HeaderP->DescriptionCount >= (1ULL<<(sizeof(Cache.DescP->ID)*8))-1)
  234. return _error->Error(_("Wow, you exceeded the number of descriptions "
  235. "this APT is capable of."));
  236. if (Cache.HeaderP->DependsCount >= (1ULL<<(sizeof(Cache.DepP->ID)*8))-1ULL)
  237. return _error->Error(_("Wow, you exceeded the number of dependencies "
  238. "this APT is capable of."));
  239. FoundFileDeps |= List.HasFileDeps();
  240. return true;
  241. }
  242. // CacheGenerator::MergeListGroup /*{{{*/
  243. bool pkgCacheGenerator::MergeListGroup(ListParser &List, std::string const &GrpName)
  244. {
  245. pkgCache::GrpIterator Grp = Cache.FindGrp(GrpName);
  246. // a group has no data on it's own, only packages have it but these
  247. // stanzas like this come from Translation- files to add descriptions,
  248. // but without a version we don't need a description for it…
  249. if (Grp.end() == true)
  250. return true;
  251. Dynamic<pkgCache::GrpIterator> DynGrp(Grp);
  252. pkgCache::PkgIterator Pkg;
  253. Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
  254. for (Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg))
  255. if (MergeListPackage(List, Pkg) == false)
  256. return false;
  257. return true;
  258. }
  259. /*}}}*/
  260. // CacheGenerator::MergeListPackage /*{{{*/
  261. bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg)
  262. {
  263. // we first process the package, then the descriptions
  264. // (for deb this package processing is in fact a no-op)
  265. pkgCache::VerIterator Ver(Cache);
  266. Dynamic<pkgCache::VerIterator> DynVer(Ver);
  267. if (List.UsePackage(Pkg, Ver) == false)
  268. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  269. Pkg.Name(), "UsePackage", 1);
  270. // Find the right version to write the description
  271. MD5SumValue CurMd5 = List.Description_md5();
  272. if (CurMd5.Value().empty() == true && List.Description("").empty() == true)
  273. return true;
  274. std::vector<std::string> availDesc = List.AvailableDescriptionLanguages();
  275. for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
  276. {
  277. pkgCache::DescIterator VerDesc = Ver.DescriptionList();
  278. // a version can only have one md5 describing it
  279. if (VerDesc.end() == true || MD5SumValue(VerDesc.md5()) != CurMd5)
  280. continue;
  281. map_ptrloc md5idx = VerDesc->md5sum;
  282. for (std::vector<std::string>::const_iterator CurLang = availDesc.begin(); CurLang != availDesc.end(); ++CurLang)
  283. {
  284. // don't add a new description if we have one for the given
  285. // md5 && language
  286. if (IsDuplicateDescription(VerDesc, CurMd5, *CurLang) == true)
  287. continue;
  288. AddNewDescription(List, Ver, *CurLang, CurMd5, md5idx);
  289. }
  290. // we can stop here as all "same" versions will share the description
  291. break;
  292. }
  293. return true;
  294. }
  295. /*}}}*/
  296. // CacheGenerator::MergeListVersion /*{{{*/
  297. bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg,
  298. std::string const &Version, pkgCache::VerIterator* &OutVer)
  299. {
  300. pkgCache::VerIterator Ver = Pkg.VersionList();
  301. Dynamic<pkgCache::VerIterator> DynVer(Ver);
  302. map_ptrloc *LastVer = &Pkg->VersionList;
  303. void const * oldMap = Map.Data();
  304. unsigned short const Hash = List.VersionHash();
  305. if (Ver.end() == false)
  306. {
  307. /* We know the list is sorted so we use that fact in the search.
  308. Insertion of new versions is done with correct sorting */
  309. int Res = 1;
  310. for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
  311. {
  312. Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
  313. // Version is higher as current version - insert here
  314. if (Res > 0)
  315. break;
  316. // Versionstrings are equal - is hash also equal?
  317. if (Res == 0 && List.SameVersion(Hash, Ver) == true)
  318. break;
  319. // proceed with the next till we have either the right
  320. // or we found another version (which will be lower)
  321. }
  322. /* We already have a version for this item, record that we saw it */
  323. if (Res == 0 && Ver.end() == false && Ver->Hash == Hash)
  324. {
  325. if (List.UsePackage(Pkg,Ver) == false)
  326. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  327. Pkg.Name(), "UsePackage", 2);
  328. if (NewFileVer(Ver,List) == false)
  329. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  330. Pkg.Name(), "NewFileVer", 1);
  331. // Read only a single record and return
  332. if (OutVer != 0)
  333. {
  334. *OutVer = Ver;
  335. return true;
  336. }
  337. return true;
  338. }
  339. }
  340. // Add a new version
  341. map_ptrloc const verindex = NewVersion(Ver, Version, Pkg.Index(), Hash, *LastVer);
  342. if (verindex == 0 && _error->PendingError())
  343. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  344. Pkg.Name(), "NewVersion", 1);
  345. if (oldMap != Map.Data())
  346. LastVer += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap;
  347. *LastVer = verindex;
  348. if (unlikely(List.NewVersion(Ver) == false))
  349. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  350. Pkg.Name(), "NewVersion", 2);
  351. if (unlikely(List.UsePackage(Pkg,Ver) == false))
  352. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  353. Pkg.Name(), "UsePackage", 3);
  354. if (unlikely(NewFileVer(Ver,List) == false))
  355. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  356. Pkg.Name(), "NewFileVer", 2);
  357. pkgCache::GrpIterator Grp = Pkg.Group();
  358. Dynamic<pkgCache::GrpIterator> DynGrp(Grp);
  359. /* If it is the first version of this package we need to add implicit
  360. Multi-Arch dependencies to all other package versions in the group now -
  361. otherwise we just add them for this new version */
  362. if (Pkg.VersionList()->NextVer == 0)
  363. {
  364. pkgCache::PkgIterator P = Grp.PackageList();
  365. Dynamic<pkgCache::PkgIterator> DynP(P);
  366. for (; P.end() != true; P = Grp.NextPkg(P))
  367. {
  368. if (P->ID == Pkg->ID)
  369. continue;
  370. pkgCache::VerIterator V = P.VersionList();
  371. Dynamic<pkgCache::VerIterator> DynV(V);
  372. for (; V.end() != true; ++V)
  373. if (unlikely(AddImplicitDepends(V, Pkg) == false))
  374. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  375. Pkg.Name(), "AddImplicitDepends", 1);
  376. }
  377. /* :none packages are packages without an architecture. They are forbidden by
  378. debian-policy, so usually they will only be in (old) dpkg status files -
  379. and dpkg will complain about them - and are pretty rare. We therefore do
  380. usually not create conflicts while the parent is created, but only if a :none
  381. package (= the target) appears. This creates incorrect dependencies on :none
  382. for architecture-specific dependencies on the package we copy from, but we
  383. will ignore this bug as architecture-specific dependencies are only allowed
  384. in jessie and until then the :none packages should be extinct (hopefully).
  385. In other words: This should work long enough to allow graceful removal of
  386. these packages, it is not supposed to allow users to keep using them … */
  387. if (strcmp(Pkg.Arch(), "none") == 0)
  388. {
  389. pkgCache::PkgIterator M = Grp.FindPreferredPkg();
  390. if (M.end() == false && Pkg != M)
  391. {
  392. pkgCache::DepIterator D = M.RevDependsList();
  393. Dynamic<pkgCache::DepIterator> DynD(D);
  394. for (; D.end() == false; ++D)
  395. {
  396. if ((D->Type != pkgCache::Dep::Conflicts &&
  397. D->Type != pkgCache::Dep::DpkgBreaks &&
  398. D->Type != pkgCache::Dep::Replaces) ||
  399. D.ParentPkg().Group() == Grp)
  400. continue;
  401. map_ptrloc *OldDepLast = NULL;
  402. pkgCache::VerIterator ConVersion = D.ParentVer();
  403. Dynamic<pkgCache::VerIterator> DynV(ConVersion);
  404. // duplicate the Conflicts/Breaks/Replaces for :none arch
  405. NewDepends(Pkg, ConVersion, D->Version,
  406. D->CompareOp, D->Type, OldDepLast);
  407. }
  408. }
  409. }
  410. }
  411. if (unlikely(AddImplicitDepends(Grp, Pkg, Ver) == false))
  412. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  413. Pkg.Name(), "AddImplicitDepends", 2);
  414. // Read only a single record and return
  415. if (OutVer != 0)
  416. {
  417. *OutVer = Ver;
  418. return true;
  419. }
  420. /* Record the Description(s) based on their master md5sum */
  421. MD5SumValue CurMd5 = List.Description_md5();
  422. if (CurMd5.Value().empty() == true && List.Description("").empty() == true)
  423. return true;
  424. /* Before we add a new description we first search in the group for
  425. a version with a description of the same MD5 - if so we reuse this
  426. description group instead of creating our own for this version */
  427. for (pkgCache::PkgIterator P = Grp.PackageList();
  428. P.end() == false; P = Grp.NextPkg(P))
  429. {
  430. for (pkgCache::VerIterator V = P.VersionList();
  431. V.end() == false; ++V)
  432. {
  433. if (V->DescriptionList == 0 || MD5SumValue(V.DescriptionList().md5()) != CurMd5)
  434. continue;
  435. Ver->DescriptionList = V->DescriptionList;
  436. }
  437. }
  438. // We haven't found reusable descriptions, so add the first description(s)
  439. map_ptrloc md5idx = Ver->DescriptionList == 0 ? 0 : Ver.DescriptionList()->md5sum;
  440. std::vector<std::string> availDesc = List.AvailableDescriptionLanguages();
  441. for (std::vector<std::string>::const_iterator CurLang = availDesc.begin(); CurLang != availDesc.end(); ++CurLang)
  442. if (AddNewDescription(List, Ver, *CurLang, CurMd5, md5idx) == false)
  443. return false;
  444. return true;
  445. }
  446. /*}}}*/
  447. bool pkgCacheGenerator::AddNewDescription(ListParser &List, pkgCache::VerIterator &Ver, std::string const &lang, MD5SumValue const &CurMd5, map_ptrloc &md5idx) /*{{{*/
  448. {
  449. pkgCache::DescIterator Desc;
  450. Dynamic<pkgCache::DescIterator> DynDesc(Desc);
  451. map_ptrloc const descindex = NewDescription(Desc, lang, CurMd5, md5idx);
  452. if (unlikely(descindex == 0 && _error->PendingError()))
  453. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  454. Ver.ParentPkg().Name(), "NewDescription", 1);
  455. md5idx = Desc->md5sum;
  456. Desc->ParentPkg = Ver.ParentPkg().Index();
  457. // we add at the end, so that the start is constant as we need
  458. // that to be able to efficiently share these lists
  459. pkgCache::DescIterator VerDesc = Ver.DescriptionList(); // old value might be invalid after ReMap
  460. for (;VerDesc.end() == false && VerDesc->NextDesc != 0; ++VerDesc);
  461. map_ptrloc * const LastNextDesc = (VerDesc.end() == true) ? &Ver->DescriptionList : &VerDesc->NextDesc;
  462. *LastNextDesc = descindex;
  463. if (NewFileDesc(Desc,List) == false)
  464. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  465. Ver.ParentPkg().Name(), "NewFileDesc", 1);
  466. return true;
  467. }
  468. /*}}}*/
  469. /*}}}*/
  470. // CacheGenerator::MergeFileProvides - Merge file provides /*{{{*/
  471. // ---------------------------------------------------------------------
  472. /* If we found any file depends while parsing the main list we need to
  473. resolve them. Since it is undesired to load the entire list of files
  474. into the cache as virtual packages we do a two stage effort. MergeList
  475. identifies the file depends and this creates Provdies for them by
  476. re-parsing all the indexs. */
  477. bool pkgCacheGenerator::MergeFileProvides(ListParser &List)
  478. {
  479. List.Owner = this;
  480. unsigned int Counter = 0;
  481. while (List.Step() == true)
  482. {
  483. string PackageName = List.Package();
  484. if (PackageName.empty() == true)
  485. return false;
  486. string Version = List.Version();
  487. if (Version.empty() == true)
  488. continue;
  489. pkgCache::PkgIterator Pkg = Cache.FindPkg(PackageName);
  490. Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
  491. if (Pkg.end() == true)
  492. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  493. PackageName.c_str(), "FindPkg", 1);
  494. Counter++;
  495. if (Counter % 100 == 0 && Progress != 0)
  496. Progress->Progress(List.Offset());
  497. unsigned short Hash = List.VersionHash();
  498. pkgCache::VerIterator Ver = Pkg.VersionList();
  499. Dynamic<pkgCache::VerIterator> DynVer(Ver);
  500. for (; Ver.end() == false; ++Ver)
  501. {
  502. if (List.SameVersion(Hash, Ver) == true && Version == Ver.VerStr())
  503. {
  504. if (List.CollectFileProvides(Cache,Ver) == false)
  505. return _error->Error(_("Error occurred while processing %s (%s%d)"),
  506. PackageName.c_str(), "CollectFileProvides", 1);
  507. break;
  508. }
  509. }
  510. if (Ver.end() == true)
  511. _error->Warning(_("Package %s %s was not found while processing file dependencies"),PackageName.c_str(),Version.c_str());
  512. }
  513. return true;
  514. }
  515. /*}}}*/
  516. // CacheGenerator::NewGroup - Add a new group /*{{{*/
  517. // ---------------------------------------------------------------------
  518. /* This creates a new group structure and adds it to the hash table */
  519. bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, const string &Name)
  520. {
  521. Grp = Cache.FindGrp(Name);
  522. if (Grp.end() == false)
  523. return true;
  524. // Get a structure
  525. map_ptrloc const Group = AllocateInMap(sizeof(pkgCache::Group));
  526. if (unlikely(Group == 0))
  527. return false;
  528. Grp = pkgCache::GrpIterator(Cache, Cache.GrpP + Group);
  529. map_ptrloc const idxName = WriteStringInMap(Name);
  530. if (unlikely(idxName == 0))
  531. return false;
  532. Grp->Name = idxName;
  533. // Insert it into the hash table
  534. unsigned long const Hash = Cache.Hash(Name);
  535. map_ptrloc *insertAt = &Cache.HeaderP->GrpHashTable[Hash];
  536. while (*insertAt != 0 && strcasecmp(Name.c_str(), Cache.StrP + (Cache.GrpP + *insertAt)->Name) > 0)
  537. insertAt = &(Cache.GrpP + *insertAt)->Next;
  538. Grp->Next = *insertAt;
  539. *insertAt = Group;
  540. Grp->ID = Cache.HeaderP->GroupCount++;
  541. return true;
  542. }
  543. /*}}}*/
  544. // CacheGenerator::NewPackage - Add a new package /*{{{*/
  545. // ---------------------------------------------------------------------
  546. /* This creates a new package structure and adds it to the hash table */
  547. bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name,
  548. const string &Arch) {
  549. pkgCache::GrpIterator Grp;
  550. Dynamic<pkgCache::GrpIterator> DynGrp(Grp);
  551. if (unlikely(NewGroup(Grp, Name) == false))
  552. return false;
  553. Pkg = Grp.FindPkg(Arch);
  554. if (Pkg.end() == false)
  555. return true;
  556. // Get a structure
  557. map_ptrloc const Package = AllocateInMap(sizeof(pkgCache::Package));
  558. if (unlikely(Package == 0))
  559. return false;
  560. Pkg = pkgCache::PkgIterator(Cache,Cache.PkgP + Package);
  561. // Insert the package into our package list
  562. if (Grp->FirstPackage == 0) // the group is new
  563. {
  564. Grp->FirstPackage = Package;
  565. // Insert it into the hash table
  566. unsigned long const Hash = Cache.Hash(Name);
  567. map_ptrloc *insertAt = &Cache.HeaderP->PkgHashTable[Hash];
  568. while (*insertAt != 0 && strcasecmp(Name.c_str(), Cache.StrP + (Cache.PkgP + *insertAt)->Name) > 0)
  569. insertAt = &(Cache.PkgP + *insertAt)->NextPackage;
  570. Pkg->NextPackage = *insertAt;
  571. *insertAt = Package;
  572. }
  573. else // Group the Packages together
  574. {
  575. // this package is the new last package
  576. pkgCache::PkgIterator LastPkg(Cache, Cache.PkgP + Grp->LastPackage);
  577. Pkg->NextPackage = LastPkg->NextPackage;
  578. LastPkg->NextPackage = Package;
  579. }
  580. Grp->LastPackage = Package;
  581. // Set the name, arch and the ID
  582. Pkg->Name = Grp->Name;
  583. Pkg->Group = Grp.Index();
  584. // all is mapped to the native architecture
  585. map_ptrloc const idxArch = (Arch == "all") ? Cache.HeaderP->Architecture : WriteUniqString(Arch.c_str());
  586. if (unlikely(idxArch == 0))
  587. return false;
  588. Pkg->Arch = idxArch;
  589. Pkg->ID = Cache.HeaderP->PackageCount++;
  590. return true;
  591. }
  592. /*}}}*/
  593. // CacheGenerator::AddImplicitDepends /*{{{*/
  594. bool pkgCacheGenerator::AddImplicitDepends(pkgCache::GrpIterator &G,
  595. pkgCache::PkgIterator &P,
  596. pkgCache::VerIterator &V)
  597. {
  598. // copy P.Arch() into a string here as a cache remap
  599. // in NewDepends() later may alter the pointer location
  600. string Arch = P.Arch() == NULL ? "" : P.Arch();
  601. map_ptrloc *OldDepLast = NULL;
  602. /* MultiArch handling introduces a lot of implicit Dependencies:
  603. - MultiArch: same → Co-Installable if they have the same version
  604. - All others conflict with all other group members */
  605. bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
  606. pkgCache::PkgIterator D = G.PackageList();
  607. Dynamic<pkgCache::PkgIterator> DynD(D);
  608. map_ptrloc const VerStrIdx = V->VerStr;
  609. for (; D.end() != true; D = G.NextPkg(D))
  610. {
  611. if (Arch == D.Arch() || D->VersionList == 0)
  612. continue;
  613. /* We allow only one installed arch at the time
  614. per group, therefore each group member conflicts
  615. with all other group members */
  616. if (coInstall == true)
  617. {
  618. // Replaces: ${self}:other ( << ${binary:Version})
  619. NewDepends(D, V, VerStrIdx,
  620. pkgCache::Dep::Less, pkgCache::Dep::Replaces,
  621. OldDepLast);
  622. // Breaks: ${self}:other (!= ${binary:Version})
  623. NewDepends(D, V, VerStrIdx,
  624. pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks,
  625. OldDepLast);
  626. } else {
  627. // Conflicts: ${self}:other
  628. NewDepends(D, V, 0,
  629. pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
  630. OldDepLast);
  631. }
  632. }
  633. return true;
  634. }
  635. bool pkgCacheGenerator::AddImplicitDepends(pkgCache::VerIterator &V,
  636. pkgCache::PkgIterator &D)
  637. {
  638. /* MultiArch handling introduces a lot of implicit Dependencies:
  639. - MultiArch: same → Co-Installable if they have the same version
  640. - All others conflict with all other group members */
  641. map_ptrloc *OldDepLast = NULL;
  642. bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
  643. if (coInstall == true)
  644. {
  645. map_ptrloc const VerStrIdx = V->VerStr;
  646. // Replaces: ${self}:other ( << ${binary:Version})
  647. NewDepends(D, V, VerStrIdx,
  648. pkgCache::Dep::Less, pkgCache::Dep::Replaces,
  649. OldDepLast);
  650. // Breaks: ${self}:other (!= ${binary:Version})
  651. NewDepends(D, V, VerStrIdx,
  652. pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks,
  653. OldDepLast);
  654. } else {
  655. // Conflicts: ${self}:other
  656. NewDepends(D, V, 0,
  657. pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
  658. OldDepLast);
  659. }
  660. return true;
  661. }
  662. /*}}}*/
  663. // CacheGenerator::NewFileVer - Create a new File<->Version association /*{{{*/
  664. // ---------------------------------------------------------------------
  665. /* */
  666. bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
  667. ListParser &List)
  668. {
  669. if (CurrentFile == 0)
  670. return true;
  671. // Get a structure
  672. map_ptrloc const VerFile = AllocateInMap(sizeof(pkgCache::VerFile));
  673. if (VerFile == 0)
  674. return 0;
  675. pkgCache::VerFileIterator VF(Cache,Cache.VerFileP + VerFile);
  676. VF->File = CurrentFile - Cache.PkgFileP;
  677. // Link it to the end of the list
  678. map_ptrloc *Last = &Ver->FileList;
  679. for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; ++V)
  680. Last = &V->NextFile;
  681. VF->NextFile = *Last;
  682. *Last = VF.Index();
  683. VF->Offset = List.Offset();
  684. VF->Size = List.Size();
  685. if (Cache.HeaderP->MaxVerFileSize < VF->Size)
  686. Cache.HeaderP->MaxVerFileSize = VF->Size;
  687. Cache.HeaderP->VerFileCount++;
  688. return true;
  689. }
  690. /*}}}*/
  691. // CacheGenerator::NewVersion - Create a new Version /*{{{*/
  692. // ---------------------------------------------------------------------
  693. /* This puts a version structure in the linked list */
  694. unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
  695. const string &VerStr,
  696. map_ptrloc const ParentPkg,
  697. unsigned long const Hash,
  698. unsigned long Next)
  699. {
  700. // Get a structure
  701. map_ptrloc const Version = AllocateInMap(sizeof(pkgCache::Version));
  702. if (Version == 0)
  703. return 0;
  704. // Fill it in
  705. Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
  706. //Dynamic<pkgCache::VerIterator> DynV(Ver); // caller MergeListVersion already takes care of it
  707. Ver->NextVer = Next;
  708. Ver->ParentPkg = ParentPkg;
  709. Ver->Hash = Hash;
  710. Ver->ID = Cache.HeaderP->VersionCount++;
  711. // try to find the version string in the group for reuse
  712. pkgCache::PkgIterator Pkg = Ver.ParentPkg();
  713. pkgCache::GrpIterator Grp = Pkg.Group();
  714. if (Pkg.end() == false && Grp.end() == false)
  715. {
  716. for (pkgCache::PkgIterator P = Grp.PackageList(); P.end() == false; P = Grp.NextPkg(P))
  717. {
  718. if (Pkg == P)
  719. continue;
  720. for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
  721. {
  722. int const cmp = strcmp(V.VerStr(), VerStr.c_str());
  723. if (cmp == 0)
  724. {
  725. Ver->VerStr = V->VerStr;
  726. return Version;
  727. }
  728. else if (cmp < 0)
  729. break;
  730. }
  731. }
  732. }
  733. // haven't found the version string, so create
  734. map_ptrloc const idxVerStr = WriteStringInMap(VerStr);
  735. if (unlikely(idxVerStr == 0))
  736. return 0;
  737. Ver->VerStr = idxVerStr;
  738. return Version;
  739. }
  740. /*}}}*/
  741. // CacheGenerator::NewFileDesc - Create a new File<->Desc association /*{{{*/
  742. // ---------------------------------------------------------------------
  743. /* */
  744. bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
  745. ListParser &List)
  746. {
  747. if (CurrentFile == 0)
  748. return true;
  749. // Get a structure
  750. map_ptrloc const DescFile = AllocateInMap(sizeof(pkgCache::DescFile));
  751. if (DescFile == 0)
  752. return false;
  753. pkgCache::DescFileIterator DF(Cache,Cache.DescFileP + DescFile);
  754. DF->File = CurrentFile - Cache.PkgFileP;
  755. // Link it to the end of the list
  756. map_ptrloc *Last = &Desc->FileList;
  757. for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; ++D)
  758. Last = &D->NextFile;
  759. DF->NextFile = *Last;
  760. *Last = DF.Index();
  761. DF->Offset = List.Offset();
  762. DF->Size = List.Size();
  763. if (Cache.HeaderP->MaxDescFileSize < DF->Size)
  764. Cache.HeaderP->MaxDescFileSize = DF->Size;
  765. Cache.HeaderP->DescFileCount++;
  766. return true;
  767. }
  768. /*}}}*/
  769. // CacheGenerator::NewDescription - Create a new Description /*{{{*/
  770. // ---------------------------------------------------------------------
  771. /* This puts a description structure in the linked list */
  772. map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
  773. const string &Lang,
  774. const MD5SumValue &md5sum,
  775. map_ptrloc idxmd5str)
  776. {
  777. // Get a structure
  778. map_ptrloc const Description = AllocateInMap(sizeof(pkgCache::Description));
  779. if (Description == 0)
  780. return 0;
  781. // Fill it in
  782. Desc = pkgCache::DescIterator(Cache,Cache.DescP + Description);
  783. Desc->ID = Cache.HeaderP->DescriptionCount++;
  784. map_ptrloc const idxlanguage_code = WriteUniqString(Lang);
  785. if (unlikely(idxlanguage_code == 0))
  786. return 0;
  787. Desc->language_code = idxlanguage_code;
  788. if (idxmd5str != 0)
  789. Desc->md5sum = idxmd5str;
  790. else
  791. {
  792. map_ptrloc const idxmd5sum = WriteStringInMap(md5sum.Value());
  793. if (unlikely(idxmd5sum == 0))
  794. return 0;
  795. Desc->md5sum = idxmd5sum;
  796. }
  797. return Description;
  798. }
  799. /*}}}*/
  800. // CacheGenerator::NewDepends - Create a dependency element /*{{{*/
  801. // ---------------------------------------------------------------------
  802. /* This creates a dependency element in the tree. It is linked to the
  803. version and to the package that it is pointing to. */
  804. bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
  805. pkgCache::VerIterator &Ver,
  806. string const &Version,
  807. unsigned int const &Op,
  808. unsigned int const &Type,
  809. map_ptrloc* &OldDepLast)
  810. {
  811. map_ptrloc index = 0;
  812. if (Version.empty() == false)
  813. {
  814. int const CmpOp = Op & 0x0F;
  815. // =-deps are used (79:1) for lockstep on same-source packages (e.g. data-packages)
  816. if (CmpOp == pkgCache::Dep::Equals && strcmp(Version.c_str(), Ver.VerStr()) == 0)
  817. index = Ver->VerStr;
  818. if (index == 0)
  819. {
  820. void const * const oldMap = Map.Data();
  821. index = WriteStringInMap(Version);
  822. if (unlikely(index == 0))
  823. return false;
  824. if (OldDepLast != 0 && oldMap != Map.Data())
  825. OldDepLast += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap;
  826. }
  827. }
  828. return NewDepends(Pkg, Ver, index, Op, Type, OldDepLast);
  829. }
  830. bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
  831. pkgCache::VerIterator &Ver,
  832. map_ptrloc const Version,
  833. unsigned int const &Op,
  834. unsigned int const &Type,
  835. map_ptrloc* &OldDepLast)
  836. {
  837. void const * const oldMap = Map.Data();
  838. // Get a structure
  839. map_ptrloc const Dependency = AllocateInMap(sizeof(pkgCache::Dependency));
  840. if (unlikely(Dependency == 0))
  841. return false;
  842. // Fill it in
  843. pkgCache::DepIterator Dep(Cache,Cache.DepP + Dependency);
  844. Dynamic<pkgCache::DepIterator> DynDep(Dep);
  845. Dep->ParentVer = Ver.Index();
  846. Dep->Type = Type;
  847. Dep->CompareOp = Op;
  848. Dep->Version = Version;
  849. Dep->ID = Cache.HeaderP->DependsCount++;
  850. // Link it to the package
  851. Dep->Package = Pkg.Index();
  852. Dep->NextRevDepends = Pkg->RevDepends;
  853. Pkg->RevDepends = Dep.Index();
  854. // Do we know where to link the Dependency to?
  855. if (OldDepLast == NULL)
  856. {
  857. OldDepLast = &Ver->DependsList;
  858. for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D)
  859. OldDepLast = &D->NextDepends;
  860. } else if (oldMap != Map.Data())
  861. OldDepLast += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap;
  862. Dep->NextDepends = *OldDepLast;
  863. *OldDepLast = Dep.Index();
  864. OldDepLast = &Dep->NextDepends;
  865. return true;
  866. }
  867. /*}}}*/
  868. // ListParser::NewDepends - Create the environment for a new dependency /*{{{*/
  869. // ---------------------------------------------------------------------
  870. /* This creates a Group and the Package to link this dependency to if
  871. needed and handles also the caching of the old endpoint */
  872. bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator &Ver,
  873. const string &PackageName,
  874. const string &Arch,
  875. const string &Version,
  876. unsigned int Op,
  877. unsigned int Type)
  878. {
  879. pkgCache::GrpIterator Grp;
  880. Dynamic<pkgCache::GrpIterator> DynGrp(Grp);
  881. if (unlikely(Owner->NewGroup(Grp, PackageName) == false))
  882. return false;
  883. // Locate the target package
  884. pkgCache::PkgIterator Pkg = Grp.FindPkg(Arch);
  885. // we don't create 'none' packages and their dependencies if we can avoid it …
  886. if (Pkg.end() == true && Arch == "none" && strcmp(Ver.ParentPkg().Arch(), "none") != 0)
  887. return true;
  888. Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
  889. if (Pkg.end() == true) {
  890. if (unlikely(Owner->NewPackage(Pkg, PackageName, Arch) == false))
  891. return false;
  892. }
  893. // Is it a file dependency?
  894. if (unlikely(PackageName[0] == '/'))
  895. FoundFileDeps = true;
  896. /* Caching the old end point speeds up generation substantially */
  897. if (OldDepVer != Ver) {
  898. OldDepLast = NULL;
  899. OldDepVer = Ver;
  900. }
  901. return Owner->NewDepends(Pkg, Ver, Version, Op, Type, OldDepLast);
  902. }
  903. /*}}}*/
  904. // ListParser::NewProvides - Create a Provides element /*{{{*/
  905. // ---------------------------------------------------------------------
  906. /* */
  907. bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
  908. const string &PkgName,
  909. const string &PkgArch,
  910. const string &Version)
  911. {
  912. pkgCache &Cache = Owner->Cache;
  913. // We do not add self referencing provides
  914. if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() ||
  915. (PkgArch == "all" && strcmp((Cache.StrP + Cache.HeaderP->Architecture), Ver.ParentPkg().Arch()) == 0)))
  916. return true;
  917. // Get a structure
  918. map_ptrloc const Provides = Owner->AllocateInMap(sizeof(pkgCache::Provides));
  919. if (unlikely(Provides == 0))
  920. return false;
  921. Cache.HeaderP->ProvidesCount++;
  922. // Fill it in
  923. pkgCache::PrvIterator Prv(Cache,Cache.ProvideP + Provides,Cache.PkgP);
  924. Dynamic<pkgCache::PrvIterator> DynPrv(Prv);
  925. Prv->Version = Ver.Index();
  926. Prv->NextPkgProv = Ver->ProvidesList;
  927. Ver->ProvidesList = Prv.Index();
  928. if (Version.empty() == false) {
  929. map_ptrloc const idxProvideVersion = WriteString(Version);
  930. Prv->ProvideVersion = idxProvideVersion;
  931. if (unlikely(idxProvideVersion == 0))
  932. return false;
  933. }
  934. // Locate the target package
  935. pkgCache::PkgIterator Pkg;
  936. Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
  937. if (unlikely(Owner->NewPackage(Pkg,PkgName, PkgArch) == false))
  938. return false;
  939. // Link it to the package
  940. Prv->ParentPkg = Pkg.Index();
  941. Prv->NextProvides = Pkg->ProvidesList;
  942. Pkg->ProvidesList = Prv.Index();
  943. return true;
  944. }
  945. /*}}}*/
  946. bool pkgCacheGenerator::ListParser::SameVersion(unsigned short const Hash,/*{{{*/
  947. pkgCache::VerIterator const &Ver)
  948. {
  949. return Hash == Ver->Hash;
  950. }
  951. /*}}}*/
  952. // CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/
  953. // ---------------------------------------------------------------------
  954. /* This is used to select which file is to be associated with all newly
  955. added versions. The caller is responsible for setting the IMS fields. */
  956. bool pkgCacheGenerator::SelectFile(const string &File,const string &Site,
  957. const pkgIndexFile &Index,
  958. unsigned long Flags)
  959. {
  960. // Get some space for the structure
  961. map_ptrloc const idxFile = AllocateInMap(sizeof(*CurrentFile));
  962. if (unlikely(idxFile == 0))
  963. return false;
  964. CurrentFile = Cache.PkgFileP + idxFile;
  965. // Fill it in
  966. map_ptrloc const idxFileName = WriteStringInMap(File);
  967. map_ptrloc const idxSite = WriteUniqString(Site);
  968. if (unlikely(idxFileName == 0 || idxSite == 0))
  969. return false;
  970. CurrentFile->FileName = idxFileName;
  971. CurrentFile->Site = idxSite;
  972. CurrentFile->NextFile = Cache.HeaderP->FileList;
  973. CurrentFile->Flags = Flags;
  974. CurrentFile->ID = Cache.HeaderP->PackageFileCount;
  975. map_ptrloc const idxIndexType = WriteUniqString(Index.GetType()->Label);
  976. if (unlikely(idxIndexType == 0))
  977. return false;
  978. CurrentFile->IndexType = idxIndexType;
  979. PkgFileName = File;
  980. Cache.HeaderP->FileList = CurrentFile - Cache.PkgFileP;
  981. Cache.HeaderP->PackageFileCount++;
  982. if (Progress != 0)
  983. Progress->SubProgress(Index.Size());
  984. return true;
  985. }
  986. /*}}}*/
  987. // CacheGenerator::WriteUniqueString - Insert a unique string /*{{{*/
  988. // ---------------------------------------------------------------------
  989. /* This is used to create handles to strings. Given the same text it
  990. always returns the same number */
  991. unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
  992. unsigned int Size)
  993. {
  994. /* We use a very small transient hash table here, this speeds up generation
  995. by a fair amount on slower machines */
  996. pkgCache::StringItem *&Bucket = UniqHash[(S[0]*5 + S[1]) % _count(UniqHash)];
  997. if (Bucket != 0 &&
  998. stringcmp(S,S+Size,Cache.StrP + Bucket->String) == 0)
  999. return Bucket->String;
  1000. // Search for an insertion point
  1001. pkgCache::StringItem *I = Cache.StringItemP + Cache.HeaderP->StringList;
  1002. int Res = 1;
  1003. map_ptrloc *Last = &Cache.HeaderP->StringList;
  1004. for (; I != Cache.StringItemP; Last = &I->NextItem,
  1005. I = Cache.StringItemP + I->NextItem)
  1006. {
  1007. Res = stringcmp(S,S+Size,Cache.StrP + I->String);
  1008. if (Res >= 0)
  1009. break;
  1010. }
  1011. // Match
  1012. if (Res == 0)
  1013. {
  1014. Bucket = I;
  1015. return I->String;
  1016. }
  1017. // Get a structure
  1018. void const * const oldMap = Map.Data();
  1019. map_ptrloc const Item = AllocateInMap(sizeof(pkgCache::StringItem));
  1020. if (Item == 0)
  1021. return 0;
  1022. map_ptrloc const idxString = WriteStringInMap(S,Size);
  1023. if (unlikely(idxString == 0))
  1024. return 0;
  1025. if (oldMap != Map.Data()) {
  1026. Last += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap;
  1027. I += (pkgCache::StringItem const * const) Map.Data() - (pkgCache::StringItem const * const) oldMap;
  1028. }
  1029. *Last = Item;
  1030. // Fill in the structure
  1031. pkgCache::StringItem *ItemP = Cache.StringItemP + Item;
  1032. ItemP->NextItem = I - Cache.StringItemP;
  1033. ItemP->String = idxString;
  1034. Bucket = ItemP;
  1035. return ItemP->String;
  1036. }
  1037. /*}}}*/
  1038. // CheckValidity - Check that a cache is up-to-date /*{{{*/
  1039. // ---------------------------------------------------------------------
  1040. /* This just verifies that each file in the list of index files exists,
  1041. has matching attributes with the cache and the cache does not have
  1042. any extra files. */
  1043. static bool CheckValidity(const string &CacheFile,
  1044. pkgSourceList &List,
  1045. FileIterator Start,
  1046. FileIterator End,
  1047. MMap **OutMap = 0)
  1048. {
  1049. bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
  1050. // No file, certainly invalid
  1051. if (CacheFile.empty() == true || FileExists(CacheFile) == false)
  1052. {
  1053. if (Debug == true)
  1054. std::clog << "CacheFile doesn't exist" << std::endl;
  1055. return false;
  1056. }
  1057. if (List.GetLastModifiedTime() > GetModificationTime(CacheFile))
  1058. {
  1059. if (Debug == true)
  1060. std::clog << "sources.list is newer than the cache" << std::endl;
  1061. return false;
  1062. }
  1063. // Map it
  1064. FileFd CacheF(CacheFile,FileFd::ReadOnly);
  1065. SPtr<MMap> Map = new MMap(CacheF,0);
  1066. pkgCache Cache(Map);
  1067. if (_error->PendingError() == true || Map->Size() == 0)
  1068. {
  1069. if (Debug == true)
  1070. std::clog << "Errors are pending or Map is empty()" << std::endl;
  1071. _error->Discard();
  1072. return false;
  1073. }
  1074. /* Now we check every index file, see if it is in the cache,
  1075. verify the IMS data and check that it is on the disk too.. */
  1076. SPtrArray<bool> Visited = new bool[Cache.HeaderP->PackageFileCount];
  1077. memset(Visited,0,sizeof(*Visited)*Cache.HeaderP->PackageFileCount);
  1078. for (; Start != End; ++Start)
  1079. {
  1080. if (Debug == true)
  1081. std::clog << "Checking PkgFile " << (*Start)->Describe() << ": ";
  1082. if ((*Start)->HasPackages() == false)
  1083. {
  1084. if (Debug == true)
  1085. std::clog << "Has NO packages" << std::endl;
  1086. continue;
  1087. }
  1088. if ((*Start)->Exists() == false)
  1089. {
  1090. #if 0 // mvo: we no longer give a message here (Default Sources spec)
  1091. _error->WarningE("stat",_("Couldn't stat source package list %s"),
  1092. (*Start)->Describe().c_str());
  1093. #endif
  1094. if (Debug == true)
  1095. std::clog << "file doesn't exist" << std::endl;
  1096. continue;
  1097. }
  1098. // FindInCache is also expected to do an IMS check.
  1099. pkgCache::PkgFileIterator File = (*Start)->FindInCache(Cache);
  1100. if (File.end() == true)
  1101. {
  1102. if (Debug == true)
  1103. std::clog << "FindInCache returned end-Pointer" << std::endl;
  1104. return false;
  1105. }
  1106. Visited[File->ID] = true;
  1107. if (Debug == true)
  1108. std::clog << "with ID " << File->ID << " is valid" << std::endl;
  1109. }
  1110. for (unsigned I = 0; I != Cache.HeaderP->PackageFileCount; I++)
  1111. if (Visited[I] == false)
  1112. {
  1113. if (Debug == true)
  1114. std::clog << "File with ID" << I << " wasn't visited" << std::endl;
  1115. return false;
  1116. }
  1117. if (_error->PendingError() == true)
  1118. {
  1119. if (Debug == true)
  1120. {
  1121. std::clog << "Validity failed because of pending errors:" << std::endl;
  1122. _error->DumpErrors();
  1123. }
  1124. _error->Discard();
  1125. return false;
  1126. }
  1127. if (OutMap != 0)
  1128. *OutMap = Map.UnGuard();
  1129. return true;
  1130. }
  1131. /*}}}*/
  1132. // ComputeSize - Compute the total size of a bunch of files /*{{{*/
  1133. // ---------------------------------------------------------------------
  1134. /* Size is kind of an abstract notion that is only used for the progress
  1135. meter */
  1136. static unsigned long ComputeSize(FileIterator Start,FileIterator End)
  1137. {
  1138. unsigned long TotalSize = 0;
  1139. for (; Start < End; ++Start)
  1140. {
  1141. if ((*Start)->HasPackages() == false)
  1142. continue;
  1143. TotalSize += (*Start)->Size();
  1144. }
  1145. return TotalSize;
  1146. }
  1147. /*}}}*/
  1148. // BuildCache - Merge the list of index files into the cache /*{{{*/
  1149. // ---------------------------------------------------------------------
  1150. /* */
  1151. static bool BuildCache(pkgCacheGenerator &Gen,
  1152. OpProgress *Progress,
  1153. unsigned long &CurrentSize,unsigned long TotalSize,
  1154. FileIterator Start, FileIterator End)
  1155. {
  1156. FileIterator I;
  1157. for (I = Start; I != End; ++I)
  1158. {
  1159. if ((*I)->HasPackages() == false)
  1160. continue;
  1161. if ((*I)->Exists() == false)
  1162. continue;
  1163. if ((*I)->FindInCache(Gen.GetCache()).end() == false)
  1164. {
  1165. _error->Warning("Duplicate sources.list entry %s",
  1166. (*I)->Describe().c_str());
  1167. continue;
  1168. }
  1169. unsigned long Size = (*I)->Size();
  1170. if (Progress != NULL)
  1171. Progress->OverallProgress(CurrentSize,TotalSize,Size,_("Reading package lists"));
  1172. CurrentSize += Size;
  1173. if ((*I)->Merge(Gen,Progress) == false)
  1174. return false;
  1175. }
  1176. if (Gen.HasFileDeps() == true)
  1177. {
  1178. if (Progress != NULL)
  1179. Progress->Done();
  1180. TotalSize = ComputeSize(Start, End);
  1181. CurrentSize = 0;
  1182. for (I = Start; I != End; ++I)
  1183. {
  1184. unsigned long Size = (*I)->Size();
  1185. if (Progress != NULL)
  1186. Progress->OverallProgress(CurrentSize,TotalSize,Size,_("Collecting File Provides"));
  1187. CurrentSize += Size;
  1188. if ((*I)->MergeFileProvides(Gen,Progress) == false)
  1189. return false;
  1190. }
  1191. }
  1192. return true;
  1193. }
  1194. /*}}}*/
  1195. // CacheGenerator::CreateDynamicMMap - load an mmap with configuration options /*{{{*/
  1196. DynamicMMap* pkgCacheGenerator::CreateDynamicMMap(FileFd *CacheF, unsigned long Flags) {
  1197. unsigned long const MapStart = _config->FindI("APT::Cache-Start", 24*1024*1024);
  1198. unsigned long const MapGrow = _config->FindI("APT::Cache-Grow", 1*1024*1024);
  1199. unsigned long const MapLimit = _config->FindI("APT::Cache-Limit", 0);
  1200. Flags |= MMap::Moveable;
  1201. if (_config->FindB("APT::Cache-Fallback", false) == true)
  1202. Flags |= MMap::Fallback;
  1203. if (CacheF != NULL)
  1204. return new DynamicMMap(*CacheF, Flags, MapStart, MapGrow, MapLimit);
  1205. else
  1206. return new DynamicMMap(Flags, MapStart, MapGrow, MapLimit);
  1207. }
  1208. /*}}}*/
  1209. // CacheGenerator::MakeStatusCache - Construct the status cache /*{{{*/
  1210. // ---------------------------------------------------------------------
  1211. /* This makes sure that the status cache (the cache that has all
  1212. index files from the sources list and all local ones) is ready
  1213. to be mmaped. If OutMap is not zero then a MMap object representing
  1214. the cache will be stored there. This is pretty much mandetory if you
  1215. are using AllowMem. AllowMem lets the function be run as non-root
  1216. where it builds the cache 'fast' into a memory buffer. */
  1217. APT_DEPRECATED bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
  1218. MMap **OutMap, bool AllowMem)
  1219. { return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); }
  1220. bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
  1221. MMap **OutMap,bool AllowMem)
  1222. {
  1223. bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
  1224. std::vector<pkgIndexFile *> Files;
  1225. for (std::vector<metaIndex *>::const_iterator i = List.begin();
  1226. i != List.end();
  1227. ++i)
  1228. {
  1229. std::vector <pkgIndexFile *> *Indexes = (*i)->GetIndexFiles();
  1230. for (std::vector<pkgIndexFile *>::const_iterator j = Indexes->begin();
  1231. j != Indexes->end();
  1232. ++j)
  1233. Files.push_back (*j);
  1234. }
  1235. unsigned long const EndOfSource = Files.size();
  1236. if (_system->AddStatusFiles(Files) == false)
  1237. return false;
  1238. // Decide if we can write to the files..
  1239. string const CacheFile = _config->FindFile("Dir::Cache::pkgcache");
  1240. string const SrcCacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
  1241. // ensure the cache directory exists
  1242. if (CacheFile.empty() == false || SrcCacheFile.empty() == false)
  1243. {
  1244. string dir = _config->FindDir("Dir::Cache");
  1245. size_t const len = dir.size();
  1246. if (len > 5 && dir.find("/apt/", len - 6, 5) == len - 5)
  1247. dir = dir.substr(0, len - 5);
  1248. if (CacheFile.empty() == false)
  1249. CreateDirectory(dir, flNotFile(CacheFile));
  1250. if (SrcCacheFile.empty() == false)
  1251. CreateDirectory(dir, flNotFile(SrcCacheFile));
  1252. }
  1253. // Decide if we can write to the cache
  1254. bool Writeable = false;
  1255. if (CacheFile.empty() == false)
  1256. Writeable = access(flNotFile(CacheFile).c_str(),W_OK) == 0;
  1257. else
  1258. if (SrcCacheFile.empty() == false)
  1259. Writeable = access(flNotFile(SrcCacheFile).c_str(),W_OK) == 0;
  1260. if (Debug == true)
  1261. std::clog << "Do we have write-access to the cache files? " << (Writeable ? "YES" : "NO") << std::endl;
  1262. if (Writeable == false && AllowMem == false && CacheFile.empty() == false)
  1263. return _error->Error(_("Unable to write to %s"),flNotFile(CacheFile).c_str());
  1264. if (Progress != NULL)
  1265. Progress->OverallProgress(0,1,1,_("Reading package lists"));
  1266. // Cache is OK, Fin.
  1267. if (CheckValidity(CacheFile, List, Files.begin(),Files.end(),OutMap) == true)
  1268. {
  1269. if (Progress != NULL)
  1270. Progress->OverallProgress(1,1,1,_("Reading package lists"));
  1271. if (Debug == true)
  1272. std::clog << "pkgcache.bin is valid - no need to build anything" << std::endl;
  1273. return true;
  1274. }
  1275. else if (Debug == true)
  1276. std::clog << "pkgcache.bin is NOT valid" << std::endl;
  1277. /* At this point we know we need to reconstruct the package cache,
  1278. begin. */
  1279. SPtr<FileFd> CacheF;
  1280. SPtr<DynamicMMap> Map;
  1281. if (Writeable == true && CacheFile.empty() == false)
  1282. {
  1283. _error->PushToStack();
  1284. unlink(CacheFile.c_str());
  1285. CacheF = new FileFd(CacheFile,FileFd::WriteAtomic);
  1286. fchmod(CacheF->Fd(),0644);
  1287. Map = CreateDynamicMMap(CacheF, MMap::Public);
  1288. if (_error->PendingError() == true)
  1289. {
  1290. delete CacheF.UnGuard();
  1291. delete Map.UnGuard();
  1292. if (Debug == true)
  1293. std::clog << "Open filebased MMap FAILED" << std::endl;
  1294. Writeable = false;
  1295. if (AllowMem == false)
  1296. {
  1297. _error->MergeWithStack();
  1298. return false;
  1299. }
  1300. _error->RevertToStack();
  1301. }
  1302. else
  1303. {
  1304. _error->MergeWithStack();
  1305. if (Debug == true)
  1306. std::clog << "Open filebased MMap" << std::endl;
  1307. }
  1308. }
  1309. if (Writeable == false || CacheFile.empty() == true)
  1310. {
  1311. // Just build it in memory..
  1312. Map = CreateDynamicMMap(NULL);
  1313. if (Debug == true)
  1314. std::clog << "Open memory Map (not filebased)" << std::endl;
  1315. }
  1316. // Lets try the source cache.
  1317. unsigned long CurrentSize = 0;
  1318. unsigned long TotalSize = 0;
  1319. if (CheckValidity(SrcCacheFile, List, Files.begin(),
  1320. Files.begin()+EndOfSource) == true)
  1321. {
  1322. if (Debug == true)
  1323. std::clog << "srcpkgcache.bin is valid - populate MMap with it." << std::endl;
  1324. // Preload the map with the source cache
  1325. FileFd SCacheF(SrcCacheFile,FileFd::ReadOnly);
  1326. unsigned long const alloc = Map->RawAllocate(SCacheF.Size());
  1327. if ((alloc == 0 && _error->PendingError())
  1328. || SCacheF.Read((unsigned char *)Map->Data() + alloc,
  1329. SCacheF.Size()) == false)
  1330. return false;
  1331. TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end());
  1332. // Build the status cache
  1333. pkgCacheGenerator Gen(Map.Get(),Progress);
  1334. if (_error->PendingError() == true)
  1335. return false;
  1336. if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
  1337. Files.begin()+EndOfSource,Files.end()) == false)
  1338. return false;
  1339. }
  1340. else
  1341. {
  1342. if (Debug == true)
  1343. std::clog << "srcpkgcache.bin is NOT valid - rebuild" << std::endl;
  1344. TotalSize = ComputeSize(Files.begin(),Files.end());
  1345. // Build the source cache
  1346. pkgCacheGenerator Gen(Map.Get(),Progress);
  1347. if (_error->PendingError() == true)
  1348. return false;
  1349. if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
  1350. Files.begin(),Files.begin()+EndOfSource) == false)
  1351. return false;
  1352. // Write it back
  1353. if (Writeable == true && SrcCacheFile.empty() == false)
  1354. {
  1355. FileFd SCacheF(SrcCacheFile,FileFd::WriteAtomic);
  1356. if (_error->PendingError() == true)
  1357. return false;
  1358. fchmod(SCacheF.Fd(),0644);
  1359. // Write out the main data
  1360. if (SCacheF.Write(Map->Data(),Map->Size()) == false)
  1361. return _error->Error(_("IO Error saving source cache"));
  1362. SCacheF.Sync();
  1363. // Write out the proper header
  1364. Gen.GetCache().HeaderP->Dirty = false;
  1365. if (SCacheF.Seek(0) == false ||
  1366. SCacheF.Write(Map->Data(),sizeof(*Gen.GetCache().HeaderP)) == false)
  1367. return _error->Error(_("IO Error saving source cache"));
  1368. Gen.GetCache().HeaderP->Dirty = true;
  1369. SCacheF.Sync();
  1370. }
  1371. // Build the status cache
  1372. if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
  1373. Files.begin()+EndOfSource,Files.end()) == false)
  1374. return false;
  1375. }
  1376. if (Debug == true)
  1377. std::clog << "Caches are ready for shipping" << std::endl;
  1378. if (_error->PendingError() == true)
  1379. return false;
  1380. if (OutMap != 0)
  1381. {
  1382. if (CacheF != 0)
  1383. {
  1384. delete Map.UnGuard();
  1385. *OutMap = new MMap(*CacheF,0);
  1386. }
  1387. else
  1388. {
  1389. *OutMap = Map.UnGuard();
  1390. }
  1391. }
  1392. return true;
  1393. }
  1394. /*}}}*/
  1395. // CacheGenerator::MakeOnlyStatusCache - Build only a status files cache/*{{{*/
  1396. // ---------------------------------------------------------------------
  1397. /* */
  1398. APT_DEPRECATED bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
  1399. { return pkgCacheGenerator::MakeOnlyStatusCache(&Progress, OutMap); }
  1400. bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap)
  1401. {
  1402. std::vector<pkgIndexFile *> Files;
  1403. unsigned long EndOfSource = Files.size();
  1404. if (_system->AddStatusFiles(Files) == false)
  1405. return false;
  1406. SPtr<DynamicMMap> Map = CreateDynamicMMap(NULL);
  1407. unsigned long CurrentSize = 0;
  1408. unsigned long TotalSize = 0;
  1409. TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end());
  1410. // Build the status cache
  1411. if (Progress != NULL)
  1412. Progress->OverallProgress(0,1,1,_("Reading package lists"));
  1413. pkgCacheGenerator Gen(Map.Get(),Progress);
  1414. if (_error->PendingError() == true)
  1415. return false;
  1416. if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
  1417. Files.begin()+EndOfSource,Files.end()) == false)
  1418. return false;
  1419. if (_error->PendingError() == true)
  1420. return false;
  1421. *OutMap = Map.UnGuard();
  1422. return true;
  1423. }
  1424. /*}}}*/
  1425. // IsDuplicateDescription /*{{{*/
  1426. static bool IsDuplicateDescription(pkgCache::DescIterator Desc,
  1427. MD5SumValue const &CurMd5, std::string const &CurLang)
  1428. {
  1429. // Descriptions in the same link-list have all the same md5
  1430. if (Desc.end() == true || MD5SumValue(Desc.md5()) != CurMd5)
  1431. return false;
  1432. for (; Desc.end() == false; ++Desc)
  1433. if (Desc.LanguageCode() == CurLang)
  1434. return true;
  1435. return false;
  1436. }
  1437. /*}}}*/
  1438. // CacheGenerator::FinishCache /*{{{*/
  1439. bool pkgCacheGenerator::FinishCache(OpProgress * /*Progress*/)
  1440. {
  1441. return true;
  1442. }
  1443. /*}}}*/