diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-06-26 06:30:09 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-06-26 06:30:09 +0200 |
commit | a23dcda4a75ead3ef9712d90300f45155856b6ce (patch) | |
tree | 8951be2e20b5403c4339fa246b59d7770c8e2e46 /apt-pkg | |
parent | bc03039d0f532b6463de33bff60c7d876af6ea5e (diff) | |
parent | b90d7d855709c49a6d5faff0ac65b96fd15e4500 (diff) |
* merged with mainline
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 70 | ||||
-rw-r--r-- | apt-pkg/acquire-item.h | 4 | ||||
-rw-r--r-- | apt-pkg/acquire.cc | 8 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 11 | ||||
-rw-r--r-- | apt-pkg/deb/debversion.cc | 23 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 8 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 10 | ||||
-rw-r--r-- | apt-pkg/tagfile.cc | 95 | ||||
-rw-r--r-- | apt-pkg/tagfile.h | 5 |
9 files changed, 126 insertions, 108 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 88c25de43..1fa929aad 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -340,12 +340,6 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, // File was already in place. It needs to be re-verified // because Release might have changed, so Move it into partial Rename(Final,DestFile); - // unlink the file and do not try to use I-M-S and Last-Modified - // if the users proxy is broken - if(_config->FindB("Acquire::BrokenProxy", false) == true) { - std::cerr << "forcing re-get of the signature file as requested" << std::endl; - unlink(DestFile.c_str()); - } } QueueURI(Desc); @@ -395,18 +389,19 @@ void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5, /*}}}*/ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) { - // Delete any existing sigfile, so that this source isn't - // mistakenly trusted - string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI); - unlink(Final.c_str()); - // if we get a timeout if fail + // if we get a network error we fail gracefully if(LookupTag(Message,"FailReason") == "Timeout" || - LookupTag(Message,"FailReason") == "TmpResolveFailure") { + LookupTag(Message,"FailReason") == "TmpResolveFailure" || + LookupTag(Message,"FailReason") == "ConnectionRefused") { Item::Failed(Message,Cnf); return; } + // Delete any existing sigfile when the acquire failed + string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI); + unlink(Final.c_str()); + // queue a pkgAcqMetaIndex with no sigfile new pkgAcqMetaIndex(Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc, "", IndexTargets, MetaIndexParser); @@ -430,7 +425,7 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner, const vector<struct IndexTarget*>* IndexTargets, indexRecords* MetaIndexParser) : Item(Owner), RealURI(URI), SigFile(SigFile), AuthPass(false), - MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets) + MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets), IMSHit(false) { DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += URItoFileName(URI); @@ -523,6 +518,9 @@ void pkgAcqMetaIndex::RetrievalDone(string Message) return; } + // see if the download was a IMSHit + IMSHit = StringToBool(LookupTag(Message,"IMS-Hit"),false); + Complete = true; string FinalFile = _config->FindDir("Dir::State::lists"); @@ -551,7 +549,7 @@ void pkgAcqMetaIndex::AuthDone(string Message) return; } - if (!VerifyVendor()) + if (!VerifyVendor(Message)) { return; } @@ -609,7 +607,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) } } -bool pkgAcqMetaIndex::VerifyVendor() +bool pkgAcqMetaIndex::VerifyVendor(string Message) { // // Maybe this should be made available from above so we don't have // // to read and parse it every time? @@ -634,6 +632,22 @@ bool pkgAcqMetaIndex::VerifyVendor() // break; // } // } + string::size_type pos; + + // check for missing sigs (that where not fatal because otherwise we had + // bombed earlier) + string missingkeys; + string msg = _("There are no public key available for the " + "following key IDs:\n"); + pos = Message.find("NO_PUBKEY "); + if (pos != std::string::npos) + { + string::size_type start = pos+strlen("NO_PUBKEY "); + string Fingerprint = Message.substr(start, Message.find("\n")-start); + missingkeys += (Fingerprint); + } + if(!missingkeys.empty()) + _error->Warning("%s", string(msg+missingkeys).c_str()); string Transformed = MetaIndexParser->GetExpectedDist(); @@ -642,7 +656,7 @@ bool pkgAcqMetaIndex::VerifyVendor() Transformed = "experimental"; } - string::size_type pos = Transformed.rfind('/'); + pos = Transformed.rfind('/'); if (pos != string::npos) { Transformed = Transformed.substr(0, pos); @@ -688,10 +702,30 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) { if (AuthPass == true) { - // gpgv method failed + // if we fail the authentication but got the file via a IMS-Hit + // this means that the file wasn't downloaded and that it might be + // just stale (server problem, proxy etc). we delete what we have + // queue it again without i-m-s + // alternatively we could just unlink the file and let the user try again + if (IMSHit) + { + Complete = false; + Local = false; + AuthPass = false; + unlink(DestFile.c_str()); + + DestFile = _config->FindDir("Dir::State::lists") + "partial/"; + DestFile += URItoFileName(RealURI); + Desc.URI = RealURI; + QueueURI(Desc); + return; + } + + // gpgv method failed _error->Warning("GPG error: %s: %s", Desc.Description.c_str(), LookupTag(Message,"Message").c_str()); + } // No Release file was present, or verification failed, so fall @@ -1037,7 +1071,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5, else PartialSize = Buf.st_size; } - + QueueURI(Desc); } /*}}}*/ diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index c34b5ef69..da1bea801 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -151,8 +151,10 @@ class pkgAcqMetaIndex : public pkgAcquire::Item const vector<struct IndexTarget*>* IndexTargets; indexRecords* MetaIndexParser; bool AuthPass; + // required to deal gracefully with problems caused by incorrect ims hits + bool IMSHit; - bool VerifyVendor(); + bool VerifyVendor(string Message); void RetrievalDone(string Message); void AuthDone(string Message); void QueueIndexes(bool verify); diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 57cf60bfe..fff1b2b6a 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -818,7 +818,13 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) unsigned long ETA = (unsigned long)((TotalBytes - CurrentBytes) / CurrentCPS); - snprintf(msg,sizeof(msg), _("Downloading file %li of %li (%s remaining)"), i, TotalItems, TimeToStr(ETA).c_str()); + // only show the ETA if it makes sense + if (ETA > 0 && ETA < 172800 /* two days */ ) + snprintf(msg,sizeof(msg), _("Retrieving file %li of %li (%s remaining)"), i, TotalItems, TimeToStr(ETA).c_str()); + else + snprintf(msg,sizeof(msg), _("Retrieving file %li of %li"), i, TotalItems); + + // build the status str status << "dlstatus:" << i diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b11d2531c..d0dc7a260 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -504,11 +504,12 @@ bool debListParser::ParseProvides(pkgCache::VerIterator Ver) Start = ParseDepends(Start,Stop,Package,Version,Op); if (Start == 0) return _error->Error("Problem parsing Provides line"); - if (Op != pkgCache::Dep::NoOp) - return _error->Error("Malformed provides line"); - - if (NewProvides(Ver,Package,Version) == false) - return false; + if (Op != pkgCache::Dep::NoOp) { + _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str()); + } else { + if (NewProvides(Ver,Package,Version) == false) + return false; + } if (Start == Stop) break; diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc index aeee61929..064d8fa5b 100644 --- a/apt-pkg/deb/debversion.cc +++ b/apt-pkg/deb/debversion.cc @@ -59,7 +59,7 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd, } /* Iterate over the whole string - What this does is to spilt the whole string into groups of + What this does is to split the whole string into groups of numeric and non numeric portions. For instance: a67bhgs89 Has 4 portions 'a', '67', 'bhgs', '89'. A more normal: @@ -140,6 +140,27 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd, if (rhs == BEnd) rhs = B; + // Special case: a zero epoch is the same as no epoch, + // so remove it. + if (lhs != A) + { + for (; *A == '0'; ++A); + if (A == lhs) + { + ++A; + ++lhs; + } + } + if (rhs != B) + { + for (; *B == '0'; ++B); + if (B == rhs) + { + ++B; + ++rhs; + } + } + // Compare the epoch int Res = CmpFragment(A,lhs,B,rhs); if (Res != 0) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index fe8fbca74..667db8ff2 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -375,8 +375,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) }, // Purge operation { - {"config-files", _("Preparing for remove with config %s")}, - {"not-installed", _("Removed with config %s")}, + {"config-files", _("Preparing to completely remove %s")}, + {"not-installed", _("Completely removed %s")}, {NULL, NULL} }, }; @@ -623,8 +623,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) 'status: conffile-prompt: conffile : 'current-conffile' 'new-conffile' useredited distedited */ - char* list[4]; - TokSplitString(':', line, list, 5); + char* list[5]; + TokSplitString(':', line, list, sizeof(list)/sizeof(list[0])); char *pkg = list[1]; char *action = _strstrip(list[2]); diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 22dd53f97..6eb6c1d85 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -24,6 +24,7 @@ #include <iostream> #include <sstream> + #include <apti18n.h> pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) : @@ -837,9 +838,14 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, } } - if (InstPkg.end() == false) + if (InstPkg.end() == false) + { + if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true) + std::clog << "Installing " << InstPkg.Name() + << " as dep of " << Pkg.Name() + << std::endl; MarkInstall(InstPkg, true, Depth + 1, false); - + } continue; } diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index cae0fa819..79ff18de4 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -35,20 +35,20 @@ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) : Fd(*pFd), Size(Size) { - if (Fd.IsOpen() == false) + if (Fd.IsOpen() == false || Fd.Size() == 0) { Buffer = 0; Start = End = Buffer = 0; - Done = true; iOffset = 0; + Map = NULL; return; } - Buffer = new char[Size]; - Start = End = Buffer; - Done = false; + Map = new MMap (Fd, MMap::Public | MMap::ReadOnly); + Buffer = (char *) Map->Data (); + Start = Buffer; + End = Buffer + Map->Size (); iOffset = 0; - Fill(); } /*}}}*/ // TagFile::~pkgTagFile - Destructor /*{{{*/ @@ -56,7 +56,7 @@ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) : /* */ pkgTagFile::~pkgTagFile() { - delete [] Buffer; + delete Map; } /*}}}*/ // TagFile::Step - Advance to the next section /*{{{*/ @@ -64,14 +64,13 @@ pkgTagFile::~pkgTagFile() /* If the Section Scanner fails we refill the buffer and try again. */ bool pkgTagFile::Step(pkgTagSection &Tag) { + if (Start == End) + return false; + if (Tag.Scan(Start,End - Start) == false) { - if (Fill() == false) - return false; - - if (Tag.Scan(Start,End - Start) == false) - return _error->Error(_("Unable to parse package file %s (1)"), - Fd.Name().c_str()); + return _error->Error(_("Unable to parse package file %s (1)"), + Fd.Name().c_str()); } Start += Tag.size(); iOffset += Tag.size(); @@ -80,50 +79,6 @@ bool pkgTagFile::Step(pkgTagSection &Tag) return true; } /*}}}*/ -// TagFile::Fill - Top up the buffer /*{{{*/ -// --------------------------------------------------------------------- -/* This takes the bit at the end of the buffer and puts it at the start - then fills the rest from the file */ -bool pkgTagFile::Fill() -{ - unsigned long EndSize = End - Start; - unsigned long Actual = 0; - - memmove(Buffer,Start,EndSize); - Start = Buffer; - End = Buffer + EndSize; - - if (Done == false) - { - // See if only a bit of the file is left - if (Fd.Read(End,Size - (End - Buffer),&Actual) == false) - return false; - if (Actual != Size - (End - Buffer)) - Done = true; - End += Actual; - } - - if (Done == true) - { - if (EndSize <= 3 && Actual == 0) - return false; - if (Size - (End - Buffer) < 4) - return true; - - // Append a double new line if one does not exist - unsigned int LineCount = 0; - for (const char *E = End - 1; E - End < 6 && (*E == '\n' || *E == '\r'); E--) - if (*E == '\n') - LineCount++; - for (; LineCount < 2; LineCount++) - *End++ = '\n'; - - return true; - } - - return true; -} - /*}}}*/ // TagFile::Jump - Jump to a pre-recorded location in the file /*{{{*/ // --------------------------------------------------------------------- /* This jumps to a pre-recorded file location and reads the record @@ -141,22 +96,10 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset) // Reposition and reload.. iOffset = Offset; - Done = false; - if (Fd.Seek(Offset) == false) - return false; - End = Start = Buffer; - - if (Fill() == false) - return false; - - if (Tag.Scan(Start,End - Start) == true) - return true; - - // This appends a double new line (for the real eof handling) - if (Fill() == false) - return false; + Start = Buffer + iOffset; - if (Tag.Scan(Start,End - Start) == false) + // Start != End is a special case to not fail on empty TagFiles + if (Start != End && Tag.Scan(Start,End - Start) == false) return _error->Error(_("Unable to parse package file %s (2)"),Fd.Name().c_str()); return true; @@ -181,7 +124,7 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength) Stop = Section = Start; memset(AlphaIndexes,0,sizeof(AlphaIndexes)); - if (Stop == 0) + if (Stop == 0 || MaxLength == 0) return false; TagCount = 0; @@ -212,6 +155,12 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength) Stop++; } + if ((Stop+1 >= End) && (End[-1] == '\n' || End[-1] == '\r')) + { + Indexes[TagCount] = (End - 1) - Section; + return true; + } + return false; } /*}}}*/ diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 8c948754d..5cff2681c 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -25,6 +25,7 @@ #endif #include <apt-pkg/fileutl.h> +#include <apt-pkg/mmap.h> #include <stdio.h> class pkgTagSection @@ -69,15 +70,13 @@ class pkgTagSection class pkgTagFile { FileFd &Fd; + MMap *Map; char *Buffer; char *Start; char *End; - bool Done; unsigned long iOffset; unsigned long Size; - bool Fill(); - public: bool Step(pkgTagSection &Section); |