From a7c0142099066791d48240815c47c07772f9e025 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 16 Apr 2021 11:48:24 +0200 Subject: Adding debug data to the log. It will now contain lsblk before and after the installation to help with detecting any potential information. Also removed a traceback log that was for debugging purposes. --- archinstall/lib/disk.py | 10 +++++++++- examples/guided.py | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index bada4076..c23bc6ac 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -222,7 +222,7 @@ class Partition(): def encrypted(self, value :bool): if value: log(f'Marking {self} as encrypted: {value}', level=LOG_LEVELS.Debug) - log(f"Callstrack when marking the partition: {''.join(traceback.format_stack())}", level=LOG_LEVELS.Debug) + #log(f"Callstrack when marking the partition: {''.join(traceback.format_stack())}", level=LOG_LEVELS.Debug) self._encrypted = value @@ -611,3 +611,11 @@ def get_filesystem_type(path): return b''.join(handle).strip().decode('UTF-8') except SysCallError: return None + +def disk_layouts(): + try: + handle = sys_command(f"lsblk -f -o+TYPE,SIZE -J") + return json.loads(b''.join(handle).decode('UTF-8')) + except SysCallError as err: + log(f"Could not return disk layouts: {err}") + return None \ No newline at end of file diff --git a/examples/guided.py b/examples/guided.py index c0d22023..dc638d26 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -7,6 +7,9 @@ if hasUEFI() is False: archinstall.log("ArchInstall currently only supports machines booted with UEFI.\nMBR & GRUB support is coming in version 2.2.0!", fg="red", level=archinstall.LOG_LEVELS.Error) exit(1) +# 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=archinstall.LOG_LEVELS.Debug) + def ask_user_questions(): """ First, we'll ask the user for a bunch of user input. @@ -357,6 +360,8 @@ def perform_installation(mountpoint): except: pass -ask_user_questions() -perform_installation_steps() + # For support reasons, we'll log the disk layout post installation (crash or no crash) + archinstall.log(f"Disk states after installing: {archinstall.disk_layouts()}", level=archinstall.LOG_LEVELS.Debug) +ask_user_questions() +perform_installation_steps() \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 1f2fe467d1956fd3d4550c33069da2f9f0017c72 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Thu, 29 Apr 2021 00:59:35 +0300 Subject: Update generic_multi_select Changes: - Add useful checks from `generic_select` - Sorting is now disabled by default (As many lists are already sorted) - Some checks have been changed (This includes unnecessary checks with `len()`, etc.) - Removed x, y from `print_large_list` as they aren't used in code - Added check for string to strip it without getting `AttributeError` - Switched to RequirementError handling as in `generic_select` - Added a log when the default option is selected with unselected options by the user - Added break when adding default option to empty list (See comments for more info) - Added support for selecting option by name --- archinstall/lib/user_interaction.py | 70 +++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 451251cd..8a4b4c49 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -99,7 +99,18 @@ def print_large_list(options, padding=5, margin_bottom=0, separator=': '): return column, row -def generic_multi_select(options, text="Select one or more of the options above (leave blank to continue): ", sort=True, default=None, allow_empty=False): +def generic_multi_select(options, text="Select one or more of the options above (leave blank to continue): ", sort=False, default=None, allow_empty=False): + # For now, we check for list, but in future it's better to have support for dictionary + # (At the moment there are no cases of using dictionaries with this function) + if type(options) not in [list]: + log(f" * Generic multi-select doesn't support ({type(options)}) as type of options * ", fg='red') + log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') + raise RequirementError("generic_multi_select() requires list as options.") + if not options: + log(f" * Generic multi-select didn't find any options to choose from * ", fg='red') + log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') + raise RequirementError('generic_multi_select() requires at least one option to proceed.') + # After passing the checks, function continues to work if sort: options = sorted(options) @@ -108,7 +119,7 @@ def generic_multi_select(options, text="Select one or more of the options above selected_options = [] while True: - if len(selected_options) <= 0 and default and default in options: + if not selected_options and default in options: selected_options.append(default) printed_options = [] @@ -119,32 +130,47 @@ def generic_multi_select(options, text="Select one or more of the options above printed_options.append(f'{option}') section.clear(0, get_terminal_height()-section._cursor_y-1) - x, y = print_large_list(printed_options, margin_bottom=2) + print_large_list(printed_options, margin_bottom=2) section._cursor_y = len(printed_options) section._cursor_x = 0 section.write_line(text) section.input_pos = section._cursor_x selected_option = section.get_keyboard_input(end=None) - - if selected_option is None: - if len(selected_options) <= 0 and default: - selected_options = [default] - - if len(selected_options) or allow_empty is True: - break - else: - log('* Need to select at least one option!', fg='red') - continue - - elif selected_option.isdigit(): - if (selected_option := int(selected_option)) >= len(options): - log('* Option is out of range, please select another one!', fg='red') - continue - selected_option = options[selected_option] - if selected_option in selected_options: - selected_options.remove(selected_option) + # This string check is necessary to correct work with it + # Without this, Python can raise AttributeError because of stripping `None` + # It also allows you to remove empty spaces if the user accidentally entered them. + if isinstance(selected_option, str): + selected_option = selected_option.strip() + try: + if not selected_option: + # Added break when adding default option to empty list + # So that the check doesn't go to the next elif + # Since it still breaks the loop + if not selected_options and default: + selected_options = [default] + log(f'Default option selected: "{default}"', fg='yellow') + break + elif selected_options or allow_empty: + break + else: + raise RequirementError('Please select at least one option to continue!') + elif selected_option.isnumeric(): + if (selected_option := int(selected_option)) >= len(options): + raise RequirementError(f'Selected option "{selected_option}" is out of range!') + selected_option = options[selected_option] + if selected_option in selected_options: + selected_options.remove(selected_option) + else: + selected_options.append(selected_option) + elif selected_option in options: + if selected_option in selected_options: + selected_options.remove(selected_option) + else: + selected_options.append(selected_option) else: - selected_options.append(selected_option) + raise RequirementError(f'Selected option "{selected_option}" does not exist in available options') + except RequirementError as e: + log(f" * {e} * ", fg='red') return selected_options -- cgit v1.2.3-54-g00ecf From 5c8748dbb5f663f579b6a462d317162de163fa84 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Thu, 29 Apr 2021 01:13:19 +0300 Subject: Update generic_select Changes: - Moved some functions for options below checks for the correctness of passed options - Removed unnecessary `continue` from `except ...`, since the loop will return to the beginning anyway - Added stripping of `selected_option` straight on input - Changed check `len() == 0` to `not ...` - Returned changing string to number on check === - Removed '!' as they look weird inside such ` * ... * ` log style (Change for generic_multi_select) --- archinstall/lib/user_interaction.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 8a4b4c49..437ca68f 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -153,10 +153,10 @@ def generic_multi_select(options, text="Select one or more of the options above elif selected_options or allow_empty: break else: - raise RequirementError('Please select at least one option to continue!') + raise RequirementError('Please select at least one option to continue') elif selected_option.isnumeric(): if (selected_option := int(selected_option)) >= len(options): - raise RequirementError(f'Selected option "{selected_option}" is out of range!') + raise RequirementError(f'Selected option "{selected_option}" is out of range') selected_option = options[selected_option] if selected_option in selected_options: selected_options.remove(selected_option) @@ -461,20 +461,24 @@ def generic_select(options, input_text="Select one of the above by index or abso this function returns an item from list, a string, or None """ - # Checking if options are different from `list` or `dict` + # Checking if the options are different from `list` or `dict` or if they are empty if type(options) not in [list, dict]: log(f" * Generic select doesn't support ({type(options)}) as type of options * ", fg='red') log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') raise RequirementError("generic_select() requires list or dictionary as options.") - # To allow only `list` and `dict`, converting values of options here. - # Therefore, now we can only provide the dictionary itself - if type(options) == dict: options = list(options.values()) - if sort: options = sorted(options) # As we pass only list and dict (converted to list), we can skip converting to list - if len(options) == 0: + if not options: log(f" * Generic select didn't find any options to choose from * ", fg='red') log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') raise RequirementError('generic_select() requires at least one option to proceed.') - + # After passing the checks, function continues to work + if type(options) == dict: + # To allow only `list` and `dict`, converting values of options here. + # Therefore, now we can only provide the dictionary itself + options = list(options.values()) + if sort: + # As we pass only list and dict (converted to list), we can skip converting to list + options = sorted(options) + # Added ability to disable the output of options items, # if another function displays something different from this @@ -486,8 +490,8 @@ def generic_select(options, input_text="Select one of the above by index or abso # Now the try...except block handles validation for invalid input from the user while True: try: - selected_option = input(input_text) - if len(selected_option.strip()) == 0: + selected_option = input(input_text).strip() + if not selected_option: # `allow_empty_input` parameter handles return of None on empty input, if necessary # Otherwise raise `RequirementError` if allow_empty_input: @@ -495,8 +499,7 @@ def generic_select(options, input_text="Select one of the above by index or abso raise RequirementError('Please select an option to continue') # Replaced `isdigit` with` isnumeric` to discard all negative numbers elif selected_option.isnumeric(): - selected_option = int(selected_option) - if selected_option >= len(options): + if (selected_option := int(selected_option)) >= len(options): raise RequirementError(f'Selected option "{selected_option}" is out of range') selected_option = options[selected_option] break @@ -506,7 +509,6 @@ def generic_select(options, input_text="Select one of the above by index or abso raise RequirementError(f'Selected option "{selected_option}" does not exist in available options') except RequirementError as err: log(f" * {err} * ", fg='red') - continue return selected_option -- cgit v1.2.3-54-g00ecf From 5f1156f80e4038a52719f4ba01c87eae4f0a8660 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Thu, 29 Apr 2021 01:30:35 +0300 Subject: Fix multi select and video card driver selection Changes: - Rephrased input text for kernel selection - Fixed crash with empty video card driver selection - Removed log info for default option --- archinstall/lib/user_interaction.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 437ca68f..10d74b63 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -118,10 +118,10 @@ def generic_multi_select(options, text="Select one or more of the options above selected_options = [] - while True: - if not selected_options and default in options: - selected_options.append(default) + if not selected_options and default in options: + selected_options.append(default) + while True: printed_options = [] for option in options: if option in selected_options: @@ -148,7 +148,6 @@ def generic_multi_select(options, text="Select one or more of the options above # Since it still breaks the loop if not selected_options and default: selected_options = [default] - log(f'Default option selected: "{default}"', fg='yellow') break elif selected_options or allow_empty: break @@ -687,7 +686,7 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS): elif b'amd' in line.lower(): print(' ** AMD card detected, suggested driver: AMD / ATI **') - initial_option = generic_select(drivers, input_text="Select your graphics card driver: ") + initial_option = generic_select(drivers, input_text="Select your graphics card driver: ", allow_empty_input=False) selected_driver = options[initial_option] if type(selected_driver) == dict: @@ -719,6 +718,6 @@ def select_kernel(options): kernels = sorted(list(options)) if kernels: - return generic_multi_select(kernels, f"Choose which kernel to use (leave blank for default: {DEFAULT_KERNEL}): ", default=DEFAULT_KERNEL) + return generic_multi_select(kernels, f"Choose which kernels to use (Default value for empty selection: {DEFAULT_KERNEL}): ", default=DEFAULT_KERNEL) raise RequirementError("Selecting kernels require a least one kernel to be given as an option.") -- cgit v1.2.3-54-g00ecf From ea14e860c7f730897544cb1bdb43964e25785c74 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Thu, 29 Apr 2021 18:47:31 +0300 Subject: Update `user_interaction.py` - Reverted some changes for default options in multi select - Added check for dict and convert from dict to list - Replaced spaces with tabs for certain comment line --- archinstall/lib/user_interaction.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 10d74b63..f06354d2 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -100,17 +100,18 @@ def print_large_list(options, padding=5, margin_bottom=0, separator=': '): def generic_multi_select(options, text="Select one or more of the options above (leave blank to continue): ", sort=False, default=None, allow_empty=False): - # For now, we check for list, but in future it's better to have support for dictionary - # (At the moment there are no cases of using dictionaries with this function) - if type(options) not in [list]: + # Checking if the options are different from `list` or `dict` or if they are empty + if type(options) not in [list, dict]: log(f" * Generic multi-select doesn't support ({type(options)}) as type of options * ", fg='red') log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') - raise RequirementError("generic_multi_select() requires list as options.") + raise RequirementError("generic_multi_select() requires list or dictionary as options.") if not options: log(f" * Generic multi-select didn't find any options to choose from * ", fg='red') log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') raise RequirementError('generic_multi_select() requires at least one option to proceed.') # After passing the checks, function continues to work + if type(options) == dict: + options = list(options.values()) if sort: options = sorted(options) @@ -118,10 +119,10 @@ def generic_multi_select(options, text="Select one or more of the options above selected_options = [] - if not selected_options and default in options: - selected_options.append(default) - while True: + if not selected_options and default in options: + selected_options.append(default) + printed_options = [] for option in options: if option in selected_options: @@ -136,19 +137,15 @@ def generic_multi_select(options, text="Select one or more of the options above section.write_line(text) section.input_pos = section._cursor_x selected_option = section.get_keyboard_input(end=None) - # This string check is necessary to correct work with it + # This string check is necessary to correct work with it # Without this, Python can raise AttributeError because of stripping `None` # It also allows you to remove empty spaces if the user accidentally entered them. if isinstance(selected_option, str): selected_option = selected_option.strip() try: if not selected_option: - # Added break when adding default option to empty list - # So that the check doesn't go to the next elif - # Since it still breaks the loop if not selected_options and default: selected_options = [default] - break elif selected_options or allow_empty: break else: @@ -718,6 +715,6 @@ def select_kernel(options): kernels = sorted(list(options)) if kernels: - return generic_multi_select(kernels, f"Choose which kernels to use (Default value for empty selection: {DEFAULT_KERNEL}): ", default=DEFAULT_KERNEL) + return generic_multi_select(kernels, f"Choose which kernels to use (leave blank for default: {DEFAULT_KERNEL}): ", default=DEFAULT_KERNEL) raise RequirementError("Selecting kernels require a least one kernel to be given as an option.") -- cgit v1.2.3-54-g00ecf From efadd4a42694d87b3fe86bd7bcedf1da9a9e1773 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Fri, 30 Apr 2021 22:31:31 +0300 Subject: Revert disabling default sorting This change reverts a previous change that disabled sorting by default in the multi select function, which would be better disabled manually for pre-sorted lists than manually enabling for unsorted lists. Also, comments of the line check have been slightly changed --- archinstall/lib/user_interaction.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index f06354d2..81f04db4 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -99,7 +99,7 @@ def print_large_list(options, padding=5, margin_bottom=0, separator=': '): return column, row -def generic_multi_select(options, text="Select one or more of the options above (leave blank to continue): ", sort=False, default=None, allow_empty=False): +def generic_multi_select(options, text="Select one or more of the options above (leave blank to continue): ", sort=True, default=None, allow_empty=False): # Checking if the options are different from `list` or `dict` or if they are empty if type(options) not in [list, dict]: log(f" * Generic multi-select doesn't support ({type(options)}) as type of options * ", fg='red') @@ -138,8 +138,8 @@ def generic_multi_select(options, text="Select one or more of the options above section.input_pos = section._cursor_x selected_option = section.get_keyboard_input(end=None) # This string check is necessary to correct work with it - # Without this, Python can raise AttributeError because of stripping `None` - # It also allows you to remove empty spaces if the user accidentally entered them. + # Without this, Python will raise AttributeError because of stripping `None` + # It also allows to remove empty spaces if the user accidentally entered them. if isinstance(selected_option, str): selected_option = selected_option.strip() try: @@ -715,6 +715,6 @@ def select_kernel(options): kernels = sorted(list(options)) if kernels: - return generic_multi_select(kernels, f"Choose which kernels to use (leave blank for default: {DEFAULT_KERNEL}): ", default=DEFAULT_KERNEL) + return generic_multi_select(kernels, f"Choose which kernels to use (leave blank for default: {DEFAULT_KERNEL}): ", default=DEFAULT_KERNEL, sort=False) raise RequirementError("Selecting kernels require a least one kernel to be given as an option.") -- cgit v1.2.3-54-g00ecf From 8f4b8fd5ffed54a4d1f7508d4ac6380ae8b84a29 Mon Sep 17 00:00:00 2001 From: builder_247 <14019974+builder-247@users.noreply.github.com> Date: Sat, 1 May 2021 00:36:40 +0300 Subject: Fix syntax error --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 61ac737c..331762b4 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -433,7 +433,7 @@ class Installer(): self.pacstrap('grub') if hasUEFI(): - self.pacstrap('efibootmgr')` + self.pacstrap('efibootmgr') o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB')) sys_command('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') return True -- cgit v1.2.3-54-g00ecf From feae13ac84e10cdf624cb4b3b19ba4707a96dabd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 30 Apr 2021 22:34:54 -0400 Subject: Tweak wording for superuser prompt a little bit --- archinstall/lib/user_interaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 451251cd..ac9ceefb 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -292,7 +292,7 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan continue password = get_password(prompt=f'Password for user {new_user}: ') - if input("Should this user be a sudo (super) user (y/N): ").strip(' ').lower() in ('y', 'yes'): + if input("Should this user be a superuser (sudoer) [y/N]: ").strip(' ').lower() in ('y', 'yes'): super_users[new_user] = {"!password" : password} else: users[new_user] = {"!password" : password} -- cgit v1.2.3-54-g00ecf From 4efa01c4fd1b14103f2690a92c7195bd6bb6fe42 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 30 Apr 2021 22:42:08 -0400 Subject: Make the style of the word superuser consistent --- archinstall/lib/user_interaction.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index ac9ceefb..be01594e 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -263,14 +263,14 @@ class MiniCurses(): if response: return response -def ask_for_superuser_account(prompt='Username for required super-user with sudo privileges: ', forced=False): +def ask_for_superuser_account(prompt='Username for required superuser with sudo privileges: ', forced=False): while 1: new_user = input(prompt).strip(' ') if not new_user and forced: # TODO: make this text more generic? # It's only used to create the first sudo user when root is disabled in guided.py - log(' * Since root is disabled, you need to create a least one (super) user!', fg='red') + log(' * Since root is disabled, you need to create a least one superuser!', fg='red') continue elif not new_user and not forced: raise UserError("No superuser was created.") @@ -282,7 +282,7 @@ def ask_for_superuser_account(prompt='Username for required super-user with sudo def ask_for_additional_users(prompt='Any additional users to install (leave blank for no users): '): users = {} - super_users = {} + superusers = {} while 1: new_user = input(prompt).strip(' ') @@ -293,11 +293,11 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan password = get_password(prompt=f'Password for user {new_user}: ') if input("Should this user be a superuser (sudoer) [y/N]: ").strip(' ').lower() in ('y', 'yes'): - super_users[new_user] = {"!password" : password} + superusers[new_user] = {"!password" : password} else: users[new_user] = {"!password" : password} - return users, super_users + return users, superusers def ask_for_a_timezone(): while True: -- cgit v1.2.3-54-g00ecf From d27fe9715f357d0a3d98ed166f480d27de3e920f Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 1 May 2021 09:28:42 -0400 Subject: Attempt to fix #406 I think this should fix the comment Torxed made --- profiles/sway.py | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/profiles/sway.py b/profiles/sway.py index db94ae2c..8e256a87 100644 --- a/profiles/sway.py +++ b/profiles/sway.py @@ -4,7 +4,19 @@ import archinstall is_top_level_profile = False -__packages__ = ["sway", "swaylock", "swayidle", "waybar", "dmenu", "light", "grim", "slurp", "pavucontrol", "alacritty"] +__packages__ = [ + "sway", + "swaylock", + "swayidle", + "waybar", + "dmenu", + "light", + "grim", + "slurp", + "pavucontrol", + "alacritty", +] + def _prep_function(*args, **kwargs): """ @@ -13,18 +25,26 @@ def _prep_function(*args, **kwargs): other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ - if "nvidia" in _gfx_driver_packages: - choice = input("The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues. Continue anyways? [y/N] ") - if choice.lower() in ("n", ""): - raise archinstall.lib.exceptions.HardwareIncompatibilityError("Sway does not support the proprietary nvidia drivers.") - - __builtins__['_gfx_driver_packages'] = archinstall.select_driver() + __builtins__["_gfx_driver_packages"] = archinstall.select_driver() return True + # Ensures that this code only gets executed if executed # through importlib.util.spec_from_file_location("sway", "/somewhere/sway.py") # or through conventional import sway -if __name__ == 'sway': +if __name__ == "sway": + if "nvidia" in _gfx_driver_packages: + choice = input( + "The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues. Continue anyways? [y/N] " + ) + if choice.lower() in ("n", ""): + raise archinstall.lib.exceptions.HardwareIncompatibilityError( + "Sway does not support the proprietary nvidia drivers." + ) + # Install the Sway packages installation.add_additional_packages(__packages__) + + # Install the graphics driver packages + installation.add_additional_packages(_gfx_driver_packages) -- cgit v1.2.3-54-g00ecf From 900827a9262df47852ad3ba84fd88a7db438cf59 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 5 May 2021 11:31:24 -0400 Subject: Change graphics driver selection based on #414 --- archinstall/lib/hardware.py | 55 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index f139dfe4..185ec1d6 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -3,24 +3,53 @@ from .general import sys_command from .networking import list_interfaces, enrichIfaceTypes from typing import Optional -__packages__ = ['xf86-video-amdgpu', 'xf86-video-ati', 'xf86-video-intel', 'xf86-video-nouveau', 'xf86-video-fbdev', 'xf86-video-vesa', 'xf86-video-vmware', 'nvidia', 'mesa'] +__packages__ = [ + "mesa", + "xf86-video-amdgpu", + "xf86-video-ati", + "xf86-video-nouveau", + "xf86-video-vmware", + "libva-mesa-driver", + "libva-intel-driver", + "intel-media-driver", + "vulkan-radeon", + "vulkan-intel", + "nvidia", +] AVAILABLE_GFX_DRIVERS = { # Sub-dicts are layer-2 options to be selected # and lists are a list of packages to be installed - 'AMD / ATI' : { - 'amd' : ['xf86-video-amdgpu'], - 'ati' : ['xf86-video-ati'] + "All open-source (default)": [ + "mesa", + "xf86-video-amdgpu", + "xf86-video-ati", + "xf86-video-nouveau", + "xf86-video-vmware", + "libva-mesa-driver", + "libva-intel-driver", + "intel-media-driver", + "vulkan-radeon", + "vulkan-intel", + ], + "AMD / ATI (open-source)": [ + "mesa", + "xf86-video-amdgpu", + "xf86-video-ati", + "libva-mesa-driver", + "vulkan-radeon", + ], + "Intel (open-source)": [ + "mesa", + "libva-intel-driver", + "intel-media-driver", + "vulkan-intel", + ], + "Nvidia": { + "open-source": ["mesa", "xf86-video-nouveau", "libva-mesa-driver"], + "proprietary": ["nvidia"], }, - 'intel' : ['xf86-video-intel'], - 'nvidia' : { - 'open-source' : ['xf86-video-nouveau'], - 'proprietary' : ['nvidia'] - }, - 'mesa' : ['mesa'], - 'fbdev' : ['xf86-video-fbdev'], - 'vesa' : ['xf86-video-vesa'], - 'vmware / virtualbox' : ['xf86-video-vmware'] + "VMware / VirtualBox (open-source)": ["mesa", "xf86-video-vmware"], } def hasWifi()->bool: -- cgit v1.2.3-54-g00ecf From 3c23f5e810b095dbe1714ff1047709c7c8f237d3 Mon Sep 17 00:00:00 2001 From: Ondřej Nekola Date: Thu, 6 May 2021 13:01:43 +0200 Subject: add dmenu dependency to i3 profile dmenu is configured as the default launcher (Penguin-SPACE key) in the default i3 configuartion. --- profiles/i3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/i3.py b/profiles/i3.py index e2db5fc7..8492d36f 100644 --- a/profiles/i3.py +++ b/profiles/i3.py @@ -6,7 +6,7 @@ is_top_level_profile = False # New way of defining packages for a profile, which is iterable and can be used out side # of the profile to get a list of "what packages will be installed". -__packages__ = ['i3lock', 'i3status', 'i3blocks', 'xterm', 'lightdm-gtk-greeter', 'lightdm'] +__packages__ = ['i3lock', 'i3status', 'i3blocks', 'xterm', 'lightdm-gtk-greeter', 'lightdm', 'dmenu'] def _prep_function(*args, **kwargs): """ -- cgit v1.2.3-54-g00ecf From 493814d8bd9a89089c6bedf82f9c85ca7075edfb Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Thu, 6 May 2021 21:38:20 +0300 Subject: Add default graphics card driver option --- archinstall/lib/user_interaction.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 81f04db4..aea708c8 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -673,6 +673,7 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS): """ drivers = sorted(list(options)) + default_option = options["All open-source (default)"] if drivers: lspci = sys_command(f'/usr/bin/lspci') @@ -683,7 +684,11 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS): elif b'amd' in line.lower(): print(' ** AMD card detected, suggested driver: AMD / ATI **') - initial_option = generic_select(drivers, input_text="Select your graphics card driver: ", allow_empty_input=False) + initial_option = generic_select(drivers, input_text="Select your graphics card driver: ") + + if not initial_option: + return default_option + selected_driver = options[initial_option] if type(selected_driver) == dict: -- cgit v1.2.3-54-g00ecf From 24a14d1800e990e2e90dd628b8460f85fe3d1495 Mon Sep 17 00:00:00 2001 From: aboven Date: Sat, 8 May 2021 13:18:03 +0200 Subject: fix error when to many options and calculation spaces --- archinstall/lib/user_interaction.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index be01594e..1240e0be 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -83,16 +83,18 @@ def get_password(prompt="Enter a password: "): def print_large_list(options, padding=5, margin_bottom=0, separator=': '): highest_index_number_length = len(str(len(options))) longest_line = highest_index_number_length + len(separator) + get_longest_option(options) + padding + spaces_without_option = longest_line - (len(separator) + highest_index_number_length) max_num_of_columns = get_terminal_width() // longest_line max_options_in_cells = max_num_of_columns * (get_terminal_height()-margin_bottom) if (len(options) > max_options_in_cells): for index, option in enumerate(options): print(f"{index}: {option}") + return 1, index else: for row in range(0, (get_terminal_height()-margin_bottom)): for column in range(row, len(options), (get_terminal_height()-margin_bottom)): - spaces = " "*(longest_line - len(options[column])) + spaces = " "*(spaces_without_option - len(options[column])) print(f"{str(column): >{highest_index_number_length}}{separator}{options[column]}", end = spaces) print() -- cgit v1.2.3-54-g00ecf From 69d079e63a00caf9268575a6ca4789962776761b Mon Sep 17 00:00:00 2001 From: advaithm Date: Wed, 12 May 2021 15:45:45 +0530 Subject: some type hint fixes and a bad catch fix --- .vscode/settings.json | 3 +++ archinstall/lib/disk.py | 5 +++-- archinstall/lib/general.py | 9 +++++---- archinstall/lib/hardware.py | 1 + archinstall/lib/output.py | 2 +- archinstall/lib/profiles.py | 5 +++-- examples/__init__.py | 0 profiles/__init__.py | 0 profiles/applications/__init__.py | 0 setup.py | 2 +- 10 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 examples/__init__.py create mode 100644 profiles/__init__.py create mode 100644 profiles/applications/__init__.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..d2a6c127 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/usr/bin/python" +} \ No newline at end of file diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 44462a21..fd08ea63 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -1,3 +1,4 @@ +from typing import Optional import glob, re, os, json, time, hashlib import pathlib, traceback, logging from collections import OrderedDict @@ -205,7 +206,7 @@ class Partition(): return f'Partition(path={self.path}, size={self.size}, fs={self.filesystem}{mount_repr})' @property - def uuid(self) -> str: + def uuid(self) -> Optional[str]: """ Returns the PARTUUID as returned by lsblk. This is more reliable than relying on /dev/disk/by-partuuid as @@ -214,7 +215,7 @@ class Partition(): lsblk = b''.join(sys_command(f'lsblk -J -o+PARTUUID {self.path}')) for partition in json.loads(lsblk.decode('UTF-8'))['blockdevices']: return partition.get('partuuid', None) - + return None @property def encrypted(self): return self._encrypted diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index eb0c5d14..72f8677f 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -5,6 +5,7 @@ from subprocess import Popen, STDOUT, PIPE, check_output from select import epoll, EPOLLIN, EPOLLHUP from .exceptions import * from .output import log +from typing import Optional, Union def gen_uid(entropy_length=256): return hashlib.sha512(os.urandom(entropy_length)).hexdigest() @@ -160,16 +161,15 @@ class sys_command():#Thread): 'exit_code': self.exit_code } - def peak(self, output :str): + def peak(self, output : Union[str, bytes]) -> bool: if type(output) == bytes: try: output = output.decode('UTF-8') except UnicodeDecodeError: - return None - + return False output = output.strip('\r\n ') if len(output) <= 0: - return None + return False if self.peak_output: from .user_interaction import get_terminal_width @@ -191,6 +191,7 @@ class sys_command():#Thread): # And print the new output we're peaking on: sys.stdout.write(output) sys.stdout.flush() + return True def run(self): self.status = 'running' diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index 185ec1d6..009a3a6c 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -91,6 +91,7 @@ def cpuVendor()-> Optional[str]: if info.get('field',None): if info.get('field',None) == "Vendor ID:": return info.get('data',None) + return None def isVM() -> bool: try: diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py index 06d99778..d6a197f1 100644 --- a/archinstall/lib/output.py +++ b/archinstall/lib/output.py @@ -19,7 +19,7 @@ class journald(dict): @abc.abstractmethod def log(message, level=logging.DEBUG): try: - import systemd.journal + import systemd.journal # type: ignore except ModuleNotFoundError: return False diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 06237c1c..1feba1cd 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -1,3 +1,4 @@ +from typing import Optional import os, urllib.request, urllib.parse, ssl, json, re import importlib.util, sys, glob, hashlib, logging from collections import OrderedDict @@ -49,7 +50,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof except urllib.error.HTTPError as err: print(f'Error: Listing profiles on URL "{profiles_url}" resulted in:', err) return cache - except: + except json.decoder.JSONDecodeError as err: print(f'Error: Could not decode "{profiles_url}" result as JSON:', err) return cache @@ -215,7 +216,7 @@ class Profile(Script): return True @property - def packages(self) -> list: + def packages(self) -> Optional[list]: """ Returns a list of packages baked into the profile definition. If no package definition has been done, .packages() will return None. diff --git a/examples/__init__.py b/examples/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/profiles/__init__.py b/profiles/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/profiles/applications/__init__.py b/profiles/applications/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/setup.py b/setup.py index a4f49f92..8b95d978 100644 --- a/setup.py +++ b/setup.py @@ -1,2 +1,2 @@ -import setuptools +import setuptools # type: ignore setuptools.setup() -- cgit v1.2.3-54-g00ecf From af3d65cc98632042b3b0ef62cfc27553261ec3b0 Mon Sep 17 00:00:00 2001 From: advaithm Date: Wed, 12 May 2021 16:08:49 +0530 Subject: removed .vscode --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index d2a6c127..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "/usr/bin/python" -} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 4ff35663b80e1bb40c44d4ceee85700ef428cab0 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 12 May 2021 13:55:41 +0200 Subject: Replaced the magic __builtin__ global variable. This should fix mypy complaints while still retaining the same functionality, kinda. It's less automatic but it's also less of dark magic, which makes sense for anyone but me. --- archinstall/lib/installer.py | 9 +-------- profiles/52-54-00-12-34-56.py | 2 +- profiles/applications/awesome.py | 8 ++++---- profiles/applications/cockpit.py | 4 ++-- profiles/applications/docker.py | 4 ++-- profiles/applications/httpd.py | 4 ++-- profiles/applications/lighttpd.py | 4 ++-- profiles/applications/mariadb.py | 6 +++--- profiles/applications/nginx.py | 4 ++-- profiles/applications/postgresql.py | 6 +++--- profiles/applications/sshd.py | 4 ++-- profiles/applications/tomcat.py | 4 ++-- profiles/awesome.py | 12 ++++++------ profiles/budgie.py | 6 +++--- profiles/cinnamon.py | 6 +++--- profiles/deepin.py | 6 +++--- profiles/desktop.py | 8 +++----- profiles/gnome.py | 6 +++--- profiles/i3.py | 10 +++++----- profiles/kde.py | 6 +++--- profiles/lxqt.py | 6 +++--- profiles/mate.py | 6 +++--- profiles/server.py | 2 +- profiles/sway.py | 4 ++-- profiles/xfce4.py | 6 +++--- profiles/xorg.py | 22 ++++++---------------- 26 files changed, 73 insertions(+), 92 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 331762b4..e5120ff1 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -452,14 +452,7 @@ class Installer(): return self.pacstrap(*packages) def install_profile(self, profile): - # TODO: Replace this with a import archinstall.session instead in the profiles. - # The tricky thing with doing the import archinstall.session instead is that - # profiles might be run from a different chroot, and there's no way we can - # guarantee file-path safety when accessing the installer object that way. - # Doing the __builtins__ replacement, ensures that the global variable "installation" - # is always kept up to date. It's considered a nasty hack - but it's a safe way - # of ensuring 100% accuracy of archinstall session variables. - __builtins__['installation'] = self + storage['installation_session'] = self if type(profile) == str: profile = Profile(self, profile) diff --git a/profiles/52-54-00-12-34-56.py b/profiles/52-54-00-12-34-56.py index a3347760..28cd14f6 100644 --- a/profiles/52-54-00-12-34-56.py +++ b/profiles/52-54-00-12-34-56.py @@ -5,7 +5,7 @@ import urllib.request __packages__ = ['nano', 'wget', 'git'] if __name__ == '52-54-00-12-34-56': - awesome = archinstall.Application(installation, 'postgresql') + awesome = archinstall.Application(archinstall.storage['installation_session'], 'postgresql') awesome.install() """ diff --git a/profiles/applications/awesome.py b/profiles/applications/awesome.py index a63c707b..d5a8e793 100644 --- a/profiles/applications/awesome.py +++ b/profiles/applications/awesome.py @@ -2,11 +2,11 @@ import archinstall __packages__ = ["awesome", "xorg-xrandr", "xterm", "feh", "slock", "terminus-font", "gnu-free-fonts", "ttf-liberation", "xsel"] -installation.install_profile('xorg') +archinstall.storage['installation_session'].install_profile('xorg') -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -with open(f'{installation.target}/etc/X11/xinit/xinitrc', 'r') as xinitrc: +with open(f"{archinstall.storage['installation_session'].target}/etc/X11/xinit/xinitrc", 'r') as xinitrc: xinitrc_data = xinitrc.read() for line in xinitrc_data.split('\n'): @@ -20,5 +20,5 @@ for line in xinitrc_data.split('\n'): xinitrc_data += '\n' xinitrc_data += 'exec awesome\n' -with open(f'{installation.target}/etc/X11/xinit/xinitrc', 'w') as xinitrc: +with open(f"{archinstall.storage['installation_session'].target}/etc/X11/xinit/xinitrc", 'w') as xinitrc: xinitrc.write(xinitrc_data) diff --git a/profiles/applications/cockpit.py b/profiles/applications/cockpit.py index f1cea1d2..8a0ede9d 100644 --- a/profiles/applications/cockpit.py +++ b/profiles/applications/cockpit.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["cockpit", "udisks2", "packagekit"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('cockpit.socket') +archinstall.storage['installation_session'].enable_service('cockpit.socket') diff --git a/profiles/applications/docker.py b/profiles/applications/docker.py index afa3f8fb..afbde1a5 100644 --- a/profiles/applications/docker.py +++ b/profiles/applications/docker.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["docker"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('docker') +archinstall.storage['installation_session'].enable_service('docker') diff --git a/profiles/applications/httpd.py b/profiles/applications/httpd.py index 00d64b6e..23b3fefa 100644 --- a/profiles/applications/httpd.py +++ b/profiles/applications/httpd.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["apache"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('httpd') +archinstall.storage['installation_session'].enable_service('httpd') diff --git a/profiles/applications/lighttpd.py b/profiles/applications/lighttpd.py index a1e6a371..71158861 100644 --- a/profiles/applications/lighttpd.py +++ b/profiles/applications/lighttpd.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["lighttpd"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('lighttpd') +archinstall.storage['installation_session'].enable_service('lighttpd') diff --git a/profiles/applications/mariadb.py b/profiles/applications/mariadb.py index e458a45a..bdde18b5 100644 --- a/profiles/applications/mariadb.py +++ b/profiles/applications/mariadb.py @@ -4,8 +4,8 @@ import archinstall # which packages will be installed by this profile __packages__ = ["mariadb"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.arch_chroot("mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql") +archinstall.storage['installation_session'].arch_chroot("mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql") -installation.enable_service('mariadb') +archinstall.storage['installation_session'].enable_service('mariadb') diff --git a/profiles/applications/nginx.py b/profiles/applications/nginx.py index 50eb0506..6f63b15c 100644 --- a/profiles/applications/nginx.py +++ b/profiles/applications/nginx.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["nginx"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('nginx') +archinstall.storage['installation_session'].enable_service('nginx') diff --git a/profiles/applications/postgresql.py b/profiles/applications/postgresql.py index fcdce824..3f8c6950 100644 --- a/profiles/applications/postgresql.py +++ b/profiles/applications/postgresql.py @@ -4,8 +4,8 @@ import archinstall # which packages will be installed by this profile __packages__ = ["postgresql"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.arch_chroot("initdb -D /var/lib/postgres/data", runas='postgres') +archinstall.storage['installation_session'].arch_chroot("initdb -D /var/lib/postgres/data", runas='postgres') -installation.enable_service('postgresql') \ No newline at end of file +archinstall.storage['installation_session'].enable_service('postgresql') \ No newline at end of file diff --git a/profiles/applications/sshd.py b/profiles/applications/sshd.py index 234638d5..4199ecb0 100644 --- a/profiles/applications/sshd.py +++ b/profiles/applications/sshd.py @@ -4,6 +4,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["openssh"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('sshd') +archinstall.storage['installation_session'].enable_service('sshd') diff --git a/profiles/applications/tomcat.py b/profiles/applications/tomcat.py index 9c521390..ae6d1c2a 100644 --- a/profiles/applications/tomcat.py +++ b/profiles/applications/tomcat.py @@ -7,6 +7,6 @@ import archinstall # which packages will be installed by this profile __packages__ = ["tomcat10"] -installation.add_additional_packages(__packages__) +archinstall.storage['installation_session'].add_additional_packages(__packages__) -installation.enable_service('tomcat10') +archinstall.storage['installation_session'].enable_service('tomcat10') diff --git a/profiles/awesome.py b/profiles/awesome.py index a5dedccd..8ee113f4 100644 --- a/profiles/awesome.py +++ b/profiles/awesome.py @@ -30,23 +30,23 @@ def _prep_function(*args, **kwargs): # or through conventional import awesome if __name__ == 'awesome': # Install the application awesome from the template under /applications/ - awesome = archinstall.Application(installation, 'awesome') + awesome = archinstall.Application(archinstall.storage['installation_session'], 'awesome') awesome.install() - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) # TODO: Copy a full configuration to ~/.config/awesome/rc.lua instead. - with open(f'{installation.target}/etc/xdg/awesome/rc.lua', 'r') as fh: + with open(f'{archinstall.storage['installation_session'].target}/etc/xdg/awesome/rc.lua', 'r') as fh: awesome_lua = fh.read() ## Replace xterm with alacritty for a smoother experience. awesome_lua = awesome_lua.replace('"xterm"', '"alacritty"') - with open(f'{installation.target}/etc/xdg/awesome/rc.lua', 'w') as fh: + with open(f'{archinstall.storage['installation_session'].target}/etc/xdg/awesome/rc.lua', 'w') as fh: fh.write(awesome_lua) ## TODO: Configure the right-click-menu to contain the above packages that were installed. (as a user config) ## Remove some interfering nemo settings - installation.arch_chroot("gsettings set org.nemo.desktop show-desktop-icons false") - installation.arch_chroot("xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search") + archinstall.storage['installation_session'].arch_chroot("gsettings set org.nemo.desktop show-desktop-icons false") + archinstall.storage['installation_session'].arch_chroot("xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search") diff --git a/profiles/budgie.py b/profiles/budgie.py index fc061cd2..dbbd3a9d 100644 --- a/profiles/budgie.py +++ b/profiles/budgie.py @@ -28,9 +28,9 @@ def _prep_function(*args, **kwargs): # or through conventional import budgie if __name__ == 'budgie': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the Budgie packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/cinnamon.py b/profiles/cinnamon.py index 4ca9cfed..89798671 100644 --- a/profiles/cinnamon.py +++ b/profiles/cinnamon.py @@ -27,9 +27,9 @@ def _prep_function(*args, **kwargs): # or through conventional import cinnamon if __name__ == 'cinnamon': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the Cinnamon packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/deepin.py b/profiles/deepin.py index ce59a699..47fbe13f 100644 --- a/profiles/deepin.py +++ b/profiles/deepin.py @@ -28,10 +28,10 @@ def _prep_function(*args, **kwargs): # or through conventional import deepin if __name__ == 'deepin': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the Deepin packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) # Enable autostart of Deepin for all users - installation.enable_service('lightdm') + archinstall.storage['installation_session'].enable_service('lightdm') diff --git a/profiles/desktop.py b/profiles/desktop.py index 2aea6d30..d4c13239 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -48,9 +48,7 @@ if __name__ == 'desktop': """ # Install common packages for all desktop environments - installation.add_additional_packages(__packages__) - - # TODO: Remove magic variable 'installation' and place it - # in archinstall.storage or archinstall.session/archinstall.installation - installation.install_profile(archinstall.storage['_desktop_profile']) + archinstall.storage['installation_session'].add_additional_packages(__packages__) + + archinstall.storage['installation_session'].install_profile(archinstall.storage['_desktop_profile']) diff --git a/profiles/gnome.py b/profiles/gnome.py index 77c90859..e6cc75c0 100644 --- a/profiles/gnome.py +++ b/profiles/gnome.py @@ -29,11 +29,11 @@ def _prep_function(*args, **kwargs): # or through conventional import gnome if __name__ == 'gnome': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the GNOME packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('gdm') # Gnome Display Manager + archinstall.storage['installation_session'].enable_service('gdm') # Gnome Display Manager # We could also start it via xinitrc since we do have Xorg, # but for gnome that's deprecated and wayland is preferred. diff --git a/profiles/i3.py b/profiles/i3.py index 8492d36f..e99bc549 100644 --- a/profiles/i3.py +++ b/profiles/i3.py @@ -48,16 +48,16 @@ if __name__ == 'i3': """ # Install common packages for all i3 configurations - installation.add_additional_packages(__packages__[:4]) + archinstall.storage['installation_session'].add_additional_packages(__packages__[:4]) # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # gaps is installed by deafult so we are overriding it here with lightdm - installation.add_additional_packages(__packages__[4:]) + archinstall.storage['installation_session'].add_additional_packages(__packages__[4:]) # Auto start lightdm for all users - installation.enable_service('lightdm') + archinstall.storage['installation_session'].enable_service('lightdm') # install the i3 group now - installation.add_additional_packages(archinstall.storage['_i3_configuration']) + archinstall.storage['installation_session'].add_additional_packages(archinstall.storage['_i3_configuration']) diff --git a/profiles/kde.py b/profiles/kde.py index c8efdcde..aac5ade4 100644 --- a/profiles/kde.py +++ b/profiles/kde.py @@ -37,10 +37,10 @@ def _post_install(*args, **kwargs): # or through conventional import kde if __name__ == 'kde': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the KDE packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) # Enable autostart of KDE for all users - installation.enable_service('sddm') + archinstall.storage['installation_session'].enable_service('sddm') diff --git a/profiles/lxqt.py b/profiles/lxqt.py index d0727a90..025d033d 100644 --- a/profiles/lxqt.py +++ b/profiles/lxqt.py @@ -28,9 +28,9 @@ def _prep_function(*args, **kwargs): # or through conventional import lxqt if __name__ == 'lxqt': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the LXQt packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('sddm') # SDDM Display Manager + archinstall.storage['installation_session'].enable_service('sddm') # SDDM Display Manager diff --git a/profiles/mate.py b/profiles/mate.py index 2cfe7305..e2421ed8 100644 --- a/profiles/mate.py +++ b/profiles/mate.py @@ -27,9 +27,9 @@ def _prep_function(*args, **kwargs): # or through conventional import mate if __name__ == 'mate': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the MATE packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/server.py b/profiles/server.py index 9d28054d..d0346ace 100644 --- a/profiles/server.py +++ b/profiles/server.py @@ -24,7 +24,7 @@ if __name__ == 'server': archinstall.log(archinstall.storage['_selected_servers'], level=logging.DEBUG) for server in archinstall.storage['_selected_servers']: archinstall.log(f'Installing {server} ...', level=logging.INFO) - app = archinstall.Application(installation, server) + app = archinstall.Application(archinstall.storage['installation_session'], server) app.install() archinstall.log('If your selections included multiple servers with the same port, you may have to reconfigure them.', fg="yellow", level=logging.INFO) diff --git a/profiles/sway.py b/profiles/sway.py index 8e256a87..e90e5e8d 100644 --- a/profiles/sway.py +++ b/profiles/sway.py @@ -44,7 +44,7 @@ if __name__ == "sway": ) # Install the Sway packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) # Install the graphics driver packages - installation.add_additional_packages(_gfx_driver_packages) + archinstall.storage['installation_session'].add_additional_packages(_gfx_driver_packages) diff --git a/profiles/xfce4.py b/profiles/xfce4.py index 8102919b..43da23ac 100644 --- a/profiles/xfce4.py +++ b/profiles/xfce4.py @@ -28,9 +28,9 @@ def _prep_function(*args, **kwargs): # or through conventional import xfce4 if __name__ == 'xfce4': # Install dependency profiles - installation.install_profile('xorg') + archinstall.storage['installation_session'].install_profile('xorg') # Install the XFCE4 packages - installation.add_additional_packages(__packages__) + archinstall.storage['installation_session'].add_additional_packages(__packages__) - installation.enable_service('lightdm') # Light Display Manager + archinstall.storage['installation_session'].enable_service('lightdm') # Light Display Manager diff --git a/profiles/xorg.py b/profiles/xorg.py index 7546a01b..19ca92d7 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -28,22 +28,12 @@ def _prep_function(*args, **kwargs): if __name__ == 'xorg': try: if "nvidia" in _gfx_driver_packages: - if "linux-zen" in installation.base_packages or "linux-lts" in installation.base_packages: - installation.add_additional_packages("dkms")#I've had kernel regen fail if it wasn't installed before nvidia-dkms - installation.add_additional_packages("xorg-server xorg-xinit nvidia-dkms") + if "linux-zen" in archinstall.storage['installation_session'].base_packages or "linux-lts" in archinstall.storage['installation_session'].base_packages: + archinstall.storage['installation_session'].add_additional_packages("dkms")#I've had kernel regen fail if it wasn't installed before nvidia-dkms + archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit nvidia-dkms") else: - installation.add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") else: - installation.add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") except: - installation.add_additional_packages(f"xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install - - # with open(f'{installation.mountpoint}/etc/X11/xinit/xinitrc', 'a') as X11: - # X11.write('setxkbmap se\n') - - # with open(f'{installation.mountpoint}/etc/vconsole.conf', 'a') as vconsole: - # vconsole.write('KEYMAP={keyboard_layout}\n'.format(**arguments)) - # vconsole.write('FONT=lat9w-16\n') - - # awesome = archinstall.Application(installation, 'awesome') - # awesome.install() \ No newline at end of file + archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 1674b7088d66873712dea57f99d3221daad4db0b Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 14 May 2021 16:13:03 +0200 Subject: Fixes string index error. --- archinstall/lib/profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 1feba1cd..9225a129 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -36,7 +36,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof description = '' with open(os.path.join(root, file), 'r') as fh: first_line = fh.readline() - if first_line[0] == '#': + if len(first_line) and first_line[0] == '#': description = first_line[1:].strip() cache[file[:-3]] = {'path' : os.path.join(root, file), 'description' : description, 'tailored' : tailored} -- cgit v1.2.3-54-g00ecf From 22750cefc89e6439d14a5df105af17e4e85eb3cc Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 14 May 2021 16:55:47 +0200 Subject: Quotation error. --- profiles/awesome.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/profiles/awesome.py b/profiles/awesome.py index 8ee113f4..7b305eb2 100644 --- a/profiles/awesome.py +++ b/profiles/awesome.py @@ -36,13 +36,13 @@ if __name__ == 'awesome': archinstall.storage['installation_session'].add_additional_packages(__packages__) # TODO: Copy a full configuration to ~/.config/awesome/rc.lua instead. - with open(f'{archinstall.storage['installation_session'].target}/etc/xdg/awesome/rc.lua', 'r') as fh: + with open(f"{archinstall.storage['installation_session'].target}/etc/xdg/awesome/rc.lua", 'r') as fh: awesome_lua = fh.read() ## Replace xterm with alacritty for a smoother experience. awesome_lua = awesome_lua.replace('"xterm"', '"alacritty"') - with open(f'{archinstall.storage['installation_session'].target}/etc/xdg/awesome/rc.lua', 'w') as fh: + with open(f"{archinstall.storage['installation_session'].target}/etc/xdg/awesome/rc.lua", 'w') as fh: fh.write(awesome_lua) ## TODO: Configure the right-click-menu to contain the above packages that were installed. (as a user config) -- cgit v1.2.3-54-g00ecf