Merge pull request #190 from advaithm/master

post install hook
This commit is contained in:
Anton Hvornum 2021-04-06 07:57:02 +00:00 committed by GitHub
commit 610d630863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 8 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
@property
def packages(self) -> list:

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

View File

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

View File

@ -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')
installation.enable_service('lightdm')