index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | archinstall/__init__.py | 6 | ||||
-rw-r--r-- | archinstall/lib/disk/filesystem.py | 12 | ||||
-rw-r--r-- | archinstall/lib/disk/user_guides.py | 12 | ||||
-rw-r--r-- | archinstall/lib/user_interaction.py | 4 | ||||
-rw-r--r-- | docs/installing/guided.rst | 6 | ||||
-rw-r--r-- | examples/disk_layouts-sample.json | 6 | ||||
-rw-r--r-- | examples/only_hd.py | 24 |
diff --git a/archinstall/__init__.py b/archinstall/__init__.py index c0e9b8bd..f4793555 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -169,6 +169,12 @@ def post_process_arguments(arguments): if not json_stream_to_structure('--disk_layouts',arguments['disk_layouts'],layout_storage): exit(1) else: + # backward compatibility. Change partition.format for partition.wipe + for disk in layout_storage: + for i,partition in enumerate(layout_storage[disk].get('partitions',[])): + if 'format' in partition: + partition['wipe'] = partition['format'] + del partition['format'] arguments['disk_layouts'] = layout_storage diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index b5dcdf85..64b8008c 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -7,7 +7,7 @@ from typing import Optional, Dict, Any, TYPE_CHECKING # https://stackoverflow.com/a/39757388/929999 if TYPE_CHECKING: from .blockdevice import BlockDevice - + from .partition import Partition from .validators import valid_fs_type from ..exceptions import DiskError @@ -76,7 +76,7 @@ class Filesystem: # We then iterate the partitions in order for partition in layout.get('partitions', []): # We don't want to re-add an existing partition (those containing a UUID already) - if partition.get('format', False) and not partition.get('PARTUUID', None): + if partition.get('wipe', False) and not partition.get('PARTUUID', None): print("Adding partition....") partition['device_instance'] = self.add_partition(partition.get('type', 'primary'), start=partition.get('start', '1MiB'), # TODO: Revisit sane block starts (4MB for memorycards for instance) @@ -113,11 +113,11 @@ class Filesystem: loopdev = f"{storage.get('ENC_IDENTIFIER', 'ai')}{pathlib.Path(partition['mountpoint']).name}loop" else: loopdev = f"{storage.get('ENC_IDENTIFIER', 'ai')}{pathlib.Path(partition['device_instance'].path).name}" - + partition['device_instance'].encrypt(password=partition['!password']) # Immediately unlock the encrypted device to format the inner volume with luks2(partition['device_instance'], loopdev, partition['!password'], auto_unmount=True) as unlocked_device: - if not partition.get('format'): + if not partition.get('wipe'): if storage['arguments'] == 'silent': raise ValueError(f"Missing fs-type to format on newly created encrypted partition {partition['device_instance']}") else: @@ -133,7 +133,7 @@ class Filesystem: break unlocked_device.format(partition['filesystem']['format'], options=format_options) - elif partition.get('format', False): + elif partition.get('wipe', False): if not partition['device_instance']: raise DiskError(f"Internal error caused us to loose the partition. Please report this issue upstream!") @@ -150,7 +150,7 @@ class Filesystem: def partprobe(self) -> bool: result = SysCommand(f'partprobe {self.blockdevice.device}') - + if result.exit_code != 0: log(f"Could not execute partprobe: {result!r}", level=logging.ERROR, fg="red") raise DiskError(f"Could not run partprobe: {result!r}") diff --git a/archinstall/lib/disk/user_guides.py b/archinstall/lib/disk/user_guides.py index 4ba22b4f..25db14ea 100644 --- a/archinstall/lib/disk/user_guides.py +++ b/archinstall/lib/disk/user_guides.py @@ -46,7 +46,7 @@ def suggest_single_disk_layout(block_device :BlockDevice, "size" : "203MiB", "boot" : True, "encrypted" : False, - "format" : True, + "wipe" : True, "mountpoint" : "/boot", "filesystem" : { "format" : "fat32" @@ -65,7 +65,7 @@ def suggest_single_disk_layout(block_device :BlockDevice, "type" : "primary", "start" : "206MiB", "encrypted" : False, - "format" : True, + "wipe" : True, "mountpoint" : "/" if not using_subvolumes else None, "filesystem" : { "format" : default_filesystem @@ -114,7 +114,7 @@ def suggest_single_disk_layout(block_device :BlockDevice, "start" : f"{min(block_device.size, 20)}GiB", "size" : "100%", "encrypted" : False, - "format" : True, + "wipe" : True, "mountpoint" : "/home", "filesystem" : { "format" : default_filesystem @@ -166,7 +166,7 @@ def suggest_multi_disk_layout(block_devices :List[BlockDevice], "size" : "203MiB", "boot" : True, "encrypted" : False, - "format" : True, + "wipe" : True, "mountpoint" : "/boot", "filesystem" : { "format" : "fat32" @@ -183,7 +183,7 @@ def suggest_multi_disk_layout(block_devices :List[BlockDevice], "start" : "206MiB", "size" : "100%", "encrypted" : False, - "format" : True, + "wipe" : True, "mountpoint" : "/", "filesystem" : { "format" : default_filesystem @@ -198,7 +198,7 @@ def suggest_multi_disk_layout(block_devices :List[BlockDevice], "start" : "1MiB", "size" : "100%", "encrypted" : False, - "format" : True, + "wipe" : True, "mountpoint" : "/home", "filesystem" : { "format" : default_filesystem diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 0ce19346..d5cd9257 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -661,7 +661,7 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> Dict[str, A block_device_struct["partitions"][partition]['mountpoint'] = mountpoint if mountpoint == '/boot': log(f"Marked partition as bootable because mountpoint was set to /boot.", fg="yellow") - block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['boot'] = True + block_device_struct["partitions"][partition]['boot'] = True else: del(block_device_struct["partitions"][partition]['mountpoint']) @@ -682,7 +682,7 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> Dict[str, A block_device_struct["partitions"][partition]['filesystem']['format'] = fstype # Negate the current wipe marking - block_device_struct["partitions"][partition]['format'] = not block_device_struct["partitions"][partition].get('format', False) + block_device_struct["partitions"][partition]['wipe'] = not block_device_struct["partitions"][partition].get('wipe', False) elif task == "Mark/Unmark a partition as encrypted": title = f'{current_layout}\n\nSelect which partition to mark as encrypted' diff --git a/docs/installing/guided.rst b/docs/installing/guided.rst index 99f7d814..5c360256 100644 --- a/docs/installing/guided.rst +++ b/docs/installing/guided.rst @@ -194,7 +194,7 @@ Options for ``--disk_layouts`` "filesystem": { "format": "fat32" }, - "format": true, + "wipe": true, "mountpoint": "/boot", "size": "513MB", "start": "5MB", @@ -213,7 +213,7 @@ Options for ``--disk_layouts`` "filesystem": { "format": "btrfs" }, - "format": true, + "wipe": true, "mountpoint": "/", "size": "100%", "start": "518MB", @@ -245,4 +245,4 @@ Options for ``--disk_layouts`` | type | primary | Only used if MBR and BIOS is used. Marks what kind of partition it is. | No | +----------------------+-----------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ | btrfs | { "subvolumes": {"subvolume": "mountpoint"}} | Support for btrfs subvolumes for a given partition | No | -+----------------------+-----------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+
\ No newline at end of file ++----------------------+-----------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------+ diff --git a/examples/disk_layouts-sample.json b/examples/disk_layouts-sample.json index ca10415c..ebb47c82 100644 --- a/examples/disk_layouts-sample.json +++ b/examples/disk_layouts-sample.json @@ -7,7 +7,7 @@ "filesystem": { "format": "fat32" }, - "format": true, + "wipe": true, "mountpoint": "/boot", "size": "513MB", "start": "5MB", @@ -26,7 +26,7 @@ "filesystem": { "format": "btrfs" }, - "format": true, + "wipe": true, "mountpoint": "/", "size": "100%", "start": "518MB", @@ -35,4 +35,4 @@ ], "wipe": true } -}
\ No newline at end of file +} diff --git a/examples/only_hd.py b/examples/only_hd.py index 962787ba..755e00f5 100644 --- a/examples/only_hd.py +++ b/examples/only_hd.py @@ -42,8 +42,8 @@ def ask_harddrives(): if input("Do you wish to continue ? [Y/n]").strip().lower() == 'n': exit(1) else: - if archinstall.storage.get('disk_layouts', None) is None: - archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives'], archinstall.arguments.get('advanced', False)) + if archinstall.arguments.get('disk_layouts', None) is None: + archinstall.arguments['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives'], archinstall.arguments.get('advanced', False)) # Get disk encryption password (or skip if blank) if archinstall.arguments.get('!encryption-password', None) is None: @@ -53,8 +53,8 @@ def ask_harddrives(): if archinstall.arguments.get('!encryption-password', None): # If no partitions was marked as encrypted, but a password was supplied and we have some disks to format.. # Then we need to identify which partitions to encrypt. This will default to / (root). - if len(list(archinstall.encrypted_partitions(archinstall.storage['disk_layouts']))) == 0: - archinstall.storage['disk_layouts'] = archinstall.select_encrypted_partitions(archinstall.storage['disk_layouts'], archinstall.arguments['!encryption-password']) + if len(list(archinstall.encrypted_partitions(archinstall.arguments['disk_layouts']))) == 0: + archinstall.arguments['disk_layouts'] = archinstall.select_encrypted_partitions(archinstall.arguments['disk_layouts'], archinstall.arguments['!encryption-password']) # Ask which boot-loader to use (will only ask if we're in BIOS (non-efi) mode) if not archinstall.arguments.get("bootloader", None): @@ -121,8 +121,8 @@ def save_user_configurations(): with open("/var/log/archinstall/user_configuration.json", "w") as config_file: config_file.write(user_configuration) - if archinstall.storage.get('disk_layouts'): - user_disk_layout = json.dumps(archinstall.storage['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON) + if archinstall.arguments.get('disk_layouts'): + user_disk_layout = json.dumps(archinstall.arguments['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON) with open("/var/log/archinstall/user_disk_layout.json", "w") as disk_layout_file: disk_layout_file.write(user_disk_layout) @@ -135,14 +135,14 @@ def write_config_files(): user_configuration = json.dumps({**archinstall.arguments, 'version' : archinstall.__version__} , indent=4, sort_keys=True, cls=archinstall.JSON) archinstall.log(user_configuration, level=logging.INFO) - if archinstall.storage.get('disk_layouts'): - user_disk_layout = json.dumps(archinstall.storage['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON) + if archinstall.arguments.get('disk_layouts'): + user_disk_layout = json.dumps(archinstall.arguments['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON) archinstall.log(user_disk_layout, level=logging.INFO) print() save_user_configurations() - if archinstall.arguments.get('dry-run'): + if archinstall.arguments.get('dry_run'): exit(0) @@ -164,7 +164,7 @@ def perform_disk_operations(): mode = archinstall.MBR for drive in archinstall.arguments.get('harddrives', []): - if dl_disk := archinstall.storage.get('disk_layouts', {}).get(drive.path): + if dl_disk := archinstall.arguments.get('disk_layouts', {}).get(drive.path): with archinstall.Filesystem(drive, mode) as fs: fs.load_layout(dl_disk) @@ -177,8 +177,8 @@ def perform_installation(mountpoint): with archinstall.Installer(mountpoint, kernels=None) as installation: # Mount all the drives to the desired mountpoint # This *can* be done outside of the installation, but the installer can deal with it. - if archinstall.storage.get('disk_layouts'): - installation.mount_ordered_layout(archinstall.storage['disk_layouts']) + if archinstall.arguments.get('disk_layouts'): + installation.mount_ordered_layout(archinstall.arguments['disk_layouts']) # Placing /boot check during installation because this will catch both re-use and wipe scenarios. for partition in installation.partitions: |