Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/lib/profiles.py15
-rw-r--r--examples/guided.py14
-rw-r--r--profiles/i3-gaps.py10
-rw-r--r--profiles/i3-wm.py9
4 files changed, 42 insertions, 6 deletions
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index 08b1d618..77c9c6b2 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -177,6 +177,21 @@ class Profile(Script):
if hasattr(imported, '_prep_function'):
return True
return False
+ def has_post_install(self):
+ with open(self.path, 'r') as source:
+ source_data = source.read()
+
+ # Some crude safety checks, make sure the imported profile has
+ # a __name__ check and if so, check if it's got a _prep_function()
+ # we can call to ask for more user input.
+ #
+ # If the requirements are met, import with .py in the namespace to not
+ # trigger a traditional:
+ # if __name__ == 'moduleName'
+ if '__name__' in source_data and '_post_install' in source_data:
+ with self.load_instructions(namespace=f"{self.namespace}.py") as imported:
+ if hasattr(imported, '_post_install'):
+ return True
class Application(Profile):
def __repr__(self, *args, **kwargs):
diff --git a/examples/guided.py b/examples/guided.py
index 032a1f39..3f11b7a8 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,4 +1,4 @@
-import getpass, time, json, sys, signal, os, subprocess
+import getpass, time, json, sys, signal, os
import archinstall
from archinstall.lib.hardware import hasUEFI
@@ -344,9 +344,15 @@ def perform_installation(device, boot_partition, language, mirrors):
if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw):
installation.user_set_pw('root', root_pw)
- if archinstall.arguments.get('profile', None) == "i3-wm" or archinstall.arguments.get('profile', None) == "i3-gaps":
- print("the installation of i3/i3-gaps does not conatain any configuerations for the wm. in this shell you should add your configuerations")
- subprocess.check_call("arch-chroot /mnt",shell=True)
+ if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_post_install():
+ with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported:
+ if not imported._post_install():
+ archinstall.log(
+ ' * Profile\'s preparation requirements was not fulfilled.',
+ bg='black',
+ fg='red'
+ )
+ exit(1)
ask_user_questions()
perform_installation_steps()
diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py
index bf8227ba..d9469dcd 100644
--- a/profiles/i3-gaps.py
+++ b/profiles/i3-gaps.py
@@ -1,4 +1,4 @@
-import archinstall
+import archinstall, subprocess
def _prep_function(*args, **kwargs):
"""
@@ -16,6 +16,14 @@ def _prep_function(*args, **kwargs):
else:
print('Deprecated (??): xorg profile has no _prep_function() anymore')
+def _post_install(*args, **kwargs):
+ """
+ Another magic function called after the system
+ has been installed.
+ """
+ print("the installation of i3 does not conatain any configuerations for the wm. in this shell you take your time should add your configuerations")
+ subprocess.check_call("arch-chroot /mnt",shell=True)
+
if __name__ == 'i3-wm':
# Install dependency profiles
installation.install_profile('xorg')
diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py
index 168abb72..8b541bbf 100644
--- a/profiles/i3-wm.py
+++ b/profiles/i3-wm.py
@@ -1,4 +1,4 @@
-import archinstall
+import archinstall, subprocess
def _prep_function(*args, **kwargs):
"""
@@ -15,6 +15,13 @@ def _prep_function(*args, **kwargs):
return imported._prep_function()
else:
print('Deprecated (??): xorg profile has no _prep_function() anymore')
+def _post_install(*args, **kwargs):
+ """
+ Another magic function called after the system
+ has been installed.
+ """
+ print("the installation of i3-gaps does not conatain any configuerations for the wm. in this shell you should take your time to add your configuerations")
+ subprocess.check_call("arch-chroot /mnt",shell=True)
if __name__ == 'i3-wm':
# Install dependency profiles