Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/installer.py7
-rw-r--r--archinstall/lib/plugins.py24
2 files changed, 31 insertions, 0 deletions
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