From: Michael Vogt Date: Mon, 4 Feb 2008 11:29:57 +0000 (+0100) Subject: merged from apt--mvo X-Git-Tag: 0.7.24ubuntu1~101^2~1 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/453a5e964ef7404909132a4c5e9e734026fc93a3?ds=inline;hp=-c merged from apt--mvo --- 453a5e964ef7404909132a4c5e9e734026fc93a3 diff --combined apt-pkg/algorithms.cc index c5e3c7b38,503a928ac..50cb6b659 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@@ -19,7 -19,7 +19,7 @@@ #include #include #include - + #include #include #include @@@ -1107,7 -1107,8 +1107,7 @@@ bool pkgProblemResolver::Resolve(bool B return _error->Error(_("Unable to correct problems, you have held broken packages.")); } - // set the auto-flags (mvo: I'm not sure if we _really_ need this, but - // I didn't managed + // set the auto-flags (mvo: I'm not sure if we _really_ need this) pkgCache::PkgIterator I = Cache.PkgBegin(); for (;I.end() != true; I++) { if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) { @@@ -1301,3 -1302,81 +1301,81 @@@ void pkgPrioSortList(pkgCache &Cache,pk } /*}}}*/ + // CacheFile::ListUpdate - update the cache files /*{{{*/ + // --------------------------------------------------------------------- + /* This is a simple wrapper to update the cache. it will fetch stuff + * from the network (or any other sources defined in sources.list) + */ + bool ListUpdate(pkgAcquireStatus &Stat, + pkgSourceList &List, + int PulseInterval) + { + pkgAcquire::RunResult res; + pkgAcquire Fetcher(&Stat); + + // Populate it with the source selection + if (List.GetIndexes(&Fetcher) == false) + return false; + + // Run scripts + RunScripts("APT::Update::Pre-Invoke"); + + // check arguments + if(PulseInterval>0) + res = Fetcher.Run(PulseInterval); + else + res = Fetcher.Run(); + + if (res == pkgAcquire::Failed) + return false; + + bool Failed = false; + bool TransientNetworkFailure = false; + for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); + I != Fetcher.ItemsEnd(); I++) + { + if ((*I)->Status == pkgAcquire::Item::StatDone) + continue; + + (*I)->Finished(); + + _error->Warning(_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(), + (*I)->ErrorText.c_str()); + + if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) + { + TransientNetworkFailure = true; + continue; + } + + Failed = true; + } + + // Clean out any old list files + // Keep "APT::Get::List-Cleanup" name for compatibility, but + // this is really a global option for the APT library now + if (!TransientNetworkFailure && !Failed && + (_config->FindB("APT::Get::List-Cleanup",true) == true && + _config->FindB("APT::List-Cleanup",true) == true)) + { + if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false || + Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false) + // something went wrong with the clean + return false; + } + + if (TransientNetworkFailure == true) + _error->Warning(_("Some index files failed to download, they have been ignored, or old ones used instead.")); + else if (Failed == true) + return _error->Error(_("Some index files failed to download, they have been ignored, or old ones used instead.")); + + + // Run the success scripts if all was fine + if(!TransientNetworkFailure && !Failed) + RunScripts("APT::Update::Post-Invoke-Success"); + + // Run the other scripts + RunScripts("APT::Update::Post-Invoke"); + return true; + } + /*}}}*/