pkgcachegen.cc 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  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. #define APT_COMPATIBILITY 986
  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/aptconfiguration.h>
  18. #include <apt-pkg/strutl.h>
  19. #include <apt-pkg/sptr.h>
  20. #include <apt-pkg/pkgsystem.h>
  21. #include <apt-pkg/macros.h>
  22. #include <apt-pkg/tagfile.h>
  23. #include <apti18n.h>
  24. #include <vector>
  25. #include <sys/stat.h>
  26. #include <unistd.h>
  27. #include <errno.h>
  28. #include <stdio.h>
  29. /*}}}*/
  30. typedef vector<pkgIndexFile *>::iterator FileIterator;
  31. // CacheGenerator::pkgCacheGenerator - Constructor /*{{{*/
  32. // ---------------------------------------------------------------------
  33. /* We set the dirty flag and make sure that is written to the disk */
  34. pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) :
  35. Map(*pMap), Cache(pMap,false), Progress(Prog),
  36. FoundFileDeps(0)
  37. {
  38. CurrentFile = 0;
  39. memset(UniqHash,0,sizeof(UniqHash));
  40. if (_error->PendingError() == true)
  41. return;
  42. if (Map.Size() == 0)
  43. {
  44. // Setup the map interface..
  45. Cache.HeaderP = (pkgCache::Header *)Map.Data();
  46. if (Map.RawAllocate(sizeof(pkgCache::Header)) == 0 && _error->PendingError() == true)
  47. return;
  48. Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
  49. // Starting header
  50. *Cache.HeaderP = pkgCache::Header();
  51. Cache.HeaderP->VerSysName = Map.WriteString(_system->VS->Label);
  52. Cache.HeaderP->Architecture = Map.WriteString(_config->Find("APT::Architecture"));
  53. Cache.ReMap();
  54. }
  55. else
  56. {
  57. // Map directly from the existing file
  58. Cache.ReMap();
  59. Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
  60. if (Cache.VS != _system->VS)
  61. {
  62. _error->Error(_("Cache has an incompatible versioning system"));
  63. return;
  64. }
  65. }
  66. Cache.HeaderP->Dirty = true;
  67. Map.Sync(0,sizeof(pkgCache::Header));
  68. }
  69. /*}}}*/
  70. // CacheGenerator::~pkgCacheGenerator - Destructor /*{{{*/
  71. // ---------------------------------------------------------------------
  72. /* We sync the data then unset the dirty flag in two steps so as to
  73. advoid a problem during a crash */
  74. pkgCacheGenerator::~pkgCacheGenerator()
  75. {
  76. if (_error->PendingError() == true)
  77. return;
  78. if (Map.Sync() == false)
  79. return;
  80. Cache.HeaderP->Dirty = false;
  81. Map.Sync(0,sizeof(pkgCache::Header));
  82. }
  83. /*}}}*/
  84. // CacheGenerator::MergeList - Merge the package list /*{{{*/
  85. // ---------------------------------------------------------------------
  86. /* This provides the generation of the entries in the cache. Each loop
  87. goes through a single package record from the underlying parse engine. */
  88. bool pkgCacheGenerator::MergeList(ListParser &List,
  89. pkgCache::VerIterator *OutVer)
  90. {
  91. List.Owner = this;
  92. unsigned int Counter = 0;
  93. while (List.Step() == true)
  94. {
  95. string const PackageName = List.Package();
  96. if (PackageName.empty() == true)
  97. return false;
  98. /* As we handle Arch all packages as architecture bounded
  99. we add all information to every (simulated) arch package */
  100. std::vector<string> genArch;
  101. if (List.ArchitectureAll() == true) {
  102. genArch = APT::Configuration::getArchitectures();
  103. if (genArch.size() != 1)
  104. genArch.push_back("all");
  105. } else
  106. genArch.push_back(List.Architecture());
  107. for (std::vector<string>::const_iterator arch = genArch.begin();
  108. arch != genArch.end(); ++arch)
  109. {
  110. // Get a pointer to the package structure
  111. pkgCache::PkgIterator Pkg;
  112. if (NewPackage(Pkg, PackageName, *arch) == false)
  113. return _error->Error(_("Error occurred while processing %s (NewPackage)"),PackageName.c_str());
  114. Counter++;
  115. if (Counter % 100 == 0 && Progress != 0)
  116. Progress->Progress(List.Offset());
  117. /* Get a pointer to the version structure. We know the list is sorted
  118. so we use that fact in the search. Insertion of new versions is
  119. done with correct sorting */
  120. string Version = List.Version();
  121. if (Version.empty() == true)
  122. {
  123. // we first process the package, then the descriptions
  124. // (this has the bonus that we get MMap error when we run out
  125. // of MMap space)
  126. if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
  127. return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
  128. PackageName.c_str());
  129. // Find the right version to write the description
  130. MD5SumValue CurMd5 = List.Description_md5();
  131. pkgCache::VerIterator Ver = Pkg.VersionList();
  132. map_ptrloc *LastVer = &Pkg->VersionList;
  133. for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
  134. {
  135. pkgCache::DescIterator Desc = Ver.DescriptionList();
  136. map_ptrloc *LastDesc = &Ver->DescriptionList;
  137. bool duplicate=false;
  138. // don't add a new description if we have one for the given
  139. // md5 && language
  140. for ( ; Desc.end() == false; Desc++)
  141. if (MD5SumValue(Desc.md5()) == CurMd5 &&
  142. Desc.LanguageCode() == List.DescriptionLanguage())
  143. duplicate=true;
  144. if(duplicate)
  145. continue;
  146. for (Desc = Ver.DescriptionList();
  147. Desc.end() == false;
  148. LastDesc = &Desc->NextDesc, Desc++)
  149. {
  150. if (MD5SumValue(Desc.md5()) == CurMd5)
  151. {
  152. // Add new description
  153. *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
  154. Desc->ParentPkg = Pkg.Index();
  155. if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
  156. return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),PackageName.c_str());
  157. break;
  158. }
  159. }
  160. }
  161. continue;
  162. }
  163. pkgCache::VerIterator Ver = Pkg.VersionList();
  164. map_ptrloc *LastVer = &Pkg->VersionList;
  165. int Res = 1;
  166. for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
  167. {
  168. Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
  169. if (Res >= 0)
  170. break;
  171. }
  172. /* We already have a version for this item, record that we
  173. saw it */
  174. unsigned long Hash = List.VersionHash();
  175. if (Res == 0 && Ver->Hash == Hash)
  176. {
  177. if (List.UsePackage(Pkg,Ver) == false)
  178. return _error->Error(_("Error occurred while processing %s (UsePackage2)"),
  179. PackageName.c_str());
  180. if (NewFileVer(Ver,List) == false)
  181. return _error->Error(_("Error occurred while processing %s (NewFileVer1)"),
  182. PackageName.c_str());
  183. // Read only a single record and return
  184. if (OutVer != 0)
  185. {
  186. *OutVer = Ver;
  187. FoundFileDeps |= List.HasFileDeps();
  188. return true;
  189. }
  190. continue;
  191. }
  192. // Skip to the end of the same version set.
  193. if (Res == 0)
  194. {
  195. for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
  196. {
  197. Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
  198. if (Res != 0)
  199. break;
  200. }
  201. }
  202. // Add a new version
  203. *LastVer = NewVersion(Ver,Version,*LastVer);
  204. Ver->ParentPkg = Pkg.Index();
  205. Ver->Hash = Hash;
  206. if ((*LastVer == 0 && _error->PendingError()) || List.NewVersion(Ver) == false)
  207. return _error->Error(_("Error occurred while processing %s (NewVersion1)"),
  208. PackageName.c_str());
  209. if (List.UsePackage(Pkg,Ver) == false)
  210. return _error->Error(_("Error occurred while processing %s (UsePackage3)"),
  211. PackageName.c_str());
  212. if (NewFileVer(Ver,List) == false)
  213. return _error->Error(_("Error occurred while processing %s (NewVersion2)"),
  214. PackageName.c_str());
  215. // Read only a single record and return
  216. if (OutVer != 0)
  217. {
  218. *OutVer = Ver;
  219. FoundFileDeps |= List.HasFileDeps();
  220. return true;
  221. }
  222. /* Record the Description data. Description data always exist in
  223. Packages and Translation-* files. */
  224. pkgCache::DescIterator Desc = Ver.DescriptionList();
  225. map_ptrloc *LastDesc = &Ver->DescriptionList;
  226. // Skip to the end of description set
  227. for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++);
  228. // Add new description
  229. *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc);
  230. Desc->ParentPkg = Pkg.Index();
  231. if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
  232. return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),PackageName.c_str());
  233. }
  234. }
  235. FoundFileDeps |= List.HasFileDeps();
  236. if (Cache.HeaderP->PackageCount >= (1ULL<<sizeof(Cache.PkgP->ID)*8)-1)
  237. return _error->Error(_("Wow, you exceeded the number of package "
  238. "names this APT is capable of."));
  239. if (Cache.HeaderP->VersionCount >= (1ULL<<(sizeof(Cache.VerP->ID)*8))-1)
  240. return _error->Error(_("Wow, you exceeded the number of versions "
  241. "this APT is capable of."));
  242. if (Cache.HeaderP->DescriptionCount >= (1ULL<<(sizeof(Cache.DescP->ID)*8))-1)
  243. return _error->Error(_("Wow, you exceeded the number of descriptions "
  244. "this APT is capable of."));
  245. if (Cache.HeaderP->DependsCount >= (1ULL<<(sizeof(Cache.DepP->ID)*8))-1ULL)
  246. return _error->Error(_("Wow, you exceeded the number of dependencies "
  247. "this APT is capable of."));
  248. return true;
  249. }
  250. /*}}}*/
  251. // CacheGenerator::MergeFileProvides - Merge file provides /*{{{*/
  252. // ---------------------------------------------------------------------
  253. /* If we found any file depends while parsing the main list we need to
  254. resolve them. Since it is undesired to load the entire list of files
  255. into the cache as virtual packages we do a two stage effort. MergeList
  256. identifies the file depends and this creates Provdies for them by
  257. re-parsing all the indexs. */
  258. bool pkgCacheGenerator::MergeFileProvides(ListParser &List)
  259. {
  260. List.Owner = this;
  261. unsigned int Counter = 0;
  262. while (List.Step() == true)
  263. {
  264. string PackageName = List.Package();
  265. if (PackageName.empty() == true)
  266. return false;
  267. string Version = List.Version();
  268. if (Version.empty() == true)
  269. continue;
  270. pkgCache::PkgIterator Pkg = Cache.FindPkg(PackageName);
  271. if (Pkg.end() == true)
  272. return _error->Error(_("Error occurred while processing %s (FindPkg)"),
  273. PackageName.c_str());
  274. Counter++;
  275. if (Counter % 100 == 0 && Progress != 0)
  276. Progress->Progress(List.Offset());
  277. unsigned long Hash = List.VersionHash();
  278. pkgCache::VerIterator Ver = Pkg.VersionList();
  279. for (; Ver.end() == false; Ver++)
  280. {
  281. if (Ver->Hash == Hash && Version.c_str() == Ver.VerStr())
  282. {
  283. if (List.CollectFileProvides(Cache,Ver) == false)
  284. return _error->Error(_("Error occurred while processing %s (CollectFileProvides)"),PackageName.c_str());
  285. break;
  286. }
  287. }
  288. if (Ver.end() == true)
  289. _error->Warning(_("Package %s %s was not found while processing file dependencies"),PackageName.c_str(),Version.c_str());
  290. }
  291. return true;
  292. }
  293. /*}}}*/
  294. // CacheGenerator::NewGroup - Add a new group /*{{{*/
  295. // ---------------------------------------------------------------------
  296. /* This creates a new group structure and adds it to the hash table */
  297. bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, const string &Name) {
  298. Grp = Cache.FindGrp(Name);
  299. if (Grp.end() == false)
  300. return true;
  301. // Get a structure
  302. unsigned long const Group = Map.Allocate(sizeof(pkgCache::Group));
  303. if (unlikely(Group == 0))
  304. return false;
  305. Grp = pkgCache::GrpIterator(Cache, Cache.GrpP + Group);
  306. Grp->Name = Map.WriteString(Name);
  307. if (unlikely(Grp->Name == 0))
  308. return false;
  309. // Insert it into the hash table
  310. unsigned long const Hash = Cache.Hash(Name);
  311. Grp->Next = Cache.HeaderP->GrpHashTable[Hash];
  312. Cache.HeaderP->GrpHashTable[Hash] = Group;
  313. Cache.HeaderP->GroupCount++;
  314. return true;
  315. }
  316. /*}}}*/
  317. // CacheGenerator::NewPackage - Add a new package /*{{{*/
  318. // ---------------------------------------------------------------------
  319. /* This creates a new package structure and adds it to the hash table */
  320. bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name,
  321. const string &Arch) {
  322. pkgCache::GrpIterator Grp;
  323. if (unlikely(NewGroup(Grp, Name) == false))
  324. return false;
  325. Pkg = Grp.FindPkg(Arch);
  326. if (Pkg.end() == false)
  327. return true;
  328. // Get a structure
  329. unsigned long const Package = Map.Allocate(sizeof(pkgCache::Package));
  330. if (unlikely(Package == 0))
  331. return false;
  332. Pkg = pkgCache::PkgIterator(Cache,Cache.PkgP + Package);
  333. // Insert it into the hash table
  334. unsigned long const Hash = Cache.Hash(Name);
  335. Pkg->NextPackage = Cache.HeaderP->PkgHashTable[Hash];
  336. Cache.HeaderP->PkgHashTable[Hash] = Package;
  337. // remember the packages in the group
  338. Grp->FirstPackage = Package;
  339. if (Grp->LastPackage == 0)
  340. Grp->LastPackage = Package;
  341. // Set the name, arch and the ID
  342. Pkg->Name = Grp->Name;
  343. Pkg->Group = Grp.Index();
  344. Pkg->Arch = WriteUniqString(Arch.c_str());
  345. if (unlikely(Pkg->Arch == 0))
  346. return false;
  347. Pkg->ID = Cache.HeaderP->PackageCount++;
  348. return true;
  349. }
  350. /*}}}*/
  351. // CacheGenerator::NewFileVer - Create a new File<->Version association /*{{{*/
  352. // ---------------------------------------------------------------------
  353. /* */
  354. bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
  355. ListParser &List)
  356. {
  357. if (CurrentFile == 0)
  358. return true;
  359. // Get a structure
  360. unsigned long VerFile = Map.Allocate(sizeof(pkgCache::VerFile));
  361. if (VerFile == 0)
  362. return 0;
  363. pkgCache::VerFileIterator VF(Cache,Cache.VerFileP + VerFile);
  364. VF->File = CurrentFile - Cache.PkgFileP;
  365. // Link it to the end of the list
  366. map_ptrloc *Last = &Ver->FileList;
  367. for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++)
  368. Last = &V->NextFile;
  369. VF->NextFile = *Last;
  370. *Last = VF.Index();
  371. VF->Offset = List.Offset();
  372. VF->Size = List.Size();
  373. if (Cache.HeaderP->MaxVerFileSize < VF->Size)
  374. Cache.HeaderP->MaxVerFileSize = VF->Size;
  375. Cache.HeaderP->VerFileCount++;
  376. return true;
  377. }
  378. /*}}}*/
  379. // CacheGenerator::NewVersion - Create a new Version /*{{{*/
  380. // ---------------------------------------------------------------------
  381. /* This puts a version structure in the linked list */
  382. unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
  383. const string &VerStr,
  384. unsigned long Next)
  385. {
  386. // Get a structure
  387. unsigned long Version = Map.Allocate(sizeof(pkgCache::Version));
  388. if (Version == 0)
  389. return 0;
  390. // Fill it in
  391. Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
  392. Ver->NextVer = Next;
  393. Ver->ID = Cache.HeaderP->VersionCount++;
  394. Ver->VerStr = Map.WriteString(VerStr);
  395. if (Ver->VerStr == 0)
  396. return 0;
  397. return Version;
  398. }
  399. /*}}}*/
  400. // CacheGenerator::NewFileDesc - Create a new File<->Desc association /*{{{*/
  401. // ---------------------------------------------------------------------
  402. /* */
  403. bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
  404. ListParser &List)
  405. {
  406. if (CurrentFile == 0)
  407. return true;
  408. // Get a structure
  409. unsigned long DescFile = Map.Allocate(sizeof(pkgCache::DescFile));
  410. if (DescFile == 0)
  411. return false;
  412. pkgCache::DescFileIterator DF(Cache,Cache.DescFileP + DescFile);
  413. DF->File = CurrentFile - Cache.PkgFileP;
  414. // Link it to the end of the list
  415. map_ptrloc *Last = &Desc->FileList;
  416. for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++)
  417. Last = &D->NextFile;
  418. DF->NextFile = *Last;
  419. *Last = DF.Index();
  420. DF->Offset = List.Offset();
  421. DF->Size = List.Size();
  422. if (Cache.HeaderP->MaxDescFileSize < DF->Size)
  423. Cache.HeaderP->MaxDescFileSize = DF->Size;
  424. Cache.HeaderP->DescFileCount++;
  425. return true;
  426. }
  427. /*}}}*/
  428. // CacheGenerator::NewDescription - Create a new Description /*{{{*/
  429. // ---------------------------------------------------------------------
  430. /* This puts a description structure in the linked list */
  431. map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
  432. const string &Lang,
  433. const MD5SumValue &md5sum,
  434. map_ptrloc Next)
  435. {
  436. // Get a structure
  437. map_ptrloc Description = Map.Allocate(sizeof(pkgCache::Description));
  438. if (Description == 0)
  439. return 0;
  440. // Fill it in
  441. Desc = pkgCache::DescIterator(Cache,Cache.DescP + Description);
  442. Desc->NextDesc = Next;
  443. Desc->ID = Cache.HeaderP->DescriptionCount++;
  444. Desc->language_code = Map.WriteString(Lang);
  445. Desc->md5sum = Map.WriteString(md5sum.Value());
  446. if (Desc->language_code == 0 || Desc->md5sum == 0)
  447. return 0;
  448. return Description;
  449. }
  450. /*}}}*/
  451. // CacheGenerator::FinishCache - do various finish operations /*{{{*/
  452. // ---------------------------------------------------------------------
  453. /* This prepares the Cache for delivery */
  454. bool pkgCacheGenerator::FinishCache(OpProgress &Progress) {
  455. // FIXME: add progress reporting for this operation
  456. // Do we have different architectures in your groups ?
  457. vector<string> archs = APT::Configuration::getArchitectures();
  458. if (archs.size() > 1) {
  459. // Create Conflicts in between the group
  460. for (pkgCache::GrpIterator G = GetCache().GrpBegin(); G.end() != true; G++) {
  461. string const PkgName = G.Name();
  462. for (pkgCache::PkgIterator P = G.PackageList(); P.end() != true; P = G.NextPkg(P)) {
  463. if (strcmp(P.Arch(),"all") == 0)
  464. continue;
  465. pkgCache::PkgIterator allPkg;
  466. for (pkgCache::VerIterator V = P.VersionList(); V.end() != true; V++) {
  467. string const Arch = V.Arch(true);
  468. map_ptrloc *OldDepLast = NULL;
  469. /* MultiArch handling introduces a lot of implicit Dependencies:
  470. - MultiArch: same → Co-Installable if they have the same version
  471. - Architecture: all → Need to be Co-Installable for internal reasons
  472. - All others conflict with all other group members */
  473. bool const coInstall = (V->MultiArch == pkgCache::Version::All ||
  474. V->MultiArch == pkgCache::Version::Same);
  475. if (V->MultiArch == pkgCache::Version::All && allPkg.end() == true)
  476. allPkg = G.FindPkg("all");
  477. for (vector<string>::const_iterator A = archs.begin(); A != archs.end(); ++A) {
  478. if (*A == Arch)
  479. continue;
  480. /* We allow only one installed arch at the time
  481. per group, therefore each group member conflicts
  482. with all other group members */
  483. pkgCache::PkgIterator D = G.FindPkg(*A);
  484. if (D.end() == true)
  485. continue;
  486. if (coInstall == true) {
  487. // Replaces: ${self}:other ( << ${binary:Version})
  488. NewDepends(D, V, V.VerStr(),
  489. pkgCache::Dep::Less, pkgCache::Dep::Replaces,
  490. OldDepLast);
  491. // Breaks: ${self}:other (!= ${binary:Version})
  492. NewDepends(D, V, V.VerStr(),
  493. pkgCache::Dep::Less, pkgCache::Dep::DpkgBreaks,
  494. OldDepLast);
  495. NewDepends(D, V, V.VerStr(),
  496. pkgCache::Dep::Greater, pkgCache::Dep::DpkgBreaks,
  497. OldDepLast);
  498. if (V->MultiArch == pkgCache::Version::All) {
  499. // Depend on ${self}:all which does depend on nothing
  500. NewDepends(allPkg, V, V.VerStr(),
  501. pkgCache::Dep::Equals, pkgCache::Dep::Depends,
  502. OldDepLast);
  503. }
  504. } else {
  505. // Conflicts: ${self}:other
  506. NewDepends(D, V, "",
  507. pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
  508. OldDepLast);
  509. }
  510. }
  511. }
  512. }
  513. }
  514. }
  515. return true;
  516. }
  517. /*}}}*/
  518. // CacheGenerator::NewDepends - Create a dependency element /*{{{*/
  519. // ---------------------------------------------------------------------
  520. /* This creates a dependency element in the tree. It is linked to the
  521. version and to the package that it is pointing to. */
  522. bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
  523. pkgCache::VerIterator &Ver,
  524. string const &Version,
  525. unsigned int const &Op,
  526. unsigned int const &Type,
  527. map_ptrloc *OldDepLast)
  528. {
  529. // Get a structure
  530. unsigned long const Dependency = Map.Allocate(sizeof(pkgCache::Dependency));
  531. if (unlikely(Dependency == 0))
  532. return false;
  533. // Fill it in
  534. pkgCache::DepIterator Dep(Cache,Cache.DepP + Dependency);
  535. Dep->ParentVer = Ver.Index();
  536. Dep->Type = Type;
  537. Dep->CompareOp = Op;
  538. Dep->ID = Cache.HeaderP->DependsCount++;
  539. // Probe the reverse dependency list for a version string that matches
  540. if (Version.empty() == false)
  541. {
  542. /* for (pkgCache::DepIterator I = Pkg.RevDependsList(); I.end() == false; I++)
  543. if (I->Version != 0 && I.TargetVer() == Version)
  544. Dep->Version = I->Version;*/
  545. if (Dep->Version == 0)
  546. if (unlikely((Dep->Version = Map.WriteString(Version)) == 0))
  547. return false;
  548. }
  549. // Link it to the package
  550. Dep->Package = Pkg.Index();
  551. Dep->NextRevDepends = Pkg->RevDepends;
  552. Pkg->RevDepends = Dep.Index();
  553. // Do we know where to link the Dependency to?
  554. if (OldDepLast == NULL)
  555. {
  556. OldDepLast = &Ver->DependsList;
  557. for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++)
  558. OldDepLast = &D->NextDepends;
  559. }
  560. Dep->NextDepends = *OldDepLast;
  561. *OldDepLast = Dep.Index();
  562. OldDepLast = &Dep->NextDepends;
  563. return true;
  564. }
  565. /*}}}*/
  566. // ListParser::NewDepends - Create the environment for a new dependency /*{{{*/
  567. // ---------------------------------------------------------------------
  568. /* This creates a Group and the Package to link this dependency to if
  569. needed and handles also the caching of the old endpoint */
  570. bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
  571. const string &PackageName,
  572. const string &Arch,
  573. const string &Version,
  574. unsigned int Op,
  575. unsigned int Type)
  576. {
  577. pkgCache::GrpIterator Grp;
  578. if (unlikely(Owner->NewGroup(Grp, PackageName) == false))
  579. return false;
  580. // Locate the target package
  581. pkgCache::PkgIterator Pkg = Grp.FindPkg(Arch);
  582. if (Pkg.end() == true) {
  583. if (unlikely(Owner->NewPackage(Pkg, PackageName, Arch) == false))
  584. return false;
  585. }
  586. // Is it a file dependency?
  587. if (unlikely(PackageName[0] == '/'))
  588. FoundFileDeps = true;
  589. /* Caching the old end point speeds up generation substantially */
  590. if (OldDepVer != Ver) {
  591. OldDepLast = NULL;
  592. OldDepVer = Ver;
  593. }
  594. return Owner->NewDepends(Pkg, Ver, Version, Op, Type, OldDepLast);
  595. }
  596. /*}}}*/
  597. // ListParser::NewProvides - Create a Provides element /*{{{*/
  598. // ---------------------------------------------------------------------
  599. /* */
  600. bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
  601. const string &PkgName,
  602. const string &PkgArch,
  603. const string &Version)
  604. {
  605. pkgCache &Cache = Owner->Cache;
  606. // We do not add self referencing provides
  607. if (Ver.ParentPkg().Name() == PkgName && PkgArch == Ver.Arch(true))
  608. return true;
  609. // Get a structure
  610. unsigned long const Provides = Owner->Map.Allocate(sizeof(pkgCache::Provides));
  611. if (unlikely(Provides == 0))
  612. return false;
  613. Cache.HeaderP->ProvidesCount++;
  614. // Fill it in
  615. pkgCache::PrvIterator Prv(Cache,Cache.ProvideP + Provides,Cache.PkgP);
  616. Prv->Version = Ver.Index();
  617. Prv->NextPkgProv = Ver->ProvidesList;
  618. Ver->ProvidesList = Prv.Index();
  619. if (Version.empty() == false && unlikely((Prv->ProvideVersion = WriteString(Version)) == 0))
  620. return false;
  621. // Locate the target package
  622. pkgCache::PkgIterator Pkg;
  623. if (unlikely(Owner->NewPackage(Pkg,PkgName, PkgArch) == false))
  624. return false;
  625. // Link it to the package
  626. Prv->ParentPkg = Pkg.Index();
  627. Prv->NextProvides = Pkg->ProvidesList;
  628. Pkg->ProvidesList = Prv.Index();
  629. return true;
  630. }
  631. /*}}}*/
  632. // CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/
  633. // ---------------------------------------------------------------------
  634. /* This is used to select which file is to be associated with all newly
  635. added versions. The caller is responsible for setting the IMS fields. */
  636. bool pkgCacheGenerator::SelectFile(const string &File,const string &Site,
  637. const pkgIndexFile &Index,
  638. unsigned long Flags)
  639. {
  640. // Get some space for the structure
  641. CurrentFile = Cache.PkgFileP + Map.Allocate(sizeof(*CurrentFile));
  642. if (CurrentFile == Cache.PkgFileP)
  643. return false;
  644. // Fill it in
  645. CurrentFile->FileName = Map.WriteString(File);
  646. CurrentFile->Site = WriteUniqString(Site);
  647. CurrentFile->NextFile = Cache.HeaderP->FileList;
  648. CurrentFile->Flags = Flags;
  649. CurrentFile->ID = Cache.HeaderP->PackageFileCount;
  650. CurrentFile->IndexType = WriteUniqString(Index.GetType()->Label);
  651. PkgFileName = File;
  652. Cache.HeaderP->FileList = CurrentFile - Cache.PkgFileP;
  653. Cache.HeaderP->PackageFileCount++;
  654. if (CurrentFile->FileName == 0)
  655. return false;
  656. if (Progress != 0)
  657. Progress->SubProgress(Index.Size());
  658. return true;
  659. }
  660. /*}}}*/
  661. // CacheGenerator::WriteUniqueString - Insert a unique string /*{{{*/
  662. // ---------------------------------------------------------------------
  663. /* This is used to create handles to strings. Given the same text it
  664. always returns the same number */
  665. unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
  666. unsigned int Size)
  667. {
  668. /* We use a very small transient hash table here, this speeds up generation
  669. by a fair amount on slower machines */
  670. pkgCache::StringItem *&Bucket = UniqHash[(S[0]*5 + S[1]) % _count(UniqHash)];
  671. if (Bucket != 0 &&
  672. stringcmp(S,S+Size,Cache.StrP + Bucket->String) == 0)
  673. return Bucket->String;
  674. // Search for an insertion point
  675. pkgCache::StringItem *I = Cache.StringItemP + Cache.HeaderP->StringList;
  676. int Res = 1;
  677. map_ptrloc *Last = &Cache.HeaderP->StringList;
  678. for (; I != Cache.StringItemP; Last = &I->NextItem,
  679. I = Cache.StringItemP + I->NextItem)
  680. {
  681. Res = stringcmp(S,S+Size,Cache.StrP + I->String);
  682. if (Res >= 0)
  683. break;
  684. }
  685. // Match
  686. if (Res == 0)
  687. {
  688. Bucket = I;
  689. return I->String;
  690. }
  691. // Get a structure
  692. unsigned long Item = Map.Allocate(sizeof(pkgCache::StringItem));
  693. if (Item == 0)
  694. return 0;
  695. // Fill in the structure
  696. pkgCache::StringItem *ItemP = Cache.StringItemP + Item;
  697. ItemP->NextItem = I - Cache.StringItemP;
  698. *Last = Item;
  699. ItemP->String = Map.WriteString(S,Size);
  700. if (ItemP->String == 0)
  701. return 0;
  702. Bucket = ItemP;
  703. return ItemP->String;
  704. }
  705. /*}}}*/
  706. // CheckValidity - Check that a cache is up-to-date /*{{{*/
  707. // ---------------------------------------------------------------------
  708. /* This just verifies that each file in the list of index files exists,
  709. has matching attributes with the cache and the cache does not have
  710. any extra files. */
  711. static bool CheckValidity(const string &CacheFile, FileIterator Start,
  712. FileIterator End,MMap **OutMap = 0)
  713. {
  714. bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
  715. // No file, certainly invalid
  716. if (CacheFile.empty() == true || FileExists(CacheFile) == false)
  717. {
  718. if (Debug == true)
  719. std::clog << "CacheFile doesn't exist" << std::endl;
  720. return false;
  721. }
  722. // Map it
  723. FileFd CacheF(CacheFile,FileFd::ReadOnly);
  724. SPtr<MMap> Map = new MMap(CacheF,0);
  725. pkgCache Cache(Map);
  726. if (_error->PendingError() == true || Map->Size() == 0)
  727. {
  728. if (Debug == true)
  729. std::clog << "Errors are pending or Map is empty()" << std::endl;
  730. _error->Discard();
  731. return false;
  732. }
  733. /* Now we check every index file, see if it is in the cache,
  734. verify the IMS data and check that it is on the disk too.. */
  735. SPtrArray<bool> Visited = new bool[Cache.HeaderP->PackageFileCount];
  736. memset(Visited,0,sizeof(*Visited)*Cache.HeaderP->PackageFileCount);
  737. for (; Start != End; Start++)
  738. {
  739. if (Debug == true)
  740. std::clog << "Checking PkgFile " << (*Start)->Describe() << ": ";
  741. if ((*Start)->HasPackages() == false)
  742. {
  743. if (Debug == true)
  744. std::clog << "Has NO packages" << std::endl;
  745. continue;
  746. }
  747. if ((*Start)->Exists() == false)
  748. {
  749. #if 0 // mvo: we no longer give a message here (Default Sources spec)
  750. _error->WarningE("stat",_("Couldn't stat source package list %s"),
  751. (*Start)->Describe().c_str());
  752. #endif
  753. if (Debug == true)
  754. std::clog << "file doesn't exist" << std::endl;
  755. continue;
  756. }
  757. // FindInCache is also expected to do an IMS check.
  758. pkgCache::PkgFileIterator File = (*Start)->FindInCache(Cache);
  759. if (File.end() == true)
  760. {
  761. if (Debug == true)
  762. std::clog << "FindInCache returned end-Pointer" << std::endl;
  763. return false;
  764. }
  765. Visited[File->ID] = true;
  766. if (Debug == true)
  767. std::clog << "with ID " << File->ID << " is valid" << std::endl;
  768. }
  769. for (unsigned I = 0; I != Cache.HeaderP->PackageFileCount; I++)
  770. if (Visited[I] == false)
  771. {
  772. if (Debug == true)
  773. std::clog << "File with ID" << I << " wasn't visited" << std::endl;
  774. return false;
  775. }
  776. if (_error->PendingError() == true)
  777. {
  778. if (Debug == true)
  779. {
  780. std::clog << "Validity failed because of pending errors:" << std::endl;
  781. _error->DumpErrors();
  782. }
  783. _error->Discard();
  784. return false;
  785. }
  786. if (OutMap != 0)
  787. *OutMap = Map.UnGuard();
  788. return true;
  789. }
  790. /*}}}*/
  791. // ComputeSize - Compute the total size of a bunch of files /*{{{*/
  792. // ---------------------------------------------------------------------
  793. /* Size is kind of an abstract notion that is only used for the progress
  794. meter */
  795. static unsigned long ComputeSize(FileIterator Start,FileIterator End)
  796. {
  797. unsigned long TotalSize = 0;
  798. for (; Start != End; Start++)
  799. {
  800. if ((*Start)->HasPackages() == false)
  801. continue;
  802. TotalSize += (*Start)->Size();
  803. }
  804. return TotalSize;
  805. }
  806. /*}}}*/
  807. // BuildCache - Merge the list of index files into the cache /*{{{*/
  808. // ---------------------------------------------------------------------
  809. /* */
  810. static bool BuildCache(pkgCacheGenerator &Gen,
  811. OpProgress &Progress,
  812. unsigned long &CurrentSize,unsigned long TotalSize,
  813. FileIterator Start, FileIterator End)
  814. {
  815. FileIterator I;
  816. for (I = Start; I != End; I++)
  817. {
  818. if ((*I)->HasPackages() == false)
  819. continue;
  820. if ((*I)->Exists() == false)
  821. continue;
  822. if ((*I)->FindInCache(Gen.GetCache()).end() == false)
  823. {
  824. _error->Warning("Duplicate sources.list entry %s",
  825. (*I)->Describe().c_str());
  826. continue;
  827. }
  828. unsigned long Size = (*I)->Size();
  829. Progress.OverallProgress(CurrentSize,TotalSize,Size,_("Reading package lists"));
  830. CurrentSize += Size;
  831. if ((*I)->Merge(Gen,Progress) == false)
  832. return false;
  833. }
  834. if (Gen.HasFileDeps() == true)
  835. {
  836. Progress.Done();
  837. TotalSize = ComputeSize(Start, End);
  838. CurrentSize = 0;
  839. for (I = Start; I != End; I++)
  840. {
  841. unsigned long Size = (*I)->Size();
  842. Progress.OverallProgress(CurrentSize,TotalSize,Size,_("Collecting File Provides"));
  843. CurrentSize += Size;
  844. if ((*I)->MergeFileProvides(Gen,Progress) == false)
  845. return false;
  846. }
  847. }
  848. return true;
  849. }
  850. /*}}}*/
  851. // MakeStatusCache - Construct the status cache /*{{{*/
  852. // ---------------------------------------------------------------------
  853. /* This makes sure that the status cache (the cache that has all
  854. index files from the sources list and all local ones) is ready
  855. to be mmaped. If OutMap is not zero then a MMap object representing
  856. the cache will be stored there. This is pretty much mandetory if you
  857. are using AllowMem. AllowMem lets the function be run as non-root
  858. where it builds the cache 'fast' into a memory buffer. */
  859. bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
  860. MMap **OutMap,bool AllowMem)
  861. {
  862. bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
  863. unsigned long const MapSize = _config->FindI("APT::Cache-Limit",24*1024*1024);
  864. vector<pkgIndexFile *> Files;
  865. for (vector<metaIndex *>::const_iterator i = List.begin();
  866. i != List.end();
  867. i++)
  868. {
  869. vector <pkgIndexFile *> *Indexes = (*i)->GetIndexFiles();
  870. for (vector<pkgIndexFile *>::const_iterator j = Indexes->begin();
  871. j != Indexes->end();
  872. j++)
  873. Files.push_back (*j);
  874. }
  875. unsigned long const EndOfSource = Files.size();
  876. if (_system->AddStatusFiles(Files) == false)
  877. return false;
  878. // Decide if we can write to the files..
  879. string const CacheFile = _config->FindFile("Dir::Cache::pkgcache");
  880. string const SrcCacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
  881. // Decide if we can write to the cache
  882. bool Writeable = false;
  883. if (CacheFile.empty() == false)
  884. Writeable = access(flNotFile(CacheFile).c_str(),W_OK) == 0;
  885. else
  886. if (SrcCacheFile.empty() == false)
  887. Writeable = access(flNotFile(SrcCacheFile).c_str(),W_OK) == 0;
  888. if (Debug == true)
  889. std::clog << "Do we have write-access to the cache files? " << (Writeable ? "YES" : "NO") << std::endl;
  890. if (Writeable == false && AllowMem == false && CacheFile.empty() == false)
  891. return _error->Error(_("Unable to write to %s"),flNotFile(CacheFile).c_str());
  892. Progress.OverallProgress(0,1,1,_("Reading package lists"));
  893. // Cache is OK, Fin.
  894. if (CheckValidity(CacheFile,Files.begin(),Files.end(),OutMap) == true)
  895. {
  896. Progress.OverallProgress(1,1,1,_("Reading package lists"));
  897. if (Debug == true)
  898. std::clog << "pkgcache.bin is valid - no need to build anything" << std::endl;
  899. return true;
  900. }
  901. else if (Debug == true)
  902. std::clog << "pkgcache.bin is NOT valid" << std::endl;
  903. /* At this point we know we need to reconstruct the package cache,
  904. begin. */
  905. SPtr<FileFd> CacheF;
  906. SPtr<DynamicMMap> Map;
  907. if (Writeable == true && CacheFile.empty() == false)
  908. {
  909. unlink(CacheFile.c_str());
  910. CacheF = new FileFd(CacheFile,FileFd::WriteEmpty);
  911. fchmod(CacheF->Fd(),0644);
  912. Map = new DynamicMMap(*CacheF,MMap::Public,MapSize);
  913. if (_error->PendingError() == true)
  914. return false;
  915. if (Debug == true)
  916. std::clog << "Open filebased MMap" << std::endl;
  917. }
  918. else
  919. {
  920. // Just build it in memory..
  921. Map = new DynamicMMap(0,MapSize);
  922. if (Debug == true)
  923. std::clog << "Open memory Map (not filebased)" << std::endl;
  924. }
  925. // Lets try the source cache.
  926. unsigned long CurrentSize = 0;
  927. unsigned long TotalSize = 0;
  928. if (CheckValidity(SrcCacheFile,Files.begin(),
  929. Files.begin()+EndOfSource) == true)
  930. {
  931. if (Debug == true)
  932. std::clog << "srcpkgcache.bin is valid - populate MMap with it." << std::endl;
  933. // Preload the map with the source cache
  934. FileFd SCacheF(SrcCacheFile,FileFd::ReadOnly);
  935. unsigned long const alloc = Map->RawAllocate(SCacheF.Size());
  936. if ((alloc == 0 && _error->PendingError())
  937. || SCacheF.Read((unsigned char *)Map->Data() + alloc,
  938. SCacheF.Size()) == false)
  939. return false;
  940. TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end());
  941. // Build the status cache
  942. pkgCacheGenerator Gen(Map.Get(),&Progress);
  943. if (_error->PendingError() == true)
  944. return false;
  945. if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
  946. Files.begin()+EndOfSource,Files.end()) == false)
  947. return false;
  948. // FIXME: move me to a better place
  949. Gen.FinishCache(Progress);
  950. }
  951. else
  952. {
  953. if (Debug == true)
  954. std::clog << "srcpkgcache.bin is NOT valid - rebuild" << std::endl;
  955. TotalSize = ComputeSize(Files.begin(),Files.end());
  956. // Build the source cache
  957. pkgCacheGenerator Gen(Map.Get(),&Progress);
  958. if (_error->PendingError() == true)
  959. return false;
  960. if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
  961. Files.begin(),Files.begin()+EndOfSource) == false)
  962. return false;
  963. // Write it back
  964. if (Writeable == true && SrcCacheFile.empty() == false)
  965. {
  966. FileFd SCacheF(SrcCacheFile,FileFd::WriteEmpty);
  967. if (_error->PendingError() == true)
  968. return false;
  969. fchmod(SCacheF.Fd(),0644);
  970. // Write out the main data
  971. if (SCacheF.Write(Map->Data(),Map->Size()) == false)
  972. return _error->Error(_("IO Error saving source cache"));
  973. SCacheF.Sync();
  974. // Write out the proper header
  975. Gen.GetCache().HeaderP->Dirty = false;
  976. if (SCacheF.Seek(0) == false ||
  977. SCacheF.Write(Map->Data(),sizeof(*Gen.GetCache().HeaderP)) == false)
  978. return _error->Error(_("IO Error saving source cache"));
  979. Gen.GetCache().HeaderP->Dirty = true;
  980. SCacheF.Sync();
  981. }
  982. // Build the status cache
  983. if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
  984. Files.begin()+EndOfSource,Files.end()) == false)
  985. return false;
  986. // FIXME: move me to a better place
  987. Gen.FinishCache(Progress);
  988. }
  989. if (Debug == true)
  990. std::clog << "Caches are ready for shipping" << std::endl;
  991. if (_error->PendingError() == true)
  992. return false;
  993. if (OutMap != 0)
  994. {
  995. if (CacheF != 0)
  996. {
  997. delete Map.UnGuard();
  998. *OutMap = new MMap(*CacheF,0);
  999. }
  1000. else
  1001. {
  1002. *OutMap = Map.UnGuard();
  1003. }
  1004. }
  1005. return true;
  1006. }
  1007. /*}}}*/
  1008. // MakeOnlyStatusCache - Build a cache with just the status files /*{{{*/
  1009. // ---------------------------------------------------------------------
  1010. /* */
  1011. bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
  1012. {
  1013. unsigned long MapSize = _config->FindI("APT::Cache-Limit",20*1024*1024);
  1014. vector<pkgIndexFile *> Files;
  1015. unsigned long EndOfSource = Files.size();
  1016. if (_system->AddStatusFiles(Files) == false)
  1017. return false;
  1018. SPtr<DynamicMMap> Map = new DynamicMMap(0,MapSize);
  1019. unsigned long CurrentSize = 0;
  1020. unsigned long TotalSize = 0;
  1021. TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end());
  1022. // Build the status cache
  1023. Progress.OverallProgress(0,1,1,_("Reading package lists"));
  1024. pkgCacheGenerator Gen(Map.Get(),&Progress);
  1025. if (_error->PendingError() == true)
  1026. return false;
  1027. if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
  1028. Files.begin()+EndOfSource,Files.end()) == false)
  1029. return false;
  1030. // FIXME: move me to a better place
  1031. Gen.FinishCache(Progress);
  1032. if (_error->PendingError() == true)
  1033. return false;
  1034. *OutMap = Map.UnGuard();
  1035. return true;
  1036. }
  1037. /*}}}*/