X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/eec898ad83d383f27b94f747245fe82fe11949b0..5f3edc0fb8a81755a5237c0f189dd55ab9f453d9:/apt-pkg/acquire-item.cc diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 35ae7d8b7..2bae109fd 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-item.cc,v 1.28 1999/04/20 05:59:29 jgg Exp $ +// $Id: acquire-item.cc,v 1.39 1999/10/17 20:58:36 jgg Exp $ /* ###################################################################### Acquire Item - Item to acquire @@ -78,7 +78,7 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf) // --------------------------------------------------------------------- /* Stash status and the file size. Note that setting Complete means sub-phases of the acquire process such as decompresion are operating */ -void pkgAcquire::Item::Start(string Message,unsigned long Size) +void pkgAcquire::Item::Start(string /*Message*/,unsigned long Size) { Status = StatFetching; if (FileSize == 0 && Complete == false) @@ -97,6 +97,9 @@ void pkgAcquire::Item::Done(string Message,unsigned long Size,string) if (Owner->Log != 0) Owner->Log->Fetched(Size,atoi(LookupTag(Message,"Resume-Point","0").c_str())); } + + if (FileSize == 0) + FileSize= Size; Status = StatDone; ErrorText = string(); @@ -133,7 +136,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location) DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += URItoFileName(Location->PackagesURI()); - // Create the item + // Create the item Desc.URI = Location->PackagesURI() + ".gz"; Desc.Description = Location->PackagesInfo(); Desc.Owner = this; @@ -320,7 +323,6 @@ void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5) /* */ void pkgAcqIndexRel::Failed(string Message,pkgAcquire::MethodConfig *Cnf) { - // This is the retry counter if (Cnf->LocalOnly == true || StringToBool(LookupTag(Message,"Transient-Failure"),false) == false) { @@ -346,12 +348,20 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, StoreFilename(StoreFilename), Vf(Version.FileList()) { Retries = _config->FindI("Acquire::Retries",0); - + + if (Version.Arch() == 0) + { + _error->Error("I wasn't able to locate file for the %s package. " + "This might mean you need to manually fix this package. (due to missing arch)", + Version.ParentPkg().Name()); + return; + } + // Generate the final file name as: package_version_arch.deb StoreFilename = QuoteString(Version.ParentPkg().Name(),"_:") + '_' + QuoteString(Version.VerStr(),"_:") + '_' + QuoteString(Version.Arch(),"_:.") + ".deb"; - + // Select a source if (QueueNext() == false && _error->PendingError() == false) _error->Error("I wasn't able to locate file for the %s package. " @@ -469,7 +479,8 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash) // Check the size if (Size != Version->Size) { - _error->Error("Size mismatch for package %s",Version.ParentPkg().Name()); + Status = StatError; + ErrorText = "Size mismatch"; return; } @@ -478,8 +489,9 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash) { if (Md5Hash != MD5) { - _error->Error("MD5Sum mismatch for package %s",Version.ParentPkg().Name()); - Rename(DestFile + ".FAILED",DestFile); + Status = StatError; + ErrorText = "MD5Sum mismatch"; + Rename(DestFile,DestFile + ".FAILED"); return; } } @@ -536,14 +548,27 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf) } } /*}}}*/ +// AcqArchive::Finished - Fetching has finished, tidy up /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgAcqArchive::Finished() +{ + if (Status == pkgAcquire::Item::StatDone && + Complete == true) + return; + StoreFilename = string(); +} + /*}}}*/ // AcqFile::pkgAcqFile - Constructor /*{{{*/ // --------------------------------------------------------------------- /* The file is added to the queue */ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5, unsigned long Size,string Dsc,string ShortDesc) : - Item(Owner), MD5(MD5) + Item(Owner), Md5Hash(MD5) { + Retries = _config->FindI("Acquire::Retries",0); + DestFile = flNotDir(URI); // Create the item @@ -574,6 +599,18 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5, /* */ void pkgAcqFile::Done(string Message,unsigned long Size,string MD5) { + // Check the md5 + if (Md5Hash.empty() == false && MD5.empty() == false) + { + if (Md5Hash != MD5) + { + Status = StatError; + ErrorText = "MD5Sum mismatch"; + Rename(DestFile,DestFile + ".FAILED"); + return; + } + } + Item::Done(Message,Size,MD5); string FileName = LookupTag(Message,"Filename"); @@ -594,9 +631,39 @@ void pkgAcqFile::Done(string Message,unsigned long Size,string MD5) if (FileName != DestFile) { Local = true; - Desc.URI = "copy:" + FileName; + if (_config->FindB("Acquire::Source-Symlinks",true) == false) + { + Desc.URI = "copy:" + FileName; + QueueURI(Desc); + return; + } + + if (symlink(FileName.c_str(),DestFile.c_str()) != 0) + { + ErrorText = "Link to " + DestFile + "failure "; + Status = StatError; + Complete = false; + } + } +} + /*}}}*/ +// AcqFile::Failed - Failure handler /*{{{*/ +// --------------------------------------------------------------------- +/* Here we try other sources */ +void pkgAcqFile::Failed(string Message,pkgAcquire::MethodConfig *Cnf) +{ + ErrorText = LookupTag(Message,"Message"); + + // This is the retry counter + if (Retries != 0 && + Cnf->LocalOnly == false && + StringToBool(LookupTag(Message,"Transient-Failure"),false) == true) + { + Retries--; QueueURI(Desc); return; } + + Item::Failed(Message,Cnf); } /*}}}*/