summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-05-10 20:40:47 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-05-10 20:40:47 +0200
commitdb09a1c5dd74f422571c4130364bb7c78200e8c8 (patch)
tree4e7d72b2525c56c3d3708b425be1eb6a6459a6e0
parent3fa950f16cb2997bccd97475f75c5f3e37609dd3 (diff)
* apt-pkg/algorithms.cc:
- factor out of ListUpdate a AcquireUpdate to be able to provide your own pkgAcquire fetcher to the wrapper
-rw-r--r--apt-pkg/algorithms.cc37
-rw-r--r--apt-pkg/algorithms.h4
-rw-r--r--debian/changelog3
3 files changed, 32 insertions, 12 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 8beb2d51c..e7b359981 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -1453,7 +1453,7 @@ void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List)
qsort(List,Count,sizeof(*List),PrioComp);
}
/*}}}*/
-// ListUpdate - update the cache files /*{{{*/
+// ListUpdate - construct Fetcher and 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)
@@ -1462,7 +1462,6 @@ bool ListUpdate(pkgAcquireStatus &Stat,
pkgSourceList &List,
int PulseInterval)
{
- pkgAcquire::RunResult res;
pkgAcquire Fetcher;
if (Fetcher.Setup(&Stat, _config->FindDir("Dir::State::Lists")) == false)
return false;
@@ -1471,11 +1470,24 @@ bool ListUpdate(pkgAcquireStatus &Stat,
if (List.GetIndexes(&Fetcher) == false)
return false;
+ return AcquireUpdate(Fetcher, PulseInterval, true);
+}
+ /*}}}*/
+// AcquireUpdate - take Fetcher and update the cache files /*{{{*/
+// ---------------------------------------------------------------------
+/* This is a simple wrapper to update the cache with a provided acquire
+ * If you only need control over Status and the used SourcesList use
+ * ListUpdate method instead.
+ */
+bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval,
+ bool const RunUpdateScripts, bool const ListCleanup)
+{
// Run scripts
- RunScripts("APT::Update::Pre-Invoke");
-
- // check arguments
- if(PulseInterval>0)
+ if (RunUpdateScripts == true)
+ RunScripts("APT::Update::Pre-Invoke");
+
+ pkgAcquire::RunResult res;
+ if(PulseInterval > 0)
res = Fetcher.Run(PulseInterval);
else
res = Fetcher.Run();
@@ -1512,7 +1524,7 @@ bool ListUpdate(pkgAcquireStatus &Stat,
// 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 &&
+ if (!TransientNetworkFailure && !Failed && ListCleanup == true &&
(_config->FindB("APT::Get::List-Cleanup",true) == true &&
_config->FindB("APT::List-Cleanup",true) == true))
{
@@ -1529,11 +1541,14 @@ bool ListUpdate(pkgAcquireStatus &Stat,
// Run the success scripts if all was fine
- if(!TransientNetworkFailure && !Failed)
- RunScripts("APT::Update::Post-Invoke-Success");
+ if (RunUpdateScripts == true)
+ {
+ if(!TransientNetworkFailure && !Failed)
+ RunScripts("APT::Update::Post-Invoke-Success");
- // Run the other scripts
- RunScripts("APT::Update::Post-Invoke");
+ // Run the other scripts
+ RunScripts("APT::Update::Post-Invoke");
+ }
return true;
}
/*}}}*/
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h
index 37eacf1f8..076542c20 100644
--- a/apt-pkg/algorithms.h
+++ b/apt-pkg/algorithms.h
@@ -147,5 +147,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache);
void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List);
bool ListUpdate(pkgAcquireStatus &progress, pkgSourceList &List, int PulseInterval=0);
-
+bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval = 0,
+ bool const RunUpdateScripts = true, bool const ListCleanup = true);
+
#endif
diff --git a/debian/changelog b/debian/changelog
index 040ca9544..7b1ed46ac 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -48,6 +48,9 @@ apt (0.9.3) UNRELEASED; urgency=low
- ensure that d is set before accessing it
* apt-pkg/aptconfiguration.cc:
- use NULL instead of "" for no (un)compress parameters
+ * apt-pkg/algorithms.cc:
+ - factor out of ListUpdate a AcquireUpdate to be able to provide your
+ own pkgAcquire fetcher to the wrapper
-- David Kalnischkies <kalnischkies@gmail.com> Mon, 07 May 2012 21:12:23 +0200