diff options
| -rw-r--r-- | apt/__init__.py | 2 | ||||
| -rw-r--r-- | apt/cache.py | 40 | ||||
| -rw-r--r-- | apt/package.py | 36 | ||||
| -rw-r--r-- | debian/changelog | 38 | ||||
| -rw-r--r-- | debian/control | 2 | ||||
| -rwxr-xr-x | debian/rules | 2 | ||||
| -rw-r--r-- | doc/source/library/apt.cache.rst | 5 | ||||
| -rw-r--r-- | doc/source/library/apt_pkg.rst | 5 | ||||
| -rw-r--r-- | python/cache.cc | 5 | ||||
| -rw-r--r-- | python/pkgsrcrecords.cc | 2 |
10 files changed, 122 insertions, 15 deletions
diff --git a/apt/__init__.py b/apt/__init__.py index a75218a8..677a625b 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -22,7 +22,7 @@ import apt_pkg # import some fancy classes from apt.package import Package -from apt.cache import Cache +from apt.cache import Cache, ProblemResolver from apt.cdrom import Cdrom if apt_pkg._COMPAT_0_7: diff --git a/apt/cache.py b/apt/cache.py index ae4254e0..eff07ef8 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -278,7 +278,7 @@ class Cache(object): return providers @deprecated_args - def update(self, fetch_progress=None): + def update(self, fetch_progress=None, pulse_interval=0): """Run the equivalent of apt-get update. The first parameter *fetch_progress* may be set to an instance of @@ -287,13 +287,15 @@ class Cache(object): """ lockfile = apt_pkg.config.find_dir("Dir::State::Lists") + "lock" lock = apt_pkg.get_lock(lockfile) + if lock < 0: raise LockFailedException("Failed to lock %s" % lockfile) try: if fetch_progress is None: fetch_progress = apt.progress.FetchProgress() - return self._cache.update(fetch_progress, self._list) + return self._cache.update(fetch_progress, self._list, + pulse_interval) finally: os.close(lock) @@ -434,6 +436,40 @@ class Cache(object): cachePreChange = function_deprecated_by(cache_pre_change) +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.ProblemResolver(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.install_protect() + + 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.resolve_by_keep() + + # ----------------------------- experimental interface diff --git a/apt/package.py b/apt/package.py index 50b57760..8c9770e9 100644 --- a/apt/package.py +++ b/apt/package.py @@ -66,14 +66,16 @@ class BaseDependency(object): name - The name of the dependency relation - The relation (>,>=,==,<,<=,) version - The version depended on + rawtype - The type of the dependendy (e.g. 'Recommends') pre_depend - Boolean value whether this is a pre-dependency. """ - def __init__(self, name, rel, ver, pre): + def __init__(self, name, rel, ver, pre, rawtype=None): self.name = name self.relation = rel self.version = ver self.pre_depend = pre + self.rawtype = rawtype def __repr__(self): return ('<BaseDependency: name:%r relation:%r version:%r preDepend:%r>' @@ -377,9 +379,8 @@ class Version(object): """Return a Record() object for this version.""" return Record(self._records.record) - @property - def dependencies(self): - """Return the dependencies of the package version.""" + def get_dependencies(self, *types): + """Return a list of Dependency objects for the given types.""" depends_list = [] depends = self._cand.depends_list for type_ in ["PreDepends", "Depends"]: @@ -389,13 +390,24 @@ class Version(object): for dep_or in dep_ver_list: base_deps.append(BaseDependency(dep_or.target_pkg.name, dep_or.comp_type, dep_or.target_ver, - (type_ == "PreDepends"))) + (type_ == "PreDepends"), + rawtype=type_)) depends_list.append(Dependency(base_deps)) except KeyError: pass return depends_list @property + def dependencies(self): + """Return the dependencies of the package version.""" + return self.get_dependencies("PreDepends", "Depends") + + @property + def recommends(self): + """Return the recommends of the package version.""" + return self.get_dependencies("Recommends") + + @property def origins(self): """Return a list of origins for the package version.""" origins = [] @@ -1100,6 +1112,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 mark_keep(self): @@ -1158,7 +1180,8 @@ class Package(object): def mark_upgrade(self): """Mark a package for upgrade.""" if self.is_upgradable: - self.mark_install() + from_user = not self._pcache._depcache.is_auto_installed(self._pkg) + self.mark_install(from_user=from_user) else: # FIXME: we may want to throw a exception here sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: " @@ -1250,6 +1273,7 @@ def _test(): print "InstalledSize: %s " % pkg.candidate.installed_size print "PackageSize: %s " % pkg.candidate.size print "Dependencies: %s" % pkg.installed.dependencies + print "Recommends: %s" % pkg.installed.recommends for dep in pkg.candidate.dependencies: print ",".join("%s (%s) (%s) (%s)" % (o.name, o.version, o.relation, o.pre_depend) for o in dep.or_dependencies) diff --git a/debian/changelog b/debian/changelog index 08035874..276c24ef 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-apt (0.7.93) experimental; urgency=low + + * Merge 0.7.13.0 from unstable. + + -- Julian Andres Klode <jak@debian.org> Fri, 21 Aug 2009 16:50:54 +0200 + python-apt (0.7.92) experimental; urgency=low * New features: @@ -78,6 +84,38 @@ python-apt (0.7.90) experimental; urgency=low -- Julian Andres Klode <jak@debian.org> Wed, 15 Apr 2009 13:47:42 +0200 +python-apt (0.7.13.0) unstable; urgency=low + + [ Michael Vogt ] + * apt/package.py: + - add "recommends" property + * apt/cache.py, python/cache.cc: + - add optional pulseInterval option to "update()" + + [ 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 + 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) + * python/pkgsrcrecords.cc: + - Fix spelling error (begining should be beginning). + * po: + - Update template and the translations de.po, fr.po (Closes: #467120), + ja.po (Closes: #454293). + * debian/control: + - Update Standards-Version to 3.8.3. + * debian/rules: + - Build with DH_PYCENTRAL=include-links instead of nomove. + + -- Julian Andres Klode <jak@debian.org> Fri, 21 Aug 2009 16:22:34 +0200 + python-apt (0.7.12.1) unstable; urgency=low * apt/debfile.py: diff --git a/debian/control b/debian/control index cc5d1e56..c5508e9b 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: python Priority: optional Maintainer: APT Development Team <deity@lists.debian.org> Uploaders: Michael Vogt <mvo@debian.org>, Julian Andres Klode <jak@debian.org> -Standards-Version: 3.8.2 +Standards-Version: 3.8.3 XS-Python-Version: 2.5, 2.6, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), diff --git a/debian/rules b/debian/rules index d5ebe29d..6c9f6fb6 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,5 @@ #!/usr/bin/make -f -export DH_PYCENTRAL=nomove +export DH_PYCENTRAL=include-links export DEBVER=$(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') export CFLAGS=-Wno-write-strings -DCOMPAT_0_7 diff --git a/doc/source/library/apt.cache.rst b/doc/source/library/apt.cache.rst index ddb2dc64..d0e44598 100644 --- a/doc/source/library/apt.cache.rst +++ b/doc/source/library/apt.cache.rst @@ -70,6 +70,11 @@ packages whose state has been changed, eg. packages marked for installation:: >>> print len(changed) == len(cache.get_changes()) # Both need to have same length True +The ProblemResolver class +-------------------------- + +.. autoclass:: ProblemResolver + :members: Exceptions ---------- diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst index ee0c33ef..720b61a3 100644 --- a/doc/source/library/apt_pkg.rst +++ b/doc/source/library/apt_pkg.rst @@ -41,13 +41,16 @@ Working with the cache Return the :class:`Package()` object for the package name given by *pkgname*. - .. method:: update(progress, list) + .. method:: update(progress, list[, pulse_interval]) Update the package cache. The parameter *progress* points to an :class:`apt.progress.FetchProgress()` object. The parameter *list* refers to a :class:`SourceList()` object. + The optional parameter *pulse_interval* describes the interval between + the calls to the :meth:`FetchProgress.pulse` method. + .. attribute:: depends_count The total number of dependencies. diff --git a/python/cache.cc b/python/cache.cc index 593bc1c2..084f6d8c 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -78,13 +78,14 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) { PyObject *pyFetchProgressInst = 0; PyObject *pySourcesList = 0; - if (PyArg_ParseTuple(Args, "OO", &pyFetchProgressInst,&pySourcesList) == 0) + int pulseInterval = 0; + if (PyArg_ParseTuple(Args, "OO|i", &pyFetchProgressInst,&pySourcesList, &pulseInterval) == 0) return 0; PyFetchProgress progress; progress.setCallbackInst(pyFetchProgressInst); pkgSourceList *source = GetCpp<pkgSourceList*>(pySourcesList); - bool res = ListUpdate(progress, *source); + bool res = ListUpdate(progress, *source, pulseInterval); PyObject *PyRes = Py_BuildValue("b", res); return HandleErrors(PyRes); diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index fbc9a293..086ec8d5 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -53,7 +53,7 @@ static PyObject *PkgSrcRecordsLookup(PyObject *Self,PyObject *Args) return Py_BuildValue("i", 1); } -static char *doc_PkgSrcRecordsRestart = "Start Lookup from the begining"; +static char *doc_PkgSrcRecordsRestart = "Start Lookup from the beginning"; static PyObject *PkgSrcRecordsRestart(PyObject *Self,PyObject *Args) { PkgSrcRecordsStruct &Struct = GetCpp<PkgSrcRecordsStruct>(Self); |
