summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2012-04-18 13:10:16 -0300
committerDaniel Nicoletti <dantti12@gmail.com>2012-04-18 13:20:51 -0300
commitefdab8f65f65b90b38e8143f7b25fc0d60adf3c7 (patch)
tree7e7f55ca6ab34fad7c885a0bfa1a0563bf949b86
parentae7ec444b041bfc81cc97d8aa522c99a91d443e9 (diff)
aptcc: Emit UnfinishedTransaction when we were not able to fix the cache
-rw-r--r--backends/aptcc/AptCacheFile.cpp18
-rw-r--r--backends/aptcc/AptCacheFile.h2
-rw-r--r--backends/aptcc/apt-intf.cpp14
3 files changed, 15 insertions, 19 deletions
diff --git a/backends/aptcc/AptCacheFile.cpp b/backends/aptcc/AptCacheFile.cpp
index a6d05c0f..f3548030 100644
--- a/backends/aptcc/AptCacheFile.cpp
+++ b/backends/aptcc/AptCacheFile.cpp
@@ -69,19 +69,7 @@ bool AptCacheFile::CheckDeps(bool FixBroken)
// Apply corrections for half-installed packages
if (pkgApplyStatus(*DCache) == false) {
- return false;
- }
-
- if (_config->FindB("APT::Get::Fix-Policy-Broken",false) == true) {
- FixBroken = true;
- if ((DCache->PolicyBrokenCount() > 0)) {
- // upgrade all policy-broken packages with ForceImportantDeps=True
- for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); ++I) {
- if ((*DCache)[I].NowPolicyBroken() == true) {
- DCache->MarkInstall(I,true,0, false, true);
- }
- }
- }
+ return _error->Error("Unable to apply corrections for half-installed packages");;
}
// Nothing is broken or we don't want to try fixing it
@@ -104,7 +92,7 @@ bool AptCacheFile::CheckDeps(bool FixBroken)
return true;
}
-void AptCacheFile::ShowBroken(bool Now)
+void AptCacheFile::ShowBroken(bool Now, PkErrorEnum error)
{
std::stringstream out;
@@ -231,7 +219,7 @@ void AptCacheFile::ShowBroken(bool Now)
}
}
}
- pk_backend_error_code(m_backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, out.str().c_str());
+ pk_backend_error_code(m_backend, error, out.str().c_str());
}
void AptCacheFile::buildPkgRecords()
diff --git a/backends/aptcc/AptCacheFile.h b/backends/aptcc/AptCacheFile.h
index 577c7401..49a5e31e 100644
--- a/backends/aptcc/AptCacheFile.h
+++ b/backends/aptcc/AptCacheFile.h
@@ -57,7 +57,7 @@ public:
* dependencies. Similar to and based on the equivalent routine in
* apt-get.
*/
- void ShowBroken(bool Now);
+ void ShowBroken(bool Now, PkErrorEnum error = PK_ERROR_ENUM_DEP_RESOLUTION_FAILED);
inline pkgRecords* GetPkgRecords() { buildPkgRecords(); return m_packageRecords; }
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index e31ccb28..87ff230b 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -2296,7 +2296,7 @@ bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, b
AptCacheFile cache(m_backend);
int timeout = 10;
// TODO test this
- while (cache.Open(withLock) == false || cache.CheckDeps(fixBroken) == false) {
+ while (cache.Open(withLock) == false) {
if (withLock == false || (timeout <= 0)) {
show_errors(m_backend, PK_ERROR_ENUM_CANNOT_GET_LOCK);
return false;
@@ -2309,6 +2309,13 @@ bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, b
// Close the cache if we are going to try again
cache.Close();
}
+
+ // Check if there are half-installed packages and if we can fix them
+ if (cache.CheckDeps(fixBroken) == false) {
+ show_errors(m_backend, PK_ERROR_ENUM_INTERNAL_ERROR);
+ return false;
+ }
+
pk_backend_set_status (m_backend, PK_STATUS_ENUM_RUNNING);
// Enter the special broken fixing mode if the user specified arguments
@@ -2367,8 +2374,9 @@ bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, b
// Now we check the state of the packages,
if (cache->BrokenCount() != 0) {
// if the problem resolver could not fix all broken things
- // show what is broken
- cache.ShowBroken(false);
+ // suggest to run RepairSystem by saing that the last transaction
+ // did not finish well
+ cache.ShowBroken(false, PK_ERROR_ENUM_UNFINISHED_TRANSACTION);
return false;
}
}