diff options
author | Timur Batyrshin <erthad@gmail.com> | 2013-11-11 13:32:01 +0100 |
---|---|---|
committer | Timur Batyrshin <erthad@gmail.com> | 2013-11-11 13:56:05 +0100 |
commit | 9e7623e9deadd00c8f8d21a82571f1b009a5e64b (patch) | |
tree | e17654269bbebba4073ccca28dc8683862fe473b /library | |
parent | Update README.md (diff) | |
download | ansible-9e7623e9deadd00c8f8d21a82571f1b009a5e64b.tar.xz ansible-9e7623e9deadd00c8f8d21a82571f1b009a5e64b.zip |
#4869 compatibility with older versions of apt
Diffstat (limited to 'library')
-rw-r--r-- | library/packaging/apt | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/library/packaging/apt b/library/packaging/apt index 0ef16c81cd..e0ceb53fdf 100644 --- a/library/packaging/apt +++ b/library/packaging/apt @@ -177,20 +177,29 @@ def package_status(m, pkgname, version, cache, state): except AttributeError: has_files = False # older python-apt cannot be used to determine non-purged + try: + package_is_installed = ll_pkg.current_state == apt_pkg.CURSTATE_INSTALLED + except AttributeError: # python-apt 0.7.X has very weak low-level object + try: + # might not be necessary as python-apt post-0.7.X should have current_state property + package_is_installed = pkg.is_installed + except AttributeError: + # assume older version of python-apt is installed + package_is_installed = pkg.isInstalled + if version: - try : - return ll_pkg.current_state == apt_pkg.CURSTATE_INSTALLED and \ - fnmatch.fnmatch(pkg.installed.version, version), False, has_files + try: + installed_version = pkg.installed.version except AttributeError: - #assume older version of python-apt is installed - return ll_pkg.current_state == apt_pkg.CURSTATE_INSTALLED and \ - fnmatch.fnmatch(pkg.installedVersion, version), False, has_files + installed_version = pkg.installedVersion + return package_is_installed and fnmatch.fnmatch(installed_version, version), False, has_files else: - try : - return ll_pkg.current_state == apt_pkg.CURSTATE_INSTALLED, pkg.is_upgradable, has_files + try: + package_is_upgradable = pkg.is_upgradable except AttributeError: - #assume older version of python-apt is installed - return ll_pkg.current_state == apt_pkg.CURSTATE_INSTALLED, pkg.isUpgradable, has_files + # assume older version of python-apt is installed + package_is_upgradable = pkg.isUpgradable + return package_is_installed, package_is_upgradable, has_files def expand_dpkg_options(dpkg_options_compressed): options_list = dpkg_options_compressed.split(',') |