added _post_install hook.

This commit is contained in:
advaithm 2021-04-06 07:21:11 +05:30
parent b56f7d0515
commit f0e40f5676
4 changed files with 42 additions and 6 deletions

View File

@ -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):

View File

@ -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()

View File

@ -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')

View File

@ -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