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) sys.exit(error_code)
def list_dependencies(module_list): def list_dependencies(app_ids):
"""List dependencies for all essential modules and exit.""" """List dependencies for all essential apps and exit."""
error_code = 0 error_code = 0
try: try:
if module_list: if app_ids:
setup.list_dependencies(module_list=module_list) setup.list_dependencies(app_ids=app_ids)
else: else:
setup.list_dependencies(essential=True) setup.list_dependencies(essential=True)
except Exception as exception: except Exception as exception:

View File

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