From c31fb6542e64a7eb279d0b246da4ea15dc4d6af3 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 20 Aug 2009 23:14:19 +0200 Subject: apt/package.py: Do not mark the package as manually installed on upgrade (Closes: #542699) --- apt/package.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt') diff --git a/apt/package.py b/apt/package.py index 7322bb94..e33078d8 100644 --- a/apt/package.py +++ b/apt/package.py @@ -1064,7 +1064,8 @@ class Package(object): def markUpgrade(self): """Mark a package for upgrade.""" if self.isUpgradable: - self.markInstall() + fromUser = not self._pcache._depcache.IsAutoInstalled(self._pkg) + self.markInstall(fromUser=fromUser) else: # FIXME: we may want to throw a exception here sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: " -- cgit v1.2.3 From 200249fc4f0fccd19e12e1abcb718c08df0bf752 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 21 Aug 2009 14:57:44 +0200 Subject: apt/package.py: Add Package.is_now_broken and Package.is_inst_broken. --- apt/package.py | 10 ++++++++++ debian/changelog | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'apt') diff --git a/apt/package.py b/apt/package.py index e33078d8..59fb8cfa 100644 --- a/apt/package.py +++ b/apt/package.py @@ -1008,6 +1008,16 @@ class Package(object): """ return VersionList(self) + @property + def is_inst_broken(self): + """Return True if the to-be-installed package is broken.""" + return self._pcache._depcache.IsInstBroken(self._pkg) + + @property + def is_now_broken(self): + """Return True if the installed package is broken.""" + return self._pcache._depcache.IsNowBroken(self._pkg) + # depcache actions def markKeep(self): diff --git a/debian/changelog b/debian/changelog index 7ab2fda4..d91b90a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,8 +9,9 @@ python-apt (0.7.12.2) UNRELEASED; urgency=low - Introduce Version.get_dependencies() which takes one or more types of dependencies and returns a list of Dependency objects. - Do not mark the package as manually installed on upgrade (Closes: #542699) + - Add Package.is_now_broken and Package.is_inst_broken. - -- Julian Andres Klode Thu, 20 Aug 2009 23:13:00 +0200 + -- Julian Andres Klode Fri, 21 Aug 2009 14:57:08 +0200 python-apt (0.7.12.1) unstable; urgency=low -- cgit v1.2.3 From e2d814ffc20e231a3b8201f7d66145939c99174c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 21 Aug 2009 15:18:33 +0200 Subject: * apt/cache.py: Introduce ProblemResolver class (Closes: #542705) --- apt/__init__.py | 2 +- apt/cache.py | 35 ++++++++++++++++++++++++++++++++++- debian/changelog | 4 +++- doc/source/apt/cache.rst | 5 +++++ doc/source/apt/index.rst | 3 +++ 5 files changed, 46 insertions(+), 3 deletions(-) (limited to 'apt') diff --git a/apt/__init__.py b/apt/__init__.py index ae2abbf2..4b3e6bf2 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -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 diff --git a/apt/cache.py b/apt/cache.py index c1e2428c..33d55368 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -91,7 +91,6 @@ class Cache(object): for f in files: if not os.path.exists(rootdir+f): open(rootdir+f,"w") - def _runCallbacks(self, name): """ internal helper to run a callback """ @@ -363,6 +362,40 @@ class Cache(object): return self._depcache.keep_count +class ProblemResolver(object): + """Resolve problems due to dependencies and conflicts. + + The first argument 'cache' is an instance of apt.Cache. + """ + + def __init__(self, cache): + self._resolver = apt_pkg.GetPkgProblemResolver(cache._depcache) + + def clear(self, package): + """Reset the package to the default state.""" + self._resolver.Clear(package._pkg) + + def install_protect(self): + """mark protected packages for install or removal.""" + self._resolver.InstallProtect() + + def protect(self, package): + """Protect a package so it won't be removed.""" + self._resolver.Protect(package._pkg) + + def remove(self, package): + """Mark a package for removal.""" + self._resolver.Remove(package._pkg) + + def resolve(self): + """Resolve dependencies, try to remove packages where needed.""" + self._resolver.Resolve() + + def resolve_by_keep(self): + """Resolve dependencies, do not try to remove packages.""" + self._resolver.ResolveByKeep() + + # ----------------------------- experimental interface diff --git a/debian/changelog b/debian/changelog index d91b90a5..bf5a6036 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.12.2) UNRELEASED; urgency=low +python-apt (0.7.13.0) UNRELEASED; urgency=low [ Michael Vogt ] * apt/package.py: @@ -10,6 +10,8 @@ python-apt (0.7.12.2) UNRELEASED; urgency=low of dependencies and returns a list of Dependency objects. - Do not mark the package as manually installed on upgrade (Closes: #542699) - Add Package.is_now_broken and Package.is_inst_broken. + * apt/cache.py: + - Introduce ProblemResolver class (Closes: #542705) -- Julian Andres Klode Fri, 21 Aug 2009 14:57:08 +0200 diff --git a/doc/source/apt/cache.rst b/doc/source/apt/cache.rst index d96cba97..beae74a2 100644 --- a/doc/source/apt/cache.rst +++ b/doc/source/apt/cache.rst @@ -70,6 +70,11 @@ packages whose state has been changed, eg. packages marked for installation:: >>> print len(changed) == len(cache.GetChanges()) # Both need to have same length True +The ProblemResolver class +-------------------------- + +.. autoclass:: ProblemResolver + :members: Exceptions ---------- diff --git a/doc/source/apt/index.rst b/doc/source/apt/index.rst index 5047a0fd..bf39354f 100644 --- a/doc/source/apt/index.rst +++ b/doc/source/apt/index.rst @@ -56,3 +56,6 @@ in the package. Please see :class:`apt.package.Package` for documentation. +.. class:: ProblemResolver + + Please see :class:`apt.cache.ProblemResolver` for documentation. -- cgit v1.2.3 From a65009779237610d6be290222aeb69af8b19ad34 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Fri, 21 Aug 2009 15:26:31 +0200 Subject: apt/cache.py: Fix the (inst|keep|broken|del)_count attributes (Closes: #542773). --- apt/cache.py | 8 ++++---- debian/changelog | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'apt') diff --git a/apt/cache.py b/apt/cache.py index 33d55368..bc1d1160 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -344,22 +344,22 @@ class Cache(object): @property def broken_count(self): """Return the number of packages with broken dependencies.""" - return self._depcache.broken_count + return self._depcache.BrokenCount @property def delete_count(self): """Return the number of packages marked for deletion.""" - return self._depcache.del_count + return self._depcache.DelCount @property def install_count(self): """Return the number of packages marked for installation.""" - return self._depcache.inst_count + return self._depcache.InstCount @property def keep_count(self): """Return the number of packages marked as keep.""" - return self._depcache.keep_count + return self._depcache.KeepCount class ProblemResolver(object): diff --git a/debian/changelog b/debian/changelog index bf5a6036..575db1b3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ python-apt (0.7.13.0) UNRELEASED; urgency=low * apt/package.py: - add "recommends" property + [ Sebastian Heinlein ] + * apt/cache.py: + - Fix the (inst|keep|broken|del)_count attributes (Closes: #542773). + [ Julian Andres Klode ] * apt/package.py: - Introduce Version.get_dependencies() which takes one or more types -- cgit v1.2.3 From 353d2494c234d87cb63affd07a927d1030fa9721 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 21 Aug 2009 17:00:03 +0200 Subject: * apt/package.py: Fix Version.get_dependencies() to not ignore the arguments. --- apt/package.py | 2 +- debian/changelog | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'apt') diff --git a/apt/package.py b/apt/package.py index 59fb8cfa..d639f31f 100644 --- a/apt/package.py +++ b/apt/package.py @@ -365,7 +365,7 @@ class Version(object): """Return a list of Dependency objects for the given types.""" depends_list = [] depends = self._cand.DependsList - for t in ["PreDepends", "Depends"]: + for t in types: try: for depVerList in depends[t]: base_deps = [] diff --git a/debian/changelog b/debian/changelog index 95c5c9f3..b75d07b7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.13.1) unstable; urgency=low + + * apt/package.py: + - Fix Version.get_dependencies() to not ignore the arguments. + + -- Julian Andres Klode Fri, 21 Aug 2009 16:59:08 +0200 + python-apt (0.7.13.0) unstable; urgency=low [ Michael Vogt ] -- cgit v1.2.3