-// PM::GetArchives - Puts the install archives in the aquire list /*{{{*/
-// ---------------------------------------------------------------------
-/* The Source list is used to convert the packages to install into
- URNs which are then passed to Aquire to convert to FileNames. */
-bool pkgPackageManager::GetArchives(pkgSourceList &List,pkgAquire &Engine)
-{
- pkgControlCache CCache(Cache);
- if (_error->PendingError() == true)
- return false;
-
- Engine.OutputDir(PKG_DEB_CA_ARCHIVES);
- pkgCache::PkgIterator I = Cache.PkgBegin();
- for (;I.end() != true; I++)
- {
- // Not interesting
- if ((Cache[I].InstallVer == (pkgCache::Version *)I.CurrentVer() &&
- I.State() != pkgCache::PkgIterator::NeedsUnpack) ||
- Cache[I].Delete() == true)
- continue;
-
- // Cross match with the source list.
- pkgSourceList::const_iterator Dist = List.MatchPkgFile(Cache[I].InstVerIter(Cache));
- if (Dist == List.end())
- {
- _error->Warning("Couldn't locate an archive source for package %s",I.Name());
- continue;
- }
-
- // Read in the info record
- pkgSPkgCtrlInfo Inf = CCache[Cache[I].InstVerIter(Cache)];
- if (Inf.isNull() == true)
- {
- _error->Warning("Couldn't locate info for package %s",I.Name());
- continue;
- }
-
- // Isolate the filename
- string File = Inf->Find("Filename")->Value();
- if (File.empty() == true)
- {
- _error->Warning("Couldn't locate an archive for package %s",I.Name());
- continue;
- }
-
- // Generate the get request.
- string URI = Dist->ArchiveURI(File);
-
- // Output file
- unsigned int Pos = File.rfind('/');
- if (Pos == File.length())
- return _error->Error("Malformed file line in package %s",I.Name());
-
- // Null pos isnt used in present package files
- if (Pos == string::npos)
- Pos = 0;
- else
- Pos++;
-
- if (Engine.Get(URI,string(File,Pos),
- Dist->ArchiveInfo(Cache[I].InstVerIter(Cache)),
- Cache[I].InstVerIter(Cache)->Size,
- Inf->Find("MD5sum")->Value(),
- &FileNames[I->ID]) == false)
- return false;
- }
-
- return true;
-}
- /*}}}*/