]> git.saurik.com Git - apt.git/blob - apt-pkg/pkgcachegen.cc
CDROM support
[apt.git] / apt-pkg / pkgcachegen.cc
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: pkgcachegen.cc,v 1.23 1998/11/13 04:23:33 jgg Exp $
4 /* ######################################################################
5
6 Package Cache Generator - Generator for the cache structure.
7
8 This builds the cache structure from the abstract package list parser.
9
10 ##################################################################### */
11 /*}}}*/
12 // Include Files /*{{{*/
13 #ifdef __GNUG__
14 #pragma implementation "apt-pkg/pkgcachegen.h"
15 #endif
16
17 #include <apt-pkg/pkgcachegen.h>
18 #include <apt-pkg/error.h>
19 #include <apt-pkg/version.h>
20 #include <apt-pkg/progress.h>
21 #include <apt-pkg/sourcelist.h>
22 #include <apt-pkg/configuration.h>
23 #include <apt-pkg/deblistparser.h>
24
25 #include <strutl.h>
26
27 #include <sys/stat.h>
28 #include <unistd.h>
29 /*}}}*/
30
31 // CacheGenerator::pkgCacheGenerator - Constructor /*{{{*/
32 // ---------------------------------------------------------------------
33 /* We set the diry flag and make sure that is written to the disk */
34 pkgCacheGenerator::pkgCacheGenerator(DynamicMMap &Map,OpProgress &Prog) :
35 Map(Map), Cache(Map), Progress(Prog)
36 {
37 if (_error->PendingError() == true)
38 return;
39
40 if (Map.Size() == 0)
41 {
42 Map.RawAllocate(sizeof(pkgCache::Header));
43 *Cache.HeaderP = pkgCache::Header();
44 }
45 Cache.HeaderP->Dirty = true;
46 Map.Sync(0,sizeof(pkgCache::Header));
47 Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
48 }
49 /*}}}*/
50 // CacheGenerator::~pkgCacheGenerator - Destructor /*{{{*/
51 // ---------------------------------------------------------------------
52 /* We sync the data then unset the dirty flag in two steps so as to
53 advoid a problem during a crash */
54 pkgCacheGenerator::~pkgCacheGenerator()
55 {
56 if (_error->PendingError() == true)
57 return;
58 if (Map.Sync() == false)
59 return;
60
61 Cache.HeaderP->Dirty = false;
62 Map.Sync(0,sizeof(pkgCache::Header));
63 }
64 /*}}}*/
65 // CacheGenerator::MergeList - Merge the package list /*{{{*/
66 // ---------------------------------------------------------------------
67 /* This provides the generation of the entries in the cache. Each loop
68 goes through a single package record from the underlying parse engine. */
69 bool pkgCacheGenerator::MergeList(ListParser &List)
70 {
71 List.Owner = this;
72
73 int Counter = 0;
74 while (List.Step() == true)
75 {
76 // Get a pointer to the package structure
77 string PackageName = List.Package();
78 pkgCache::PkgIterator Pkg;
79 if (NewPackage(Pkg,PackageName) == false)
80 return _error->Error("Error occured while processing %s (NewPackage)",PackageName.c_str());
81 Counter++;
82 if (Counter % 100 == 0)
83 Progress.Progress(List.Offset());
84
85 /* Get a pointer to the version structure. We know the list is sorted
86 so we use that fact in the search. Insertion of new versions is
87 done with correct sorting */
88 string Version = List.Version();
89 if (Version.empty() == true)
90 {
91 if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
92 return _error->Error("Error occured while processing %s (UsePackage1)",PackageName.c_str());
93 continue;
94 }
95
96 pkgCache::VerIterator Ver = Pkg.VersionList();
97 __apt_ptrloc *Last = &Pkg->VersionList;
98 int Res = 1;
99 for (; Ver.end() == false; Last = &Ver->NextVer, Ver++)
100 {
101 Res = pkgVersionCompare(Version.begin(),Version.end(),Ver.VerStr(),
102 Ver.VerStr() + strlen(Ver.VerStr()));
103 if (Res >= 0)
104 break;
105 }
106
107 /* We already have a version for this item, record that we
108 saw it */
109 if (Res == 0)
110 {
111 if (List.UsePackage(Pkg,Ver) == false)
112 return _error->Error("Error occured while processing %s (UsePackage2)",PackageName.c_str());
113
114 if (NewFileVer(Ver,List) == false)
115 return _error->Error("Error occured while processing %s (NewFileVer1)",PackageName.c_str());
116
117 continue;
118 }
119
120 // Add a new version
121 *Last = NewVersion(Ver,Version,*Last);
122 Ver->ParentPkg = Pkg.Index();
123 if (List.NewVersion(Ver) == false)
124 return _error->Error("Error occured while processing %s (NewVersion1)",PackageName.c_str());
125
126 if (List.UsePackage(Pkg,Ver) == false)
127 return _error->Error("Error occured while processing %s (UsePackage3)",PackageName.c_str());
128
129 if (NewFileVer(Ver,List) == false)
130 return _error->Error("Error occured while processing %s (NewVersion2)",PackageName.c_str());
131 }
132
133 return true;
134 }
135 /*}}}*/
136 // CacheGenerator::NewPackage - Add a new package /*{{{*/
137 // ---------------------------------------------------------------------
138 /* This creates a new package structure and adds it to the hash table */
139 bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,string Name)
140 {
141 Pkg = Cache.FindPkg(Name);
142 if (Pkg.end() == false)
143 return true;
144
145 // Get a structure
146 unsigned long Package = Map.Allocate(sizeof(pkgCache::Package));
147 if (Package == 0)
148 return false;
149
150 Pkg = pkgCache::PkgIterator(Cache,Cache.PkgP + Package);
151
152 // Insert it into the hash table
153 unsigned long Hash = Cache.Hash(Name);
154 Pkg->NextPackage = Cache.HeaderP->HashTable[Hash];
155 Cache.HeaderP->HashTable[Hash] = Package;
156
157 // Set the name and the ID
158 Pkg->Name = Map.WriteString(Name);
159 if (Pkg->Name == 0)
160 return false;
161 Pkg->ID = Cache.HeaderP->PackageCount++;
162
163 return true;
164 }
165 /*}}}*/
166 // CacheGenerator::NewFileVer - Create a new File<->Version association /*{{{*/
167 // ---------------------------------------------------------------------
168 /* */
169 bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
170 ListParser &List)
171 {
172 // Get a structure
173 unsigned long VerFile = Map.Allocate(sizeof(pkgCache::VerFile));
174 if (VerFile == 0)
175 return 0;
176
177 pkgCache::VerFileIterator VF(Cache,Cache.VerFileP + VerFile);
178 VF->File = CurrentFile - Cache.PkgFileP;
179
180 // Link it to the end of the list
181 __apt_ptrloc *Last = &Ver->FileList;
182 for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++)
183 Last = &V->NextFile;
184 VF->NextFile = *Last;
185 *Last = VF.Index();
186
187 VF->Offset = List.Offset();
188 VF->Size = List.Size();
189 if (Cache.HeaderP->MaxVerFileSize < VF->Size)
190 Cache.HeaderP->MaxVerFileSize = VF->Size;
191 return true;
192 }
193 /*}}}*/
194 // CacheGenerator::NewVersion - Create a new Version /*{{{*/
195 // ---------------------------------------------------------------------
196 /* This puts a version structure in the linked list */
197 unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
198 string VerStr,
199 unsigned long Next)
200 {
201 // Get a structure
202 unsigned long Version = Map.Allocate(sizeof(pkgCache::Version));
203 if (Version == 0)
204 return 0;
205
206 // Fill it in
207 Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
208 Ver->NextVer = Next;
209 Ver->ID = Cache.HeaderP->VersionCount++;
210 Ver->VerStr = Map.WriteString(VerStr);
211 if (Ver->VerStr == 0)
212 return 0;
213
214 return Version;
215 }
216 /*}}}*/
217 // ListParser::NewDepends - Create a dependency element /*{{{*/
218 // ---------------------------------------------------------------------
219 /* This creates a dependency element in the tree. It is linked to the
220 version and to the package that it is pointing to. */
221 bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
222 string PackageName,
223 string Version,
224 unsigned int Op,
225 unsigned int Type)
226 {
227 pkgCache &Cache = Owner->Cache;
228
229 // Get a structure
230 unsigned long Dependency = Owner->Map.Allocate(sizeof(pkgCache::Dependency));
231 if (Dependency == 0)
232 return false;
233
234 // Fill it in
235 pkgCache::DepIterator Dep(Cache,Cache.DepP + Dependency);
236 Dep->ParentVer = Ver.Index();
237 Dep->Type = Type;
238 Dep->CompareOp = Op;
239 Dep->ID = Cache.HeaderP->DependsCount++;
240
241 // Locate the target package
242 pkgCache::PkgIterator Pkg;
243 if (Owner->NewPackage(Pkg,PackageName) == false)
244 return false;
245
246 // Probe the reverse dependency list for a version string that matches
247 if (Version.empty() == false)
248 {
249 for (pkgCache::DepIterator I = Pkg.RevDependsList(); I.end() == false; I++)
250 if (I->Version != 0 && I.TargetVer() == Version)
251 Dep->Version = I->Version;
252 if (Dep->Version == 0)
253 if ((Dep->Version = WriteString(Version)) == 0)
254 return false;
255 }
256
257 // Link it to the package
258 Dep->Package = Pkg.Index();
259 Dep->NextRevDepends = Pkg->RevDepends;
260 Pkg->RevDepends = Dep.Index();
261
262 // Link it to the version (at the end of the list)
263 __apt_ptrloc *Last = &Ver->DependsList;
264 for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++)
265 Last = &D->NextDepends;
266 Dep->NextDepends = *Last;
267 *Last = Dep.Index();
268
269 return true;
270 }
271 /*}}}*/
272 // ListParser::NewProvides - Create a Provides element /*{{{*/
273 // ---------------------------------------------------------------------
274 /* */
275 bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
276 string PackageName,
277 string Version)
278 {
279 pkgCache &Cache = Owner->Cache;
280
281 // We do not add self referencing provides
282 if (Ver.ParentPkg().Name() == PackageName)
283 return true;
284
285 // Get a structure
286 unsigned long Provides = Owner->Map.Allocate(sizeof(pkgCache::Provides));
287 if (Provides == 0)
288 return false;
289
290 // Fill it in
291 pkgCache::PrvIterator Prv(Cache,Cache.ProvideP + Provides,Cache.PkgP);
292 Prv->Version = Ver.Index();
293 Prv->NextPkgProv = Ver->ProvidesList;
294 Ver->ProvidesList = Prv.Index();
295 if (Version.empty() == false && (Prv->Version = WriteString(Version)) == 0)
296 return false;
297
298 // Locate the target package
299 pkgCache::PkgIterator Pkg;
300 if (Owner->NewPackage(Pkg,PackageName) == false)
301 return false;
302
303 // Link it to the package
304 Prv->ParentPkg = Pkg.Index();
305 Prv->NextProvides = Pkg->ProvidesList;
306 Pkg->ProvidesList = Prv.Index();
307
308 return true;
309 }
310 /*}}}*/
311 // CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/
312 // ---------------------------------------------------------------------
313 /* This is used to select which file is to be associated with all newly
314 added versions. */
315 bool pkgCacheGenerator::SelectFile(string File,unsigned long Flags)
316 {
317 struct stat Buf;
318 if (stat(File.c_str(),&Buf) == -1)
319 return _error->Errno("stat","Couldn't stat ",File.c_str());
320
321 // Get some space for the structure
322 CurrentFile = Cache.PkgFileP + Map.Allocate(sizeof(*CurrentFile));
323 if (CurrentFile == Cache.PkgFileP)
324 return false;
325
326 // Fill it in
327 CurrentFile->FileName = Map.WriteString(File);
328 CurrentFile->Size = Buf.st_size;
329 CurrentFile->mtime = Buf.st_mtime;
330 CurrentFile->NextFile = Cache.HeaderP->FileList;
331 CurrentFile->Flags = Flags;
332 CurrentFile->ID = Cache.HeaderP->PackageFileCount;
333 PkgFileName = File;
334 Cache.HeaderP->FileList = CurrentFile - Cache.PkgFileP;
335 Cache.HeaderP->PackageFileCount++;
336
337 if (CurrentFile->FileName == 0)
338 return false;
339
340 Progress.SubProgress(Buf.st_size);
341 return true;
342 }
343 /*}}}*/
344 // CacheGenerator::WriteUniqueString - Insert a unique string /*{{{*/
345 // ---------------------------------------------------------------------
346 /* This is used to create handles to strings. Given the same text it
347 always returns the same number */
348 unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
349 unsigned int Size)
350 {
351 // Search for an insertion point
352 pkgCache::StringItem *I = Cache.StringItemP + Cache.HeaderP->StringList;
353 int Res = 1;
354 __apt_ptrloc *Last = &Cache.HeaderP->StringList;
355 for (; I != Cache.StringItemP; Last = &I->NextItem,
356 I = Cache.StringItemP + I->NextItem)
357 {
358 Res = stringcmp(S,S+Size,Cache.StrP + I->String);
359 if (Res >= 0)
360 break;
361 }
362
363 // Match
364 if (Res == 0)
365 return I->String;
366
367 // Get a structure
368 unsigned long Item = Map.Allocate(sizeof(pkgCache::StringItem));
369 if (Item == 0)
370 return 0;
371
372 // Fill in the structure
373 pkgCache::StringItem *ItemP = Cache.StringItemP + Item;
374 ItemP->NextItem = I - Cache.StringItemP;
375 *Last = Item;
376 ItemP->String = Map.WriteString(S,Size);
377 if (ItemP->String == 0)
378 return 0;
379
380 return ItemP->String;
381 }
382 /*}}}*/
383
384 // SrcCacheCheck - Check if the source package cache is uptodate /*{{{*/
385 // ---------------------------------------------------------------------
386 /* The source cache is checked against the source list and the files
387 on disk, any difference results in a false. */
388 bool pkgSrcCacheCheck(pkgSourceList &List)
389 {
390 if (_error->PendingError() == true)
391 return false;
392
393 string CacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
394 string ListDir = _config->FindDir("Dir::State::lists");
395
396 // Count the number of missing files
397 int Missing = 0;
398 for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
399 {
400 string File = ListDir + URItoFileName(I->PackagesURI());
401 struct stat Buf;
402 if (stat(File.c_str(),&Buf) != 0)
403 {
404 _error->WarningE("stat","Couldn't stat source package list '%s' (%s)",
405 I->PackagesInfo().c_str(),File.c_str());
406 Missing++;
407 }
408 }
409
410 // Open the source package cache
411 if (FileExists(CacheFile) == false)
412 return false;
413
414 FileFd CacheF(CacheFile,FileFd::ReadOnly);
415 if (_error->PendingError() == true)
416 {
417 _error->Discard();
418 return false;
419 }
420
421 MMap Map(CacheF,MMap::Public | MMap::ReadOnly);
422 if (_error->PendingError() == true || Map.Size() == 0)
423 {
424 _error->Discard();
425 return false;
426 }
427
428 pkgCache Cache(Map);
429 if (_error->PendingError() == true)
430 {
431 _error->Discard();
432 return false;
433 }
434
435 // They are certianly out of sync
436 if (Cache.Head().PackageFileCount != List.size() - Missing)
437 return false;
438
439 for (pkgCache::PkgFileIterator F(Cache); F.end() == false; F++)
440 {
441 // Search for a match in the source list
442 bool Bad = true;
443 for (pkgSourceList::const_iterator I = List.begin();
444 I != List.end(); I++)
445 {
446 string File = ListDir + URItoFileName(I->PackagesURI());
447 if (F.FileName() == File)
448 {
449 Bad = false;
450 break;
451 }
452 }
453
454 // Check if the file matches what was cached
455 Bad |= !F.IsOk();
456 if (Bad == true)
457 return false;
458 }
459
460 return true;
461 }
462 /*}}}*/
463 // PkgCacheCheck - Check if the package cache is uptodate /*{{{*/
464 // ---------------------------------------------------------------------
465 /* This does a simple check of all files used to compose the cache */
466 bool pkgPkgCacheCheck(string CacheFile)
467 {
468 if (_error->PendingError() == true)
469 return false;
470
471 // Open the source package cache
472 if (FileExists(CacheFile) == false)
473 return false;
474
475 FileFd CacheF(CacheFile,FileFd::ReadOnly);
476 if (_error->PendingError() == true)
477 {
478 _error->Discard();
479 return false;
480 }
481
482 MMap Map(CacheF,MMap::Public | MMap::ReadOnly);
483 if (_error->PendingError() == true || Map.Size() == 0)
484 {
485 _error->Discard();
486 return false;
487 }
488
489 pkgCache Cache(Map);
490 if (_error->PendingError() == true)
491 {
492 _error->Discard();
493 return false;
494 }
495
496 // Status files that must be in the cache
497 string Status[3];
498 Status[0] = _config->FindFile("Dir::State::xstatus");
499 Status[1]= _config->FindFile("Dir::State::userstatus");
500 Status[2] = _config->FindFile("Dir::State::status");
501
502 // Cheack each file
503 for (pkgCache::PkgFileIterator F(Cache); F.end() == false; F++)
504 {
505 if (F.IsOk() == false)
506 return false;
507
508 // See if this is one of the status files
509 for (int I = 0; I != 3; I++)
510 if (F.FileName() == Status[I])
511 Status[I] = string();
512 }
513
514 // Make sure all the status files are loaded.
515 for (int I = 0; I != 3; I++)
516 {
517 if (Status[I].empty() == false && FileExists(Status[I]) == true)
518 return false;
519 }
520
521 return true;
522 }
523 /*}}}*/
524 // AddSourcesSize - Add the size of the status files /*{{{*/
525 // ---------------------------------------------------------------------
526 /* This adds the size of all the status files to the size counter */
527 static bool pkgAddSourcesSize(unsigned long &TotalSize)
528 {
529 // Grab the file names
530 string xstatus = _config->FindFile("Dir::State::xstatus");
531 string userstatus = _config->FindFile("Dir::State::userstatus");
532 string status = _config->FindFile("Dir::State::status");
533
534 // Grab the sizes
535 struct stat Buf;
536 if (stat(xstatus.c_str(),&Buf) == 0)
537 TotalSize += Buf.st_size;
538 if (stat(userstatus.c_str(),&Buf) == 0)
539 TotalSize += Buf.st_size;
540 if (stat(status.c_str(),&Buf) != 0)
541 return _error->Errno("stat","Couldn't stat the status file %s",status.c_str());
542 TotalSize += Buf.st_size;
543
544 return true;
545 }
546 /*}}}*/
547 // MergeStatus - Add the status files to the cache /*{{{*/
548 // ---------------------------------------------------------------------
549 /* This adds the status files to the map */
550 static bool pkgMergeStatus(OpProgress &Progress,pkgCacheGenerator &Gen,
551 unsigned long &CurrentSize,unsigned long TotalSize)
552 {
553 // Grab the file names
554 string Status[3];
555 Status[0] = _config->FindFile("Dir::State::xstatus");
556 Status[1]= _config->FindFile("Dir::State::userstatus");
557 Status[2] = _config->FindFile("Dir::State::status");
558
559 for (int I = 0; I != 3; I++)
560 {
561 // Check if the file exists and it is not the primary status file.
562 string File = Status[I];
563 if (I != 2 && FileExists(File) == false)
564 continue;
565
566 FileFd Pkg(File,FileFd::ReadOnly);
567 debListParser Parser(Pkg);
568 Progress.OverallProgress(CurrentSize,TotalSize,Pkg.Size(),"Reading Package Lists");
569 if (_error->PendingError() == true)
570 return _error->Error("Problem opening %s",File.c_str());
571 CurrentSize += Pkg.Size();
572
573 Progress.SubProgress(0,"Local Package State - " + flNotDir(File));
574 if (Gen.SelectFile(File,pkgCache::Flag::NotSource) == false)
575 return _error->Error("Problem with SelectFile %s",File.c_str());
576
577 if (Gen.MergeList(Parser) == false)
578 return _error->Error("Problem with MergeList %s",File.c_str());
579 Progress.Progress(Pkg.Size());
580 }
581
582 return true;
583 }
584 /*}}}*/
585 // MakeStatusCache - Generates a cache that includes the status files /*{{{*/
586 // ---------------------------------------------------------------------
587 /* This copies the package source cache and then merges the status and
588 xstatus files into it. */
589 bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress)
590 {
591 Progress.OverallProgress(0,1,1,"Reading Package Lists");
592
593 string CacheFile = _config->FindFile("Dir::Cache::pkgcache");
594 bool SrcOk = pkgSrcCacheCheck(List);
595 bool PkgOk = SrcOk && pkgPkgCacheCheck(CacheFile);
596
597 // Rebuild the source and package caches
598 if (SrcOk == false)
599 {
600 string SCacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
601 string ListDir = _config->FindDir("Dir::State::lists");
602 FileFd SCacheF(SCacheFile,FileFd::WriteEmpty);
603 FileFd CacheF(CacheFile,FileFd::WriteEmpty);
604 DynamicMMap Map(CacheF,MMap::Public);
605 if (_error->PendingError() == true)
606 return false;
607
608 pkgCacheGenerator Gen(Map,Progress);
609
610 // Prepare the progress indicator
611 unsigned long TotalSize = 0;
612 struct stat Buf;
613 for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
614 {
615 string File = ListDir + URItoFileName(I->PackagesURI());
616 if (stat(File.c_str(),&Buf) != 0)
617 continue;
618 TotalSize += Buf.st_size;
619 }
620
621 if (pkgAddSourcesSize(TotalSize) == false)
622 return false;
623
624 // Generate the pkg source cache
625 unsigned long CurrentSize = 0;
626 for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
627 {
628 string File = ListDir + URItoFileName(I->PackagesURI());
629
630 if (stat(File.c_str(),&Buf) != 0)
631 continue;
632
633 FileFd Pkg(File,FileFd::ReadOnly);
634 debListParser Parser(Pkg);
635 Progress.OverallProgress(CurrentSize,TotalSize,Pkg.Size(),"Reading Package Lists");
636 if (_error->PendingError() == true)
637 return _error->Error("Problem opening %s",File.c_str());
638 CurrentSize += Pkg.Size();
639
640 Progress.SubProgress(0,I->PackagesInfo());
641 if (Gen.SelectFile(File) == false)
642 return _error->Error("Problem with SelectFile %s",File.c_str());
643
644 if (Gen.MergeList(Parser) == false)
645 return _error->Error("Problem with MergeList %s",File.c_str());
646 }
647
648 // Write the src cache
649 Gen.GetCache().HeaderP->Dirty = false;
650 if (SCacheF.Write(Map.Data(),Map.Size()) == false)
651 return _error->Error("IO Error saving source cache");
652 Gen.GetCache().HeaderP->Dirty = true;
653
654 // Merge in the source caches
655 return pkgMergeStatus(Progress,Gen,CurrentSize,TotalSize);
656 }
657
658 if (PkgOk == true)
659 {
660 Progress.OverallProgress(1,1,1,"Reading Package Lists");
661 return true;
662 }
663
664 // We use the source cache to generate the package cache
665 string SCacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
666
667 FileFd SCacheF(SCacheFile,FileFd::ReadOnly);
668 FileFd CacheF(CacheFile,FileFd::WriteEmpty);
669 DynamicMMap Map(CacheF,MMap::Public);
670 if (_error->PendingError() == true)
671 return false;
672
673 // Preload the map with the source cache
674 if (SCacheF.Read((unsigned char *)Map.Data() + Map.RawAllocate(SCacheF.Size()),
675 SCacheF.Size()) == false)
676 return false;
677
678 pkgCacheGenerator Gen(Map,Progress);
679
680 // Compute the progress
681 unsigned long TotalSize = 0;
682 if (pkgAddSourcesSize(TotalSize) == false)
683 return false;
684
685 unsigned long CurrentSize = 0;
686 return pkgMergeStatus(Progress,Gen,CurrentSize,TotalSize);
687 }
688 /*}}}*/