summaryrefslogtreecommitdiff
path: root/apt-pkg/algorithms.cc
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2008-01-07 21:26:11 +0100
committerMichael Vogt <egon@bottom>2008-01-07 21:26:11 +0100
commit187b88d8d90ee10b2e2e14ba762be2fdd9fce744 (patch)
treefbb090aa431bcd89a7207b20d3b585ff43456d8e /apt-pkg/algorithms.cc
parent0a626f9e3738d5ff70b81820b3c497a4a50f589c (diff)
parentf0983ff2091df782027a2e344cbd9e3df43c1450 (diff)
* apt-pkg/packagemanager.{cc,h}:
- propergate the Immediate flag to make hitting the "E: Internal Error, Could not perform immediate configuration (2)" harder * debian/control: - build against libdb-dev (instead of libdb4.4-dev) * merged the apt--DoListUpdate branch, this provides a common interface for "apt-get update" like operations for the frontends and also provides hooks to run stuff in APT::Update::{Pre,Post}-Invoke
Diffstat (limited to 'apt-pkg/algorithms.cc')
-rw-r--r--apt-pkg/algorithms.cc76
1 files changed, 75 insertions, 1 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 158f9c258..6e2b97557 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -19,7 +19,7 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/version.h>
#include <apt-pkg/sptr.h>
-
+#include <apt-pkg/acquire-item.h>
#include <apti18n.h>
#include <sys/types.h>
@@ -1302,3 +1302,77 @@ void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List)
}
/*}}}*/
+// 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 scripts if all was fine
+ RunScripts("APT::Update::Post-Invoke");
+ return true;
+}
+ /*}}}*/