From 7ac68b2436b3a542d8004b26defb89ebb2905fa9 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Mar 2021 13:54:01 +0100 Subject: Removed redundant error handling as well as added some more debug logs. --- examples/guided.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 9339f969..74d413aa 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -305,8 +305,8 @@ def perform_installation(device, boot_partition, language, mirrors): if archinstall.arguments.get('packages', None) and archinstall.arguments.get('packages', None)[0] != '': installation.add_additional_packages(archinstall.arguments.get('packages', None)) - if archinstall.arguments.get('profile', None) and len(profile := archinstall.arguments.get('profile').strip()): - installation.install_profile(profile) + if archinstall.arguments.get('profile', None): + installation.install_profile(archinstall.arguments.get('profile', None)) if archinstall.arguments.get('users', None): for user in archinstall.arguments.get('users'): -- cgit v1.2.3-70-g09d2 From 37b1e618280c8b428824f202902e392792e10c18 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Mar 2021 14:00:52 +0100 Subject: Corrected some spelling errors and wrong variables. --- archinstall/lib/user_interaction.py | 6 +++--- examples/guided.py | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 7e7f5873..ab2b19bc 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -31,7 +31,7 @@ def ask_for_superuser_account(prompt='Create a required super-user with sudo pri raise UserError("No superuser was created.") password = get_password(prompt=f'Password for user {new_user}: ') - return {new_user: password} + return {new_user: {"!password" : password}} def ask_for_additional_users(prompt='Any additional users to install (leave blank for no users): '): users = {} @@ -44,9 +44,9 @@ 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 sudo (super) user (y/N): ").strip(' ').lower() in ('y', 'yes'): - super_users[new_user] = password + super_users[new_user] = {"!password" : password} else: - users[new_user] = password + users[new_user] = {"!password" : password} return users, super_users diff --git a/examples/guided.py b/examples/guided.py index 74d413aa..4e6aaf34 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -308,15 +308,11 @@ def perform_installation(device, boot_partition, language, mirrors): if archinstall.arguments.get('profile', None): installation.install_profile(archinstall.arguments.get('profile', None)) - if archinstall.arguments.get('users', None): - for user in archinstall.arguments.get('users'): - password = users[user] - installation.user_create(user, password, sudo=False) - if archinstall.arguments.get('superusers', None): - for user in archinstall.arguments.get('users'): - password = users[user] - installation.user_create(user, password, sudo=Tru) - + for user, user_info in archinstall.arguments.get('users', {}).items(): + installation.user_create(user, user_info["!password"], sudo=False) + + for superuser, user_info in archinstall.arguments.get('superusers', {}).items(): + installation.user_create(superuser, user_info["!password"], sudo=True) if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw): installation.user_set_pw('root', root_pw) -- cgit v1.2.3-70-g09d2 From b495b3328e81983e88f9ada072916d16e897910c Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Mar 2021 15:22:25 +0100 Subject: Added error handling for unlocking an old partition (autodetect feature). --- examples/guided.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 4e6aaf34..40ac7ca8 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -91,7 +91,11 @@ def ask_user_questions(): new_filesystem = input(f"Enter a valid filesystem for {partition} (leave blank for {partition.filesystem}): ").strip(' ') if len(new_filesystem) <= 0: if partition.encrypted and partition.filesystem == 'crypto_LUKS': - if (autodetected_filesystem := partition.detect_inner_filesystem(archinstall.arguments.get('!encryption-password', None))): + old_password = archinstall.arguments.get('!encryption-password', None) + if not old_password: + old_password = input(f'Enter the old encryption password for {partition}: ') + + if (autodetected_filesystem := partition.detect_inner_filesystem(old_password)): new_filesystem = autodetected_filesystem else: archinstall.log(f"Could not auto-detect the filesystem inside the encrypted volume.", fg='red') -- cgit v1.2.3-70-g09d2 From 502968b579160b4df9f5cbd66c8f6e96c2f8d2b4 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Mar 2021 15:28:46 +0100 Subject: Added some error handling to disk encryption passwords. --- examples/guided.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 40ac7ca8..96243a1b 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -94,7 +94,7 @@ def ask_user_questions(): old_password = archinstall.arguments.get('!encryption-password', None) if not old_password: old_password = input(f'Enter the old encryption password for {partition}: ') - + if (autodetected_filesystem := partition.detect_inner_filesystem(old_password)): new_filesystem = autodetected_filesystem else: @@ -134,8 +134,9 @@ def ask_user_questions(): # Get disk encryption password (or skip if blank) if not archinstall.arguments.get('!encryption-password', None): - archinstall.arguments['!encryption-password'] = archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ') - archinstall.arguments['harddrive'].encryption_password = archinstall.arguments['!encryption-password'] + if passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): '): + archinstall.arguments['!encryption-password'] = passwd + archinstall.arguments['harddrive'].encryption_password = archinstall.arguments['!encryption-password'] # Get the hostname for the machine if not archinstall.arguments.get('hostname', None): -- cgit v1.2.3-70-g09d2 From 32ab44e6dab9c2374fa65a1d76af5ab0fa746ce6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Mar 2021 15:32:22 +0100 Subject: More error handling to encrypted vs not encrypted partitions. --- examples/guided.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 96243a1b..cf3610a1 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -248,8 +248,11 @@ def perform_installation_steps(): # which ones are safe to format, and format those. for partition in archinstall.arguments['harddrive']: if partition.safe_to_format(): - if partition.encrypted: - partition.encrypt(password=archinstall.arguments.get('!encryption-password', None)) + # Partition might be marked as encrypted due to the filesystem type crypt_LUKS + # But we might have omitted the encryption password question to skip encryption. + # In which case partition.encrypted will be true, but passwd will be false. + if partition.encrypted and passwd := archinstall.arguments.get('!encryption-password', None): + partition.encrypt(password=passwd) else: partition.format() else: -- cgit v1.2.3-70-g09d2 From 51cbec58da9b0695d0a4805ef31bc065c560b344 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Mar 2021 15:32:52 +0100 Subject: Spelling error. --- 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 cf3610a1..0816f3bf 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -251,7 +251,7 @@ def perform_installation_steps(): # Partition might be marked as encrypted due to the filesystem type crypt_LUKS # But we might have omitted the encryption password question to skip encryption. # In which case partition.encrypted will be true, but passwd will be false. - if partition.encrypted and passwd := archinstall.arguments.get('!encryption-password', None): + if partition.encrypted and (passwd := archinstall.arguments.get('!encryption-password', None)): partition.encrypt(password=passwd) else: partition.format() -- cgit v1.2.3-70-g09d2 From 54200bf476d004721a03c89ce1916fc7c79124a2 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Mar 2021 15:39:52 +0100 Subject: Removed evil .format(ext4) which was a remenant from the old days. --- examples/guided.py | 1 - 1 file changed, 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 0816f3bf..87f46b35 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -270,7 +270,6 @@ def perform_installation_steps(): language=archinstall.arguments['keyboard-language'], mirrors=archinstall.arguments['mirror-region']) else: - archinstall.arguments['harddrive'].partition[1].format('ext4') perform_installation(device=fs.find_partition('/'), boot_partition=fs.find_partition('/boot'), language=archinstall.arguments['keyboard-language'], -- cgit v1.2.3-70-g09d2 From 61504fc9270c24cac088bbf18fb6d623462ce790 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 20 Mar 2021 17:12:53 +0100 Subject: Fixed #101. Now warns the users after they skip the network configuration. --- examples/guided.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 87f46b35..655fc29f 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -187,6 +187,8 @@ def ask_user_questions(): # Ask or Call the helper function that asks the user to optionally configure a network. if not archinstall.arguments.get('nic', None): archinstall.arguments['nic'] = archinstall.ask_to_configure_network() + if not archinstall.arguments['nic']: + archinstall.log(f"No network configuration was selected. Network is going to be unavailable until configured manually!", fg="yellow") def perform_installation_steps(): -- cgit v1.2.3-70-g09d2 From b67257233f43fa8d34dacd6ecc3dc7cbbf60d221 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 20 Mar 2021 17:26:48 +0100 Subject: Fixed #64. installation.set_timezone() already excisted since earlier versions of archinstall in the library section. The guided.py example simply never asked for a time-zone. There's still no NTP option, which I'll add in later. Mostly because there's a lot of settings one can do to a time-client configuration, and I'm not sure all users want the default time servers etc. --- archinstall/lib/installer.py | 5 +++-- archinstall/lib/user_interaction.py | 7 ++++++- examples/guided.py | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 39e3447d..2604e77d 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1,4 +1,4 @@ -import os, stat, time, shutil +import os, stat, time, shutil, pathlib from .exceptions import * from .disk import * @@ -171,7 +171,8 @@ class Installer(): def set_timezone(self, zone, *args, **kwargs): if not len(zone): return True - o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} ln -s /usr/share/zoneinfo/{zone} /etc/localtime')) + (pathlib.Path(self.mountpoint)/"etc"/"localtime").unlink(missing_ok=True) + sys_command(f'/usr/bin/arch-chroot {self.mountpoint} ln -s /usr/share/zoneinfo/{zone} /etc/localtime') return True def activate_ntp(self): diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index ab2b19bc..6b3e5faa 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -1,4 +1,4 @@ -import getpass +import getpass, pathlib from .exceptions import * from .profiles import Profile from .locale_helpers import search_keyboard_layout @@ -50,6 +50,11 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan return users, super_users +def ask_for_a_timezone(): + timezone = input('Enter a valid timezone (Example: Europe/Stockholm): ').strip() + if pathlib.Path(timezone).exists(): + return timezone + def ask_to_configure_network(): # Optionally configure one network interface. #while 1: diff --git a/examples/guided.py b/examples/guided.py index 655fc29f..e9edac09 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -190,6 +190,9 @@ def ask_user_questions(): if not archinstall.arguments['nic']: archinstall.log(f"No network configuration was selected. Network is going to be unavailable until configured manually!", fg="yellow") + if not archinstall.arguments.get('timezone', None): + archinstall.arguments['timezone'] = archinstall.ask_for_a_timezone() + def perform_installation_steps(): global SIG_TRIGGER @@ -323,6 +326,9 @@ def perform_installation(device, boot_partition, language, mirrors): for superuser, user_info in archinstall.arguments.get('superusers', {}).items(): installation.user_create(superuser, user_info["!password"], sudo=True) + if (timezone := archinstall.arguments.get('timezone', None)): + installation.set_timezone(timezone) + if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw): installation.user_set_pw('root', root_pw) -- cgit v1.2.3-70-g09d2 From a75002a36d2e98d5618d88ac372fb9b5ed3575bf Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 21 Mar 2021 11:12:07 +0100 Subject: Fixed an issue where brand new disks (no partitions), got protected by a safety measurement where .keep_partitions were set to True by default. --- examples/guided.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index e9edac09..b6aa5810 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -131,6 +131,11 @@ def ask_user_questions(): elif option == 'format-all': archinstall.arguments['filesystem'] = archinstall.ask_for_main_filesystem_format() archinstall.arguments['harddrive'].keep_partitions = False + else: + # If the drive doesn't have any partitions, safely mark the disk with keep_partitions = False + # and ask the user for a root filesystem. + archinstall.arguments['filesystem'] = archinstall.ask_for_main_filesystem_format() + archinstall.arguments['harddrive'].keep_partitions = False # Get disk encryption password (or skip if blank) if not archinstall.arguments.get('!encryption-password', None): -- cgit v1.2.3-70-g09d2 From a3aef119b24201078857e605f2b62c7f6000e91a Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 21 Mar 2021 21:30:52 +0100 Subject: Improved english grammar and dialogues. Some 'questions' were formatted in a way where the user would enter 'yes' instead of the expected input. For instance, 'Any additional users to install:' which is a question where 'yes' is a appropriate response, but the expected input was the username to be created. Rephrased it to 'Enter a username to create a additional user:' instead for instance. --- archinstall/lib/user_interaction.py | 8 ++++---- examples/guided.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 296fa8db..c883d6a3 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -136,7 +136,7 @@ def ask_for_main_filesystem_format(): 'vfat' : 'vfat' } - value = generic_select(options.values(), "Select your main partitions filesystem by number or free-text: ") + value = generic_select(options.values(), "Select which filesystem your main partition should use (by number of name): ") return next((key for key, val in options.items() if val == value), None) def generic_select(options, input_text="Select one of the above by index or absolute value: ", sort=True): @@ -212,10 +212,10 @@ def select_profile(options): for index, profile in enumerate(profiles): print(f"{index}: {profile}") - print(' -- The above list is pre-programmed profiles. --') + print(' -- The above list is a set of pre-programmed profiles. --') print(' -- They might make it easier to install things like desktop environments. --') - print(' -- (Leave blank to skip this next optional step) --') - selected_profile = input('Any particular pre-programmed profile you want to install: ') + print(' -- (Leave blank and hit enter to skip this step and continue) --') + selected_profile = input('Enter a pre-programmed profile name if you want to install one: ') if len(selected_profile.strip()) <= 0: return None diff --git a/examples/guided.py b/examples/guided.py index b6aa5810..4766301e 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -53,7 +53,7 @@ def ask_user_questions(): # 3. Check that we support the current partitions # 2. If so, ask if we should keep them or wipe everything if archinstall.arguments['harddrive'].has_partitions(): - archinstall.log(f"{archinstall.arguments['harddrive']} contains the following partitions:", fg='red') + archinstall.log(f"{archinstall.arguments['harddrive']} contains the following partitions:", fg='yellow') # We curate a list pf supported paritions # and print those that we don't support. @@ -149,7 +149,7 @@ def ask_user_questions(): # Ask for a root password (optional, but triggers requirement for super-user if skipped) if not archinstall.arguments.get('!root-password', None): - archinstall.arguments['!root-password'] = archinstall.get_password(prompt='Enter root password (Recommended: leave blank to leave root disabled): ') + 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'] = {} @@ -157,7 +157,7 @@ def ask_user_questions(): if not archinstall.arguments.get('!root-password', 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('Any additional users to install (leave blank for no users): ') + 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} @@ -180,7 +180,7 @@ def ask_user_questions(): # Additional packages (with some light weight error handling for invalid package names) if not archinstall.arguments.get('packages', None): - archinstall.arguments['packages'] = [package for package in input('Additional packages aside from base (space separated): ').split(' ') if len(package)] + archinstall.arguments['packages'] = [package for package in input('Write additional packages to install (space separated, leave blank to skip): ').split(' ') if len(package)] # Verify packages that were given try: -- cgit v1.2.3-70-g09d2 From a156f224a87a02d6b0f9a54eef2ce18e418e5187 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 29 Mar 2021 08:56:41 +0200 Subject: Fixing un-encrypted drives matching on block encrypted. --- archinstall/lib/disk.py | 5 +++-- examples/guided.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index c1db3dc9..85b08bc0 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -142,7 +142,8 @@ class Partition(): self.target_mountpoint = mountpoint self.filesystem = filesystem self.size = size # TODO: Refresh? - self._encrypted = encrypted + self._encrypted = None + self.encrypted = encrypted self.allow_formatting = False # A fail-safe for unconfigured partitions, such as windows NTFS partitions. if mountpoint: @@ -161,7 +162,7 @@ class Partition(): self.filesystem = fstype if self.filesystem == 'crypto_LUKS': - self._encrypted = True + self.encrypted = True def __lt__(self, left_comparitor): if type(left_comparitor) == Partition: diff --git a/examples/guided.py b/examples/guided.py index 4766301e..d9dfe0df 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -292,6 +292,7 @@ def perform_installation(device, boot_partition, language, mirrors): Only requirement is that the block devices are formatted and setup prior to entering this function. """ + print('Installing on:', device) with archinstall.Installer(device, boot_partition=boot_partition, hostname=archinstall.arguments.get('hostname', 'Archinstall')) as installation: ## if len(mirrors): # Certain services might be running that affects the system during installation. -- cgit v1.2.3-70-g09d2 From ed565e13481cce7ac3b640f0ad933605f6ad63c3 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 29 Mar 2021 09:33:58 +0200 Subject: Adding some overclarification to encryption checks. --- examples/guided.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index d9dfe0df..009f9fa6 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -139,7 +139,7 @@ def ask_user_questions(): # Get disk encryption password (or skip if blank) if not archinstall.arguments.get('!encryption-password', None): - if passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): '): + if (passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ')).strip(): archinstall.arguments['!encryption-password'] = passwd archinstall.arguments['harddrive'].encryption_password = archinstall.arguments['!encryption-password'] @@ -292,7 +292,6 @@ def perform_installation(device, boot_partition, language, mirrors): Only requirement is that the block devices are formatted and setup prior to entering this function. """ - print('Installing on:', device) with archinstall.Installer(device, boot_partition=boot_partition, hostname=archinstall.arguments.get('hostname', 'Archinstall')) as installation: ## if len(mirrors): # Certain services might be running that affects the system during installation. -- cgit v1.2.3-70-g09d2 From 36dfa2e1c42add691243850b62b705b26a0a796c Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 29 Mar 2021 10:20:35 +0200 Subject: Reverting .strip() logic and moving the check into the get_password() function. --- archinstall/lib/user_interaction.py | 4 ++++ examples/guided.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index a79b4847..bee7b569 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -24,6 +24,10 @@ def get_password(prompt="Enter a password: "): if passwd != passwd_verification: log(' * Passwords did not match * ', bg='black', fg='red') continue + + if len(passwd.strip()) <= 0: + break + return passwd return None diff --git a/examples/guided.py b/examples/guided.py index 009f9fa6..92331450 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -139,7 +139,7 @@ def ask_user_questions(): # Get disk encryption password (or skip if blank) if not archinstall.arguments.get('!encryption-password', None): - if (passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ')).strip(): + if (passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ')): archinstall.arguments['!encryption-password'] = passwd archinstall.arguments['harddrive'].encryption_password = archinstall.arguments['!encryption-password'] -- cgit v1.2.3-70-g09d2 From a29bd759548c02c609aa43d9536475b1259a70f9 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 29 Mar 2021 17:46:07 +0200 Subject: Removing a flush of the cache that was excessive. --- archinstall/lib/disk.py | 25 ++----------------------- examples/guided.py | 8 ++++---- 2 files changed, 6 insertions(+), 27 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 3e512034..4e70a4a5 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -130,21 +130,7 @@ class BlockDevice(): return False def flush_cache(self): - old_partitions = {**self.partitions} - self.part_cache = OrderedDict() - # Trigger a refresh of the cache - if len(self.partitions): - pass - - # Carry over any flags from the previous partitions - for partition in old_partitions: - if partition in self.part_cache: - if self.part_cache[partition].size == old_partitions[partition].size and \ - self.part_cache[partition].filesystem == old_partitions[partition].filesystem: - print('Carrying over', self.part_cache[partition].target_mountpoint, self.part_cache[partition].allow_formatting) - self.part_cache[partition].target_mountpoint = old_partitions[partition].target_mountpoint - self.part_cache[partition].allow_formatting = old_partitions[partition].allow_formatting class Partition(): def __init__(self, path :str, block_device :BlockDevice, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False, autodetect_filesystem=True): @@ -341,9 +327,7 @@ class Partition(): else: raise UnknownFilesystemFormat(f"Fileformat '{filesystem}' is not yet implemented.") - # self.encrypted = False if self.filesystem != 'crypto_LUKS' else True - if self.block_device: - self.block_device.flush_cache() + self.encrypted = False if self.filesystem != 'crypto_LUKS' else True return True @@ -460,7 +444,7 @@ class Filesystem(): """ return self.raw_parted(string).exit_code - def use_entire_disk(self, root_filesystem_type='ext4', encrypt_root_partition=True): + def use_entire_disk(self, root_filesystem_type='ext4'): log(f"Using and formatting the entire {self.blockdevice}.", level=LOG_LEVELS.Debug) self.add_partition('primary', start='1MiB', end='513MiB', format='fat32') self.set_name(0, 'EFI') @@ -480,11 +464,6 @@ class Filesystem(): self.blockdevice.partition[0].allow_formatting = True self.blockdevice.partition[1].allow_formatting = True - if encrypt_root_partition: - log(f"Marking partition {self.blockdevice.partition[1]} as encrypted.", level=LOG_LEVELS.Debug) - - self.blockdevice.partition[1].encrypted = True - def add_partition(self, type, start, end, format=None): log(f'Adding partition to {self.blockdevice}', level=LOG_LEVELS.Info) diff --git a/examples/guided.py b/examples/guided.py index 92331450..71e1e01d 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -247,10 +247,10 @@ def perform_installation_steps(): with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs: # Wipe the entire drive if the disk flag `keep_partitions`is False. if archinstall.arguments['harddrive'].keep_partitions is False: - fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get('filesystem', 'btrfs'), - encrypt_root_partition=archinstall.arguments.get('!encryption-password', False)) - # Otherwise, check if encryption is desired and mark the root partition as encrypted. - elif archinstall.arguments.get('!encryption-password', None): + fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get('filesystem', 'btrfs')) + + # Check if encryption is desired and mark the root partition as encrypted. + if archinstall.arguments.get('!encryption-password', None): root_partition = fs.find_partition('/') root_partition.encrypted = True -- cgit v1.2.3-70-g09d2