summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2012-04-19 21:59:53 -0300
committerDaniel Nicoletti <dantti12@gmail.com>2012-04-19 21:59:53 -0300
commiteda735a08ac4e406b25bde278438382b2b92245f (patch)
treecd02ce5a39ebbd089db33ebd1034de0dda0d870c
parente5c505f909ebabd0744bf82cd1cf637f5eb6510d (diff)
aptcc: separate the try install/remove functions
-rw-r--r--backends/aptcc/apt-intf.cpp64
-rw-r--r--backends/aptcc/apt-intf.h6
2 files changed, 33 insertions, 37 deletions
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 2ed68655..2217a69e 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -1429,33 +1429,42 @@ bool AptIntf::checkTrusted(pkgAcquire &fetcher, bool simulating)
return false;
}
-bool AptIntf::tryToInstall(const pkgCache::PkgIterator &constPkg,
+void AptIntf::tryToRemove(const pkgCache::VerIterator &ver,
+ pkgDepCache &Cache,
+ pkgProblemResolver &Fix)
+{
+ pkgCache::PkgIterator Pkg = ver.ParentPkg();
+
+ // The package is not installed
+ if (Pkg->CurrentVer == 0) {
+ Fix.Clear(Pkg);
+ Fix.Protect(Pkg);
+ Fix.Remove(Pkg);
+
+ return;
+ }
+
+ Fix.Clear(Pkg);
+ Fix.Protect(Pkg);
+ Fix.Remove(Pkg);
+ // TODO this is false since PackageKit can't
+ // tell it want's o purge
+ Cache.MarkDelete(Pkg, false);
+}
+
+
+bool AptIntf::tryToInstall(const pkgCache::VerIterator &ver,
pkgDepCache &Cache,
pkgProblemResolver &Fix,
- bool Remove,
bool BrokenFix,
unsigned int &ExpectedInst)
{
- pkgCache::PkgIterator Pkg = constPkg;
- // This is a pure virtual package and there is a single available provides
- if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0 &&
- Pkg.ProvidesList()->NextProvides == 0) {
- pkgCache::PkgIterator Tmp = Pkg.ProvidesList().OwnerPkg();
- // TODO this is UGLY!!! create a local PkgIterator for this
- Pkg = Tmp;
- }
+ pkgCache::PkgIterator Pkg = ver.ParentPkg();
// Check if there is something at all to install
pkgDepCache::StateCache &State = Cache[Pkg];
- if (Remove == true && Pkg->CurrentVer == 0) {
- Fix.Clear(Pkg);
- Fix.Protect(Pkg);
- Fix.Remove(Pkg);
-
- return true;
- }
- if (State.CandidateVer == 0 && Remove == false) {
+ if (State.CandidateVer == 0) {
_error->Error("Package %s is virtual and has no installation candidate", Pkg.Name());
pk_backend_error_code(m_backend,
@@ -1468,13 +1477,6 @@ bool AptIntf::tryToInstall(const pkgCache::PkgIterator &constPkg,
Fix.Clear(Pkg);
Fix.Protect(Pkg);
- if (Remove == true) {
- Fix.Remove(Pkg);
- // TODO this is false since PackageKit can't
- // tell it want's o purge
- Cache.MarkDelete(Pkg, false);
- return true;
- }
// Install it
Cache.MarkInstall(Pkg, false);
@@ -2309,10 +2311,9 @@ bool AptIntf::runTransaction(const PkgList &install, const PkgList &remove, bool
break;
}
- if (tryToInstall(it->ParentPkg(),
+ if (tryToInstall(*it,
cache,
Fix,
- false, // remove
BrokenFix,
ExpectedInst) == false) {
return false;
@@ -2329,14 +2330,7 @@ bool AptIntf::runTransaction(const PkgList &install, const PkgList &remove, bool
break;
}
- if (tryToInstall(it->ParentPkg(),
- cache,
- Fix,
- true, // remove
- BrokenFix,
- ExpectedInst) == false) {
- return false;
- }
+ tryToRemove(*it, cache, Fix);
}
// Call the scored problem resolver
diff --git a/backends/aptcc/apt-intf.h b/backends/aptcc/apt-intf.h
index 8c648516..bbebbfd4 100644
--- a/backends/aptcc/apt-intf.h
+++ b/backends/aptcc/apt-intf.h
@@ -233,10 +233,12 @@ public:
private:
bool checkTrusted(pkgAcquire &fetcher, bool simulating);
bool packageIsSupported(const pkgCache::VerIterator &verIter, string component);
- bool tryToInstall(const pkgCache::PkgIterator &constPkg,
+ void tryToRemove(const pkgCache::VerIterator &ver,
+ pkgDepCache &Cache,
+ pkgProblemResolver &Fix);
+ bool tryToInstall(const pkgCache::VerIterator &ver,
pkgDepCache &Cache,
pkgProblemResolver &Fix,
- bool Remove,
bool BrokenFix,
unsigned int &ExpectedInst);