From b5a970223093a201d9271dea49fa1cb35131b17f Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 16 Mar 2020 11:46:57 +0100 Subject: New function: prerequisit_check(). Moved the exit-if-not-uefi logic into a function instead of hard-crashing whoever imports the library. This way tho, it's up to the user to run the check. TODO: Add a warning message if the function isn't run beforehand. --- archinstall.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/archinstall.py b/archinstall.py index 994ecfe0..2fcaac55 100644 --- a/archinstall.py +++ b/archinstall.py @@ -13,10 +13,6 @@ from string import ascii_uppercase, ascii_lowercase, digits from hashlib import sha512 from threading import Thread, enumerate as tenum -if not os.path.isdir('/sys/firmware/efi'): - print('[E] This script only supports UEFI-booted machines.') - exit(1) - if os.path.isfile('./SAFETY_LOCK'): SAFETY_LOCK = True else: @@ -1219,7 +1215,18 @@ def create_user(username, password='', groups=[]): o = (f'/usr/bin/arch-chroot /mnt gpasswd -a {username} {group}') return True +def prerequisit_check(): + if not os.path.isdir('/sys/firmware/efi'): + return False, 'Archinstall only supports UEFI-booted machines.' + + return True + if __name__ == '__main__': + + if not (prereq := prerequisit_check()) is True: + print(f'[E] {prereq[1]}') + exit(1) + ## Setup some defaults # (in case no command-line parameters or netdeploy-params were given) args = setup_args_defaults(args) -- cgit v1.2.3-70-g09d2