summaryrefslogtreecommitdiff
path: root/apt-pkg/algorithms.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-09-18 17:55:44 +0200
committerMichael Vogt <mvo@debian.org>2013-09-18 17:55:44 +0200
commitfacea693b2078327b59502e663c238c50118e96a (patch)
treee0e38838817c3b0d2a63c7a1da03b699322e08d3 /apt-pkg/algorithms.cc
parent3e2d892340d42053d388bda3d50dfbee99299082 (diff)
improve the API for Upgrade()
Diffstat (limited to 'apt-pkg/algorithms.cc')
-rw-r--r--apt-pkg/algorithms.cc38
1 files changed, 30 insertions, 8 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 69d4acd83..68531f3ca 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -422,12 +422,8 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
return Fix.Resolve();
}
/*}}}*/
-// AllUpgrade - Upgrade as many packages as possible /*{{{*/
-// ---------------------------------------------------------------------
-/* Right now the system must be consistent before this can be called.
- It also will not change packages marked for install, it only tries
- to install packages not marked for install */
-bool pkgAllUpgrade(pkgDepCache &Cache)
+// AllUpgradeNoNewPackages - Upgrade but no removals or new pkgs /*{{{*/
+bool pkgAllUpgradeNoNewPackages(pkgDepCache &Cache)
{
std::string const solver = _config->Find("APT::Solver", "internal");
if (solver != "internal") {
@@ -459,13 +455,13 @@ bool pkgAllUpgrade(pkgDepCache &Cache)
return Fix.ResolveByKeep();
}
/*}}}*/
-// AllUpgradeNoDelete - Upgrade without removing packages /*{{{*/
+// AllUpgradeWithNewInstalls - Upgrade + install new packages as needed /*{{{*/
// ---------------------------------------------------------------------
/* Right now the system must be consistent before this can be called.
* Upgrade as much as possible without deleting anything (useful for
* stable systems)
*/
-bool pkgAllUpgradeNoDelete(pkgDepCache &Cache)
+bool pkgAllUpgradeWithNewPackages(pkgDepCache &Cache)
{
pkgDepCache::ActionGroup group(Cache);
@@ -502,6 +498,16 @@ bool pkgAllUpgradeNoDelete(pkgDepCache &Cache)
return Fix.ResolveByKeep();
}
/*}}}*/
+// AllUpgrade - Upgrade as many packages as possible /*{{{*/
+// ---------------------------------------------------------------------
+/* Right now the system must be consistent before this can be called.
+ It also will not change packages marked for install, it only tries
+ to install packages not marked for install */
+bool pkgAllUpgrade(pkgDepCache &Cache)
+{
+ return pkgAllUpgradeNoNewPackages(Cache);
+}
+ /*}}}*/
// MinimizeUpgrade - Minimizes the set of packages to be upgraded /*{{{*/
// ---------------------------------------------------------------------
/* This simply goes over the entire set of packages and tries to keep
@@ -547,6 +553,22 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache)
return true;
}
/*}}}*/
+// APT::Upgrade::Upgrade - Upgrade using a specific strategy /*{{{*/
+bool APT::Upgrade::Upgrade(pkgDepCache &Cache, APT::Upgrade::UpgradeMode mode)
+{
+ switch(mode) {
+ case APT::Upgrade::NO_INSTALL_OR_REMOVE:
+ return pkgAllUpgradeNoNewPackages(Cache);
+ case APT::Upgrade::ALLOW_NEW_INSTALLS:
+ return pkgAllUpgradeWithNewPackages(Cache);
+ case APT::Upgrade::ALLOW_REMOVAL_AND_NEW_INSTALLS:
+ return pkgDistUpgrade(Cache);
+ default:
+ _error->Error("pkgAllUpgrade called with unknwon mode %i", mode);
+ }
+ return false;
+}
+ /*}}}*/
// ProblemResolver::pkgProblemResolver - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */