[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#542705: python-apt: Forced use of the private depcache to resolve complex situations



On Wed, Aug 19, 2009 at 05:00:12PM +0200, Sebastian Heinlein wrote:
> Package: python-apt
> Version: 0.7.12.1
> Severity: normal
> 
> In PackageKit apt backend I use the problem resolver directly e.g. to make sure
> that all given packages are installed which are queued for a transaction.
> 
> Just calling apt.Packagek.mark_install for each package could unmark the 
> installation of a previous package during the resolver call (autoFix=True).
> So I have to protect all the to be installed packages in the resolver.
> 
> The factory apt_pkg.GetPkgProblemResolver requires the private _depcache of
> an apt.Cache. Furthermore I need the IsInstBroken and IsNowBroken method for
> a more detailed error reporting.
> 
> It would be nice to habe a stable API for this.
See the attached patch. This should probably do what you want.
-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
=== modified file 'apt/__init__.py'
--- apt/__init__.py	2009-04-01 14:27:15 +0000
+++ apt/__init__.py	2009-08-20 22:20:41 +0000
@@ -23,7 +23,7 @@ import os
 
 # import some fancy classes
 from apt.package import Package
-from apt.cache import Cache
+from apt.cache import Cache, ProblemResolver
 from apt.progress import (
     OpProgress, FetchProgress, InstallProgress, CdromProgress)
 from apt.cdrom import Cdrom

=== modified file 'apt/cache.py'
--- apt/cache.py	2009-07-30 13:00:44 +0000
+++ apt/cache.py	2009-08-20 22:20:24 +0000
@@ -363,6 +363,30 @@ class Cache(object):
         return self._depcache.keep_count
 
 
+class ProblemResolver(object):
+
+    def __init__(self, cache):
+        self._resolver = apt_pkg.GetPkgProblemResolver(cache._depcache)
+
+    def clear(self, package):
+        self._resolver.Clear(package._pkg)
+
+    def install_protect(self):
+        self._resolver.InstallProtect()
+
+    def protect(self, package):
+        self._resolver.Protect(package._pkg)
+        
+    def remove(self, package):
+        self._resolver.Remove(package._pkg)
+
+    def resolve(self):
+        self._resolver.Resolve()
+        
+    def resolve_by_keep(self):
+        self._resolver.ResolveByKeep()
+
+
 # ----------------------------- experimental interface
 
 

=== modified file 'apt/package.py'
--- apt/package.py	2009-08-20 21:14:19 +0000
+++ apt/package.py	2009-08-20 22:21:29 +0000
@@ -1008,6 +1008,14 @@ class Package(object):
         """
         return VersionList(self)
 
+    @property
+    def is_inst_broken(self):
+        return self._pcache._depcache.IsInstBroken(self._pkg)
+
+    @property
+    def is_now_broken(self):
+        return self._pcache._depcache.IsNowBroken(self._pkg)
+
     # depcache actions
 
     def markKeep(self):



Attachment: pgpbyDT2IewW7.pgp
Description: PGP signature


Reply to: