From: Michael Vogt Date: Tue, 23 Sep 2014 13:47:44 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/debian/experimental' into feature/acq-trans X-Git-Tag: 1.1.exp4~6^2~50 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/db1d1c32149177c0b6ca49e5107ab1f5fd364660 Merge remote-tracking branch 'upstream/debian/experimental' into feature/acq-trans Conflicts: apt-pkg/acquire-item.cc apt-pkg/acquire-item.h methods/copy.cc test/integration/test-hashsum-verification --- db1d1c32149177c0b6ca49e5107ab1f5fd364660 diff --cc apt-pkg/acquire-item.cc index 1fa7971c5,bbdd3897a..e8b0e25de --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@@ -1065,9 -1136,9 +1065,10 @@@ void pkgAcqIndex::Done(string Message,u { if (ExpectedHashes.usable() && ExpectedHashes != Hashes) { + Desc.URI = RealURI; RenameOnError(HashSumMismatch); printHashSumComparision(RealURI, ExpectedHashes, Hashes); + Failed(Message, Cfg); return; } @@@ -1094,16 -1163,21 +1095,17 @@@ } } - // Done, move it into position - string FinalFile = GetFinalFilename(RealURI, compExt); - Rename(DestFile,FinalFile); - chmod(FinalFile.c_str(),0644); - - /* We restore the original name to DestFile so that the clean operation - will work OK */ - DestFile = _config->FindDir("Dir::State::lists") + "partial/"; - DestFile += URItoFileName(RealURI); - if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz") - DestFile += ".gz"; + // FIXME: can we void the "Erase" bool here as its very non-local? + std::string CompressedFile = _config->FindDir("Dir::State::lists") + "partial/"; + CompressedFile += URItoFileName(RealURI); + // Remove the compressed version. if (Erase == true) - unlink(DestFile.c_str()); + unlink(CompressedFile.c_str()); + + // Done, queue for rename on transaction finished + PartialFile = DestFile; + DestFile = GetFinalFilename(RealURI, compExt); return; } @@@ -1162,14 -1209,33 +1151,33 @@@ Erase = true; else Local = true; - + + // do not reverify cdrom sources as apt-cdrom may rewrite the Packages + // file when its doing the indexcopy + if (RealURI.substr(0,6) == "cdrom:" && + StringToBool(LookupTag(Message,"IMS-Hit"),false) == true) + return; + + // The files timestamp matches, for non-local URLs reverify the local + // file, for local file, uncompress again to ensure the hashsum is still + // matching the Release file + if (!Local && StringToBool(LookupTag(Message,"IMS-Hit"),false) == true) + { - ReverifyAfterIMS(FileName); ++ ReverifyAfterIMS(); + return; + } string decompProg; - // If we enable compressed indexes and already have gzip, keep it - if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz" && !Local) { - // Done, queue for rename on transaction finished - PartialFile = DestFile; - DestFile = GetFinalFilename(RealURI, compExt); + // If we enable compressed indexes, queue for hash verification + if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz" && !Local) + { + DestFile = _config->FindDir("Dir::State::lists"); + DestFile += URItoFileName(RealURI) + ".gz"; + + Decompression = true; + Desc.URI = "copy:" + FileName; + QueueURI(Desc); + return; } diff --cc methods/copy.cc index 8c797ff1f,b78053d36..30a3f4a51 --- a/methods/copy.cc +++ b/methods/copy.cc @@@ -70,15 -70,15 +70,23 @@@ bool CopyMethod::Fetch(FetchItem *Itm Res.LastModified = Buf.st_mtime; Res.IMSHit = false; URIStart(Res); + + // when the files are identical, just compute the hashes + if(File == Itm->DestFile) + { + CalculateHashes(Res); + URIDone(Res); + return true; + } + // just calc the hashes if the source and destination are identical + if (File == Itm->DestFile) + { + CalculateHashes(Res); + URIDone(Res); + return true; + } + // See if the file exists FileFd From(File,FileFd::ReadOnly); FileFd To(Itm->DestFile,FileFd::WriteAtomic);