index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | archinstall/lib/installer.py | 7 | ||||
-rw-r--r-- | archinstall/lib/plugins.py | 24 |
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 0044532f..dff05b0a 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -3,6 +3,7 @@ from .hardware import * from .locale_helpers import verify_keyboard_layout, verify_x11_keyboard_layout from .mirrors import * from .storage import storage +from .plugins import plugins from .user_interaction import * # Any package that the Installer() is responsible for (optional and the default ones) @@ -132,6 +133,12 @@ class Installer: def pacstrap(self, *packages, **kwargs): if type(packages[0]) in (list, tuple): packages = packages[0] + + for plugin in plugins.values(): + if hasattr(plugin, 'on_pacstrap'): + if (result := plugin.on_pacstrap(packages)): + packages = result + self.log(f'Installing packages: {packages}', level=logging.INFO) if (sync_mirrors := SysCommand('/usr/bin/pacman -Syy')).exit_code == 0: diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py new file mode 100644 index 00000000..f7f8bc4e --- /dev/null +++ b/archinstall/lib/plugins.py @@ -0,0 +1,24 @@ +import pkgutil +import importlib +import imp # Deprecated +from .storage import storage + +plugins = {} +PLUGIN_PREFIXES = 'archinstall-' + +if (plugin_list := storage.get('plugins', None)): + if type(plugin_list) == str and plugin_list != '*': + plugin_list = plugin_list.split(',') + + for module_info in pkgutil.iter_modules(path=None, prefix=''): + if not module_info.ispkg: + continue + + # If --plugins=* and <iterator:plugin> == 'archinstall-' + # of --plugins=name is <iterator:plugin> + if (plugin_list == '*' and PLUGIN_PREFIXES in module_info.name) or (module_info.name in plugin_list): + try: + modulesource = importlib.import_module(module_info.name) + imp.reload(modulesource) + except Exception as e: + print('Could not load plugin {} {}'.format(modname, e))
\ No newline at end of file |