summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-06-29 11:23:31 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-06-29 11:23:31 +0200
commit508f1ddb5b6a0cc69655e39dbd59fe3466173a84 (patch)
tree0c8688b9adbea946ca41757e0c446d8374e06657 /apt/cache.py
parentcdaebccd5f7a5a0e23a9be7989b64850fabafed1 (diff)
downloadpython-apt-508f1ddb5b6a0cc69655e39dbd59fe3466173a84.tar.gz
* apt/cache.py:
- add new "dpkg_journal_dirty" property that can be used to detect a interrupted dpkg (the famous "E: dpkg was interrupted, you must manually run 'dpkg --configure -a'")
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 3679e4ba..3962bb4f 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -19,6 +19,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
+import fnmatch
import os
import weakref
@@ -455,6 +456,20 @@ class Cache(object):
return apt_pkg.ActionGroup(self._depcache)
@property
+ def dpkg_journal_dirty(self):
+ """Return True if the dpkg was interrupted
+
+ All dpkg operations will fail until this is fixed, the action to
+ fix the system if dpkg got interrupted is to run
+ 'dpkg --configure -a' as root.
+ """
+ dpkg_status_dir = os.path.dirname(apt_pkg.Config.find_file("Dir::State::status"))
+ for f in os.listdir(os.path.join(dpkg_status_dir, "updates")):
+ if fnmatch.fnmatch(f, "[0-9]*"):
+ return True
+ return False
+
+ @property
def broken_count(self):
"""Return the number of packages with broken dependencies."""
return self._depcache.broken_count