setup: disable install button for currently unavailable apps

- Fixes #1229.

Signed-off-by: Johannes Keyser <johanneskeyser@posteo.de>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Johannes Keyser authored and James Valleroy committed 2018-04-20 20:12:46 -04:00
1 parent d5797395cf
commit 3a9c4128ff
2 files changed
+19

No files matched your search

+10
View File
@@ -143,6 +143,8 @@ class Helper(object):
return 'up-to-date'
if not current_version:
if any(self.list_unavailable_packages()):
return 'unavailable'
return 'needs-setup'
else:
return 'needs-update'
@@ -166,6 +168,14 @@ class Helper(object):
'setup_version': version
})
def list_unavailable_packages(self):
"""List the unavailable packages managed by the module (if any)."""
cache = apt.Cache()
managed_pkgs = getattr(self.module, 'managed_packages', [])
unavailable_pkgs = [pkg_name for pkg_name in managed_pkgs
if pkg_name not in cache]
return unavailable_pkgs
def init(module_name, module):
"""Create a setup helper for a module for later use."""