mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
setup: Abstraction for getting managing packages of a module
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
2df02b059c
commit
d042026314
@ -184,7 +184,7 @@ class Helper(object):
|
|||||||
if num_files < 2: # not counting the lock file
|
if num_files < 2: # not counting the lock file
|
||||||
return None
|
return None
|
||||||
cache = apt.Cache()
|
cache = apt.Cache()
|
||||||
managed_pkgs = getattr(self.module, 'managed_packages', [])
|
managed_pkgs = _get_module_managed_packages(self.module)
|
||||||
unavailable_pkgs = (pkg_name for pkg_name in managed_pkgs
|
unavailable_pkgs = (pkg_name for pkg_name in managed_pkgs
|
||||||
if pkg_name not in cache)
|
if pkg_name not in cache)
|
||||||
return any(unavailable_pkgs)
|
return any(unavailable_pkgs)
|
||||||
@ -227,7 +227,7 @@ def list_dependencies(module_list=None, essential=False):
|
|||||||
'*' not in module_list:
|
'*' not in module_list:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for package_name in getattr(module, 'managed_packages', []):
|
for package_name in _get_module_managed_packages(module):
|
||||||
print(package_name)
|
print(package_name)
|
||||||
|
|
||||||
|
|
||||||
@ -304,6 +304,11 @@ def _is_module_essential(module):
|
|||||||
return getattr(module, 'is_essential', False)
|
return getattr(module, 'is_essential', False)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_module_managed_packages(module):
|
||||||
|
"""Return list of packages managed by a module."""
|
||||||
|
return getattr(module, 'managed_packages', [])
|
||||||
|
|
||||||
|
|
||||||
def _module_state_matches(module, state):
|
def _module_state_matches(module, state):
|
||||||
"""Return if the current setup state of a module matches given state."""
|
"""Return if the current setup state of a module matches given state."""
|
||||||
return module.setup_helper.get_state() == state
|
return module.setup_helper.get_state() == state
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user