Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #567 from FabioBatSilva/devel
Browse files Browse the repository at this point in the history
handle list of lists - python-apt < 0.7.9 compatibility
  • Loading branch information
abadger committed Dec 30, 2014
2 parents f9574cc + 9ed842e commit 0d551d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packaging/os/apt.py
Expand Up @@ -144,6 +144,7 @@
import os
import datetime
import fnmatch
import itertools

# APT related constants
APT_ENV_VARS = dict(
Expand Down Expand Up @@ -181,7 +182,7 @@ def package_versions(pkgname, pkg, pkg_cache):
# apt.package.Package#versions require python-apt >= 0.7.9.
pkg_cache_list = (p for p in pkg_cache.Packages if p.Name == pkgname)
pkg_versions = (p.VersionList for p in pkg_cache_list)
versions = set(p.VerStr for p in pkg_versions)
versions = set(p.VerStr for p in itertools.chain(*pkg_versions))

return versions

Expand All @@ -201,9 +202,14 @@ def package_status(m, pkgname, version, cache, state):
ll_pkg = cache._cache[pkgname] # the low-level package object
except KeyError:
if state == 'install':
if cache.get_providing_packages(pkgname):
try:
if cache.get_providing_packages(pkgname):
return False, True, False
m.fail_json(msg="No package matching '%s' is available" % pkgname)
except AttributeError:
# python-apt version too old to detect virtual packages
# mark as upgradable and let apt-get install deal with it
return False, True, False
m.fail_json(msg="No package matching '%s' is available" % pkgname)
else:
return False, False, False
try:
Expand Down

0 comments on commit 0d551d8

Please sign in to comment.