From 51eb05691a5845652a9dc583de05519f095961f3 Mon Sep 17 00:00:00 2001 From: Hamad Al Marri Date: Wed, 7 Jul 2021 18:38:55 +0300 Subject: Fix encryption + grub both in UEFI and BIOS systems. We need to have two partitions in BIOS one for boot (grub) and the other for root (/). The format of the boot partition is ext2 (so it is added). If disk is chosen to be encrypted, `then /etc/default/grub` is edited as the followings: https://wiki.archlinux.org/title/Dm-crypt/Encrypting_an_entire_system#Configuring_GRUB_2 Issue: https://github.com/archlinux/archinstall/issues/586 This work is done while working on CachyOS which is Arch based and it is using customized archinstaller. To test these changes you can try CachyOS installer which supports encrypted disk with grub (https://wiki.cachyos.org/). Hamad --- examples/guided.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index aebebcfa..17732f1b 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -322,8 +322,7 @@ def perform_installation_steps(): else: fs.find_partition('/').mount(archinstall.storage.get('MOUNT_POINT', '/mnt')) - if has_uefi(): - fs.find_partition('/boot').mount(archinstall.storage.get('MOUNT_POINT', '/mnt') + '/boot') + fs.find_partition('/boot').mount(archinstall.storage.get('MOUNT_POINT', '/mnt') + '/boot') perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt')) @@ -352,7 +351,7 @@ def perform_installation(mountpoint): installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium if archinstall.arguments["bootloader"] == "grub-install" and has_uefi(): installation.add_additional_packages("grub") - installation.add_bootloader(archinstall.arguments["bootloader"]) + installation.add_bootloader(archinstall.arguments["harddrive"], archinstall.arguments["bootloader"]) # If user selected to copy the current ISO network configuration # Perform a copy of the config -- cgit v1.2.3-54-g00ecf From d55b1786c5797c191cfbaad79c33b1079d1d53c5 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 18 Jul 2021 01:28:41 +0530 Subject: created load_config() to load configuration --- archinstall/lib/user_interaction.py | 3 +- examples/guided.py | 70 +++++++++++++++---------------------- 2 files changed, 31 insertions(+), 42 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 2c5810ae..44dabbe6 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -710,7 +710,8 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS): if has_nvidia_graphics(): print('For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.') - arguments['gfx_driver'] = generic_select(drivers, input_text="Select your graphics card driver: ") + if not arguments.get('gfx_driver', None): + arguments['gfx_driver'] = generic_select(drivers, input_text="Select a graphics driver or leave blank to install all open-source drivers: ") if arguments.get('gfx_driver', None) is None: arguments['gfx_driver'] = "All open-source (default)" diff --git a/examples/guided.py b/examples/guided.py index aebebcfa..0ec9834f 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -26,6 +26,29 @@ archinstall.log(f"Graphics devices detected: {archinstall.graphics_devices().key # For support reasons, we'll log the disk layout pre installation to match against post-installation layout archinstall.log(f"Disk states before installing: {archinstall.disk_layouts()}", level=logging.DEBUG) +def load_config(): + if archinstall.arguments.get('harddrive', None) is not None: + archinstall.arguments['harddrive'] = archinstall.BlockDevice(path=archinstall.arguments['harddrive']['path']) + # Temporarily disabling keep_partitions if config file is loaded + archinstall.arguments['harddrive'].keep_partitions = False + # Temporary workaround to make Desktop Environments work + if archinstall.arguments.get('profile', None) is not None: + if type(archinstall.arguments.get('profile', None)) is dict: + archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)['path']) + else: + archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)) + if archinstall.arguments.get('mirror-region', None) is not None: + if type(archinstall.arguments.get('mirror-region', None)) is dict: + archinstall.arguments['mirror-region'] = archinstall.arguments.get('mirror-region', None) + else: + selected_region = archinstall.arguments.get('mirror-region', None) + archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} + if archinstall.arguments.get('sys-language', None) is not None: + archinstall.arguments['sys-language'] = archinstall.arguments.get('sys-language', 'en_US') + if archinstall.arguments.get('sys-encoding', None) is not None: + archinstall.arguments['sys-encoding'] = archinstall.arguments.get('sys-encoding', 'utf-8') + if archinstall.arguments.get('gfx_driver', None) is not None: + archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) def ask_user_questions(): """ @@ -54,9 +77,6 @@ def ask_user_questions(): break except archinstall.RequirementError as e: archinstall.log(e, fg="red") - else: - selected_region = archinstall.arguments['mirror-region'] - archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} if not archinstall.arguments.get('sys-language', None) and archinstall.arguments.get('advanced', False): archinstall.arguments['sys-language'] = input("Enter a valid locale (language) for your OS, (Default: en_US): ").strip() @@ -69,9 +89,7 @@ def ask_user_questions(): archinstall.arguments['sys-encoding'] = 'utf-8' # Ask which harddrive/block-device we will install to - if archinstall.arguments.get('harddrive', None): - archinstall.arguments['harddrive'] = archinstall.BlockDevice(archinstall.arguments['harddrive']) - else: + if not archinstall.arguments.get('harddrive', None): archinstall.arguments['harddrive'] = archinstall.select_disk(archinstall.all_disks()) if archinstall.arguments['harddrive'] is None: archinstall.arguments['target-mount'] = archinstall.storage.get('MOUNT_POINT', '/mnt') @@ -188,20 +206,15 @@ def ask_user_questions(): archinstall.arguments['!root-password'] = archinstall.get_password(prompt='Enter root password (Recommendation: leave blank to leave root disabled): ') # Ask for additional users (super-user if root pw was not set) - archinstall.arguments['users'] = {} - archinstall.arguments['superusers'] = {} - if not archinstall.arguments.get('!root-password', None): + if not archinstall.arguments.get('!root-password', None) and not archinstall.arguments.get('superusers', None): archinstall.arguments['superusers'] = archinstall.ask_for_superuser_account('Create a required super-user with sudo privileges: ', forced=True) - - users, superusers = archinstall.ask_for_additional_users('Enter a username to create a additional user (leave blank to skip & continue): ') - archinstall.arguments['users'] = users - archinstall.arguments['superusers'] = {**archinstall.arguments['superusers'], **superusers} + users, superusers = archinstall.ask_for_additional_users('Enter a username to create a additional user (leave blank to skip & continue): ') + archinstall.arguments['users'] = users + archinstall.arguments['superusers'] = {**archinstall.arguments['superusers'], **superusers} # Ask for archinstall-specific profiles (such as desktop environments etc) if not archinstall.arguments.get('profile', None): archinstall.arguments['profile'] = archinstall.select_profile() - else: - archinstall.arguments['profile'] = Profile(installer=None, path=archinstall.arguments['profile']) # Check the potentially selected profiles preparations to get early checks if some additional questions are needed. if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_prep_function(): @@ -437,33 +450,8 @@ if not check_mirror_reachable(): archinstall.log(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'.", level=logging.INFO, fg="red") exit(1) +load_config() if not archinstall.arguments.get('silent'): ask_user_questions() -else: - # Workarounds if config is loaded from a file - # The harddrive section should be moved to perform_installation_steps, where it's actually being performed - # Blockdevice object should be created in perform_installation_steps - # This needs to be done until then - archinstall.arguments['harddrive'] = archinstall.BlockDevice(path=archinstall.arguments['harddrive']['path']) - # Temporarily disabling keep_partitions if config file is loaded - archinstall.arguments['harddrive'].keep_partitions = False - # Temporary workaround to make Desktop Environments work - if archinstall.arguments.get('profile', None) is not None: - if type(archinstall.arguments.get('profile', None)) is dict: - archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)['path']) - else: - archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)) - else: - archinstall.arguments['profile'] = None - if archinstall.arguments.get('mirror-region', None) is not None: - if type(archinstall.arguments.get('mirror-region', None)) is dict: - archinstall.arguments['mirror-region'] = archinstall.arguments.get('mirror-region', None) - else: - selected_region = archinstall.arguments.get('mirror-region', None) - archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} - archinstall.arguments['sys-language'] = archinstall.arguments.get('sys-language', 'en_US') - archinstall.arguments['sys-encoding'] = archinstall.arguments.get('sys-encoding', 'utf-8') - if archinstall.arguments.get('gfx_driver', None) is not None: - archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) perform_installation_steps() -- cgit v1.2.3-54-g00ecf From b2476313a7284fedc7a29ec17fc5090a1c985ae9 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 18 Jul 2021 21:17:20 +0530 Subject: added new key for desktop-environment --- examples/guided.py | 1 + profiles/desktop.py | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 0ec9834f..6054387a 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -37,6 +37,7 @@ def load_config(): archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)['path']) else: archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)) + archinstall.storage['_desktop_profile'] = archinstall.arguments.get('desktop-environment', None) if archinstall.arguments.get('mirror-region', None) is not None: if type(archinstall.arguments.get('mirror-region', None)) is dict: archinstall.arguments['mirror-region'] = archinstall.arguments.get('mirror-region', None) diff --git a/profiles/desktop.py b/profiles/desktop.py index eaf145c2..457283e9 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -52,10 +52,8 @@ def _prep_function(*args, **kwargs): # the next time it gets executed. if '_desktop_profile' not in archinstall.storage.keys(): archinstall.storage['_desktop_profile'] = desktop - + archinstall.arguments['desktop-environment'] = desktop profile = archinstall.Profile(None, desktop) - # Set the resolved profile path to the actual desktop environment - archinstall.arguments['profile'] = profile # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. with profile.load_instructions(namespace=f"{desktop}.py") as imported: if hasattr(imported, '_prep_function'): -- cgit v1.2.3-54-g00ecf From b60e8dfd10d4d4c2b2918bad8df2b8354a7f4996 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 18 Jul 2021 21:45:24 +0530 Subject: changed dry_run to dry-run --- archinstall/__init__.py | 2 +- examples/guided.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 84595528..2eec1ce6 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -64,7 +64,7 @@ def initialize_arguments(): config[key] = val config["script"] = args.script if args.dry_run is not None: - config["dry_run"] = args.dry_run + config["dry-run"] = args.dry_run return config diff --git a/examples/guided.py b/examples/guided.py index 6054387a..6cb80190 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -280,7 +280,7 @@ def perform_installation_steps(): config_file.write(user_configuration) print() - if archinstall.arguments.get('dry_run'): + if archinstall.arguments.get('dry-run'): exit(0) if not archinstall.arguments.get('silent'): -- cgit v1.2.3-54-g00ecf From 79f70cee21c3ed74b2a7c274dee34843aa54f2c7 Mon Sep 17 00:00:00 2001 From: ギャラ Date: Wed, 18 Aug 2021 20:52:10 +0900 Subject: Update guided.py Fix wrong default in kernels. --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index aebebcfa..91d0357c 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -334,7 +334,7 @@ def perform_installation(mountpoint): Only requirement is that the block devices are formatted and setup prior to entering this function. """ - with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', 'linux')) as installation: + with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', ['linux'])) as installation: # if len(mirrors): # Certain services might be running that affects the system during installation. # Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist -- cgit v1.2.3-54-g00ecf From 6d462ac1ccfe3ec74f70e000465d422c31d9e634 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Fri, 20 Aug 2021 03:34:50 +0530 Subject: added servers key --- examples/guided.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 6cb80190..7a9f8b47 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -8,6 +8,7 @@ from archinstall.lib.general import run_custom_user_commands from archinstall.lib.hardware import * from archinstall.lib.networking import check_mirror_reachable from archinstall.lib.profiles import Profile, is_desktop_profile +from archinstall.lib.profiles.server import available_servers if archinstall.arguments.get('help'): print("See `man archinstall` for help.") @@ -50,7 +51,9 @@ def load_config(): archinstall.arguments['sys-encoding'] = archinstall.arguments.get('sys-encoding', 'utf-8') if archinstall.arguments.get('gfx_driver', None) is not None: archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) - + if archinstall.arguments.get('servers', None) is not None: + archinstall.storage['_selected_servers'] = archinstall.arguments.get('servers', None) + def ask_user_questions(): """ First, we'll ask the user for a bunch of user input. -- cgit v1.2.3-54-g00ecf From 78bbf26c1aa02f34366020ec4d9212836fafc3dd Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Fri, 20 Aug 2021 03:48:13 +0530 Subject: Update guided.py --- examples/guided.py | 1 - 1 file changed, 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 7a9f8b47..273fcadf 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -8,7 +8,6 @@ from archinstall.lib.general import run_custom_user_commands from archinstall.lib.hardware import * from archinstall.lib.networking import check_mirror_reachable from archinstall.lib.profiles import Profile, is_desktop_profile -from archinstall.lib.profiles.server import available_servers if archinstall.arguments.get('help'): print("See `man archinstall` for help.") -- cgit v1.2.3-54-g00ecf