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.py15
-rw-r--r--profiles/i3-gaps.py15
-rw-r--r--profiles/i3-wm.py16
4 files changed, 53 insertions, 8 deletions
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index 8198ff11..70c21a67 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
@property
def packages(self) -> list:
diff --git a/examples/guided.py b/examples/guided.py
index e58228fd..81cc2991 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
@@ -347,11 +347,16 @@ 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")
+ 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 post configuration requirements was not fulfilled.',
+ fg='red'
+ )
+ exit(1)
ask_user_questions()
perform_installation_steps()
- \ No newline at end of file
+
diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py
index bf8227ba..96d972e3 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,19 @@ 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.
+ """
+ installation.log("the installation of i3 does not conatain any configuerations for the wm. In this shell you should take your time to add your desiired configueration. Exit the shell once you are done to continue the installation.", fg="yellow")
+ try:
+ subprocess.check_call("arch-chroot /mnt",shell=True)
+ except subprocess.CallProcessError:
+ return False
+
+ return 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..66a7884e 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,18 @@ 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.
+ """
+ installation.log("the installation of i3 does not conatain any configuerations for the wm. In this shell you should take your time to add your desiired configueration. Exit the shell once you are done to continue the installation.", fg="yellow")
+ try:
+ subprocess.check_call("arch-chroot /mnt",shell=True)
+ except subprocess.CallProcessError:
+ return False
+
+ return True
if __name__ == 'i3-wm':
# Install dependency profiles
@@ -25,4 +37,4 @@ if __name__ == 'i3-wm':
i3 = archinstall.Application(installation, 'i3-wm')
i3.install()
# Auto start lightdm for all users
- installation.enable_service('lightdm') \ No newline at end of file
+ installation.enable_service('lightdm')