From 508f1ddb5b6a0cc69655e39dbd59fe3466173a84 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 29 Jun 2010 11:23:31 +0200 Subject: * 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'") --- apt/cache.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'apt') 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 @@ -454,6 +455,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.""" -- cgit v1.2.3