setup: List dependencies for apps instead of modules

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2021-11-24 12:00:04 -08:00 committed by James Valleroy
parent a0a6e1d362
commit 7eab8a2cda
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 11 additions and 14 deletions

View File

@ -55,12 +55,12 @@ def run_setup_and_exit(app_ids, allow_install=True):
sys.exit(error_code)
def list_dependencies(module_list):
"""List dependencies for all essential modules and exit."""
def list_dependencies(app_ids):
"""List dependencies for all essential apps and exit."""
error_code = 0
try:
if module_list:
setup.list_dependencies(module_list=module_list)
if app_ids:
setup.list_dependencies(app_ids=app_ids)
else:
setup.list_dependencies(essential=True)
except Exception as exception:

View File

@ -3,7 +3,6 @@
Utilities for performing application setup operations.
"""
import importlib
import logging
import sys
import threading
@ -156,19 +155,17 @@ def setup_apps(app_ids=None, essential=False, allow_install=True):
module.setup_helper.run(allow_install=allow_install)
def list_dependencies(module_list=None, essential=False):
"""Print list of packages required by selected or essential modules."""
for module_import_path in plinth.module_loader.get_modules_to_load():
module_name = module_import_path.split('.')[-1]
module = importlib.import_module(module_import_path)
if essential and not module.app.info.is_essential:
def list_dependencies(app_ids=None, essential=False):
"""Print list of packages required by selected or essential apps."""
for app in app_module.App.list():
if essential and not app.info.is_essential:
continue
if module_list and module_name not in module_list and \
'*' not in module_list:
if app_ids and app.app_id not in app_ids and \
'*' not in app_ids:
continue
for component in module.app.get_components_of_type(Packages):
for component in app.get_components_of_type(Packages):
for package_name in component.packages:
print(package_name)