mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
actions: Get list of packages from Packages components
Instead of getting it from managed_packages module level variable. This is made possible by the ability to instantiate an app without being able to instantiate all apps at once and without even initializing Django. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
d1b040cdb6
commit
cea023f7b2
@ -5,6 +5,7 @@ Wrapper to handle package installation with apt-get.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import inspect
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -17,9 +18,11 @@ import apt.cache
|
|||||||
import apt_inst
|
import apt_inst
|
||||||
import apt_pkg
|
import apt_pkg
|
||||||
|
|
||||||
|
from plinth import app as app_module
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
from plinth.action_utils import (apt_hold_freedombox, is_package_manager_busy,
|
from plinth.action_utils import (apt_hold_freedombox, is_package_manager_busy,
|
||||||
run_apt_command)
|
run_apt_command)
|
||||||
|
from plinth.package import Packages
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -119,8 +122,19 @@ def _assert_managed_packages(module, packages):
|
|||||||
module_path = file_handle.read().strip()
|
module_path = file_handle.read().strip()
|
||||||
|
|
||||||
module = import_module(module_path)
|
module = import_module(module_path)
|
||||||
|
module_classes = inspect.getmembers(module, inspect.isclass)
|
||||||
|
app_classes = [
|
||||||
|
cls[1] for cls in module_classes if issubclass(cls[1], app_module.App)
|
||||||
|
]
|
||||||
|
managed_packages = []
|
||||||
|
for cls in app_classes:
|
||||||
|
app = cls()
|
||||||
|
components = app.get_components_of_type(Packages)
|
||||||
|
for component in components:
|
||||||
|
managed_packages += component.packages
|
||||||
|
|
||||||
for package in packages:
|
for package in packages:
|
||||||
assert package in module.managed_packages
|
assert package in managed_packages
|
||||||
|
|
||||||
|
|
||||||
def subcommand_is_package_manager_busy(_):
|
def subcommand_is_package_manager_busy(_):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user