From 995edaf316ab42cec5adbc50b32c133ae2ec77b6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 12 Sep 2021 15:42:13 +0200 Subject: Removed legacy need to add_bootloader `add_bootloader` no longer needs to have a harddrive given as a argument. It will (and should) auto-detect what's mounted in the `self.target` (aka mountpoint) of the installation. --- archinstall/lib/installer.py | 13 +++++++------ examples/guided.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 3efb0499..f206946c 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -429,7 +429,7 @@ class Installer: return True - def add_bootloader(self, _device, bootloader='systemd-bootctl'): + def add_bootloader(self, bootloader='systemd-bootctl'): for plugin in plugins.values(): if hasattr(plugin, 'on_add_bootloader'): # Allow plugins to override the boot-loader handling. @@ -535,14 +535,15 @@ class Installer: SysCommand(f"/usr/bin/arch-chroot {self.target} {enable_CRYPTODISK} {_file}") if has_uefi(): - self.pacstrap('efibootmgr') - o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB')) - SysCommand('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') + self.pacstrap('efibootmgr') # TODO: Do we need? + SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB') + SysCommand(f'/usr/bin/arch-chroot {self.target} grub-mkconfig -o /boot/grub/grub.cfg') self.helper_flags['bootloader'] = True return True else: - o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc --recheck {_device.path}')) - SysCommand('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') + boot_partition = filesystem.find_partition(mountpoint=f"{self.target}/boot") + SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc --recheck {boot_partition.path}') + SysCommand(f'/usr/bin/arch-chroot {self.target} grub-mkconfig -o /boot/grub/grub.cfg') self.helper_flags['bootloader'] = True else: raise RequirementError(f"Unknown (or not yet implemented) bootloader requested: {bootloader}") diff --git a/examples/guided.py b/examples/guided.py index 4e6d1bc5..3dd30875 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -269,7 +269,7 @@ def perform_installation(mountpoint): installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium if archinstall.arguments["bootloader"] == "grub-install" and has_uefi(): installation.add_additional_packages("grub") - installation.add_bootloader(archinstall.arguments["harddrive"], archinstall.arguments["bootloader"]) + installation.add_bootloader(archinstall.arguments["bootloader"]) # If user selected to copy the current ISO network configuration # Perform a copy of the config -- cgit v1.2.3-54-g00ecf From 168379d43dce60e71e999722aa6a49fd5679891f Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 13 Sep 2021 14:55:09 +0000 Subject: Added --noconfirm to pacstrap and increased logging verbosity when packages fail, and adding a exception so that the installation doesn't continue silently. This causes too much confusion (even tho I liked the idea that people could recover the missing parts without having to re-run the installer for subsequent steps. --- archinstall/lib/installer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 3efb0499..cb5b24a0 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -163,10 +163,12 @@ class Installer: self.log(f'Installing packages: {packages}', level=logging.INFO) if (sync_mirrors := SysCommand('/usr/bin/pacman -Syy')).exit_code == 0: - if (pacstrap := SysCommand(f'/usr/bin/pacstrap {self.target} {" ".join(packages)}', peak_output=True)).exit_code == 0: + if (pacstrap := SysCommand(f'/usr/bin/pacstrap --noconfirm {self.target} {" ".join(packages)}', peak_output=True)).exit_code == 0: return True else: - self.log(f'Could not strap in packages: {pacstrap.exit_code}', level=logging.INFO) + self.log(f'Could not strap in packages: {pacstrap}', level=logging.ERROR, fg="red") + self.log(f'Could not strap in packages: {pacstrap.exit_code}', level=logging.ERROR, fg="red") + raise RequirementError("Pacstrap failed. See /var/log/archinstall/install.log or above message for error details.") else: self.log(f'Could not sync mirrors: {sync_mirrors.exit_code}', level=logging.INFO) -- cgit v1.2.3-54-g00ecf From 6d2a2f327c874f38233d6f52bc27d5678586567a Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 14 Sep 2021 11:47:16 +0000 Subject: Moved --noconfirm at the end of the pacstrap command to get piped properly to pacman inside pacstrap. --- 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 1ade75b3..62dc933d 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -163,7 +163,7 @@ class Installer: self.log(f'Installing packages: {packages}', level=logging.INFO) if (sync_mirrors := SysCommand('/usr/bin/pacman -Syy')).exit_code == 0: - if (pacstrap := SysCommand(f'/usr/bin/pacstrap --noconfirm {self.target} {" ".join(packages)}', peak_output=True)).exit_code == 0: + if (pacstrap := SysCommand(f'/usr/bin/pacstrap {self.target} {" ".join(packages)} --noconfirm', peak_output=True)).exit_code == 0: return True else: self.log(f'Could not strap in packages: {pacstrap}', level=logging.ERROR, fg="red") -- cgit v1.2.3-54-g00ecf From 7d3f2b6f29082d179212a494a12089cb2bf05802 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 14 Sep 2021 14:07:50 +0000 Subject: Added a 'hidden' variable called --disk-sleep for delaying disk partition up time before continuing after a format. This is an ugly hack to get around some disk issues, for now. --- archinstall/lib/disk.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index c86bf7bc..a700c2a0 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -921,7 +921,9 @@ class Filesystem: time.sleep(0.025) - time.sleep(0.5) # Let the kernel catch up with quick block devices (nvme for instance) + # Todo: Find a better way to detect if the new UUID of the partition has showed up. + # But this will address (among other issues) + time.sleep(float(storage['arguments'].get('disk-sleep', 2.0))) # Let the kernel catch up with quick block devices (nvme for instance) return self.blockdevice.get_partition(uuid=(previous_partition_uuids ^ {partition.uuid for partition in self.blockdevice.partitions.values()}).pop()) def set_name(self, partition: int, name: str): -- cgit v1.2.3-54-g00ecf From c09a36b7b166cc5cf74e5c25e8c9b200f4f2088a Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 13:33:34 +0000 Subject: Changed from internal storage to parameter-friendly arguments for disk_layouts, so we can support JSON for disk layouts on the new logic. --- examples/guided.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index 3dd30875..7574f39f 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -102,7 +102,7 @@ def ask_user_questions(): allow_empty=True) if archinstall.arguments.get('harddrives', None): - archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives']) + archinstall.arguments['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives']) # Get disk encryption password (or skip if blank) if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None) is None: @@ -112,8 +112,8 @@ def ask_user_questions(): if archinstall.arguments['harddrives'] and 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): @@ -207,7 +207,7 @@ def perform_filesystem_operations(): archinstall.log(user_configuration, level=logging.INFO) with open("/var/log/archinstall/user_configuration.json", "w") as config_file: config_file.write(user_configuration) - user_disk_layout = json.dumps(archinstall.storage['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON) + 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) with open("/var/log/archinstall/user_disk_layout.json", "w") as disk_layout_file: disk_layout_file.write(user_disk_layout) @@ -238,7 +238,7 @@ def perform_filesystem_operations(): for drive in archinstall.arguments['harddrives']: with archinstall.Filesystem(drive, mode) as fs: - fs.load_layout(archinstall.storage['disk_layouts'][drive]) + fs.load_layout(archinstall.arguments['disk_layouts'][drive]) def perform_installation(mountpoint): @@ -250,7 +250,7 @@ def perform_installation(mountpoint): with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', 'linux')) 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. - installation.mount_ordered_layout(archinstall.storage['disk_layouts']) + installation.mount_ordered_layout(archinstall.arguments['disk_layouts']) # if len(mirrors): # Certain services might be running that affects the system during installation. -- cgit v1.2.3-54-g00ecf From 8dd097da0524d8a3e2d784ab7821a08e051b82cf Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 17:36:54 +0200 Subject: Reverted last change, and improved it. By passing it through load_config and tweaking the read structure a bit, it worked out better if the accessed values are in archinstall.storage instead. --- examples/guided.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index 7574f39f..0813e2ef 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -51,6 +51,9 @@ def load_config(): archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) if archinstall.arguments.get('servers', None) is not None: archinstall.storage['_selected_servers'] = archinstall.arguments.get('servers', None) + if archinstall.arguments.get('disk_layouts', None) is not None: + archinstall.storage['disk_layouts'] = {archinstall.BlockDevice(disk) : struct for disk, struct in archinstall.arguments['disk_layouts']} + def ask_user_questions(): """ @@ -102,7 +105,7 @@ def ask_user_questions(): allow_empty=True) if archinstall.arguments.get('harddrives', None): - archinstall.arguments['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives']) + archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives']) # Get disk encryption password (or skip if blank) if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None) is None: @@ -112,8 +115,8 @@ def ask_user_questions(): if archinstall.arguments['harddrives'] and 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.arguments['disk_layouts']))) == 0: - archinstall.arguments['disk_layouts'] = archinstall.select_encrypted_partitions(archinstall.arguments['disk_layouts'], archinstall.arguments['!encryption-password']) + 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']) # Ask which boot-loader to use (will only ask if we're in BIOS (non-efi) mode) if not archinstall.arguments.get("bootloader", None): @@ -207,7 +210,7 @@ def perform_filesystem_operations(): archinstall.log(user_configuration, level=logging.INFO) with open("/var/log/archinstall/user_configuration.json", "w") as config_file: config_file.write(user_configuration) - user_disk_layout = json.dumps(archinstall.arguments['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON) + user_disk_layout = json.dumps(archinstall.storage['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON) archinstall.log(user_disk_layout, level=logging.INFO) with open("/var/log/archinstall/user_disk_layout.json", "w") as disk_layout_file: disk_layout_file.write(user_disk_layout) @@ -238,7 +241,7 @@ def perform_filesystem_operations(): for drive in archinstall.arguments['harddrives']: with archinstall.Filesystem(drive, mode) as fs: - fs.load_layout(archinstall.arguments['disk_layouts'][drive]) + fs.load_layout(archinstall.storage['disk_layouts'][drive]) def perform_installation(mountpoint): @@ -250,7 +253,7 @@ def perform_installation(mountpoint): with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', 'linux')) 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. - installation.mount_ordered_layout(archinstall.arguments['disk_layouts']) + installation.mount_ordered_layout(archinstall.storage['disk_layouts']) # if len(mirrors): # Certain services might be running that affects the system during installation. -- cgit v1.2.3-54-g00ecf From d6acfec799280b764bf50e1623fb4608cc9a7742 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 19:01:14 +0200 Subject: Updating support for --disk_layouts. It now supports file paths as well as JSON in string format via --disk_layouts= --- examples/guided.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/guided.py b/examples/guided.py index 0813e2ef..a3c0db2d 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,6 +1,7 @@ import json import logging import os +import pathlib import time import archinstall @@ -52,6 +53,14 @@ def load_config(): if archinstall.arguments.get('servers', None) is not None: archinstall.storage['_selected_servers'] = archinstall.arguments.get('servers', None) if archinstall.arguments.get('disk_layouts', None) is not None: + if (dl_path := pathlib.Path(archinstall.arguments['disk_layouts'])).exists() and str(dl_path).endswith('.json'): + with open(dl_path) as fh: + archinstall.arguments['disk_layouts'] = json.load(fh) + else: + try: + archinstall.arguments['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts']) + except: + raise ValueError("--disk_layouts= needs either a JSON file or a JSON string given with a valid disk layout.") archinstall.storage['disk_layouts'] = {archinstall.BlockDevice(disk) : struct for disk, struct in archinstall.arguments['disk_layouts']} -- cgit v1.2.3-54-g00ecf From 1a7056efc40a336a855be353f549af0eb7e0fca9 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 19:09:57 +0200 Subject: Might be redundant, but if the JSON file given to --config contains a list it will break the .split(), but if --harddrives is given as an argument, then we need to split. So adding a type-check --- examples/guided.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/guided.py b/examples/guided.py index a3c0db2d..e5cf2d38 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -29,7 +29,9 @@ archinstall.log(f"Disk states before installing: {archinstall.disk_layouts()}", def load_config(): if archinstall.arguments.get('harddrives', None) is not None: - archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives'].split(',')] + if type(archinstall.arguments['harddrives']) is str: + archinstall.arguments['harddrives'] = archinstall.arguments['harddrives'].split(',') + archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives']] # Temporarily disabling keep_partitions if config file is loaded # Temporary workaround to make Desktop Environments work if archinstall.arguments.get('profile', None) is not None: -- cgit v1.2.3-54-g00ecf From 2cfbafc6534ebcca7e8d52be263aed4d54c04914 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 19:16:30 +0200 Subject: More error handling and fixed a spelling error. --- examples/guided.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index e5cf2d38..10f4c9eb 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -56,14 +56,17 @@ def load_config(): archinstall.storage['_selected_servers'] = archinstall.arguments.get('servers', None) if archinstall.arguments.get('disk_layouts', None) is not None: if (dl_path := pathlib.Path(archinstall.arguments['disk_layouts'])).exists() and str(dl_path).endswith('.json'): - with open(dl_path) as fh: - archinstall.arguments['disk_layouts'] = json.load(fh) + try: + with open(dl_path) as fh: + archinstall.arguments['disk_layouts'] = json.load(fh) + except Exception as e: + raise ValueError(f"--disk_layouts does not contain a valid JSON format: {e}") else: try: archinstall.arguments['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts']) except: raise ValueError("--disk_layouts= needs either a JSON file or a JSON string given with a valid disk layout.") - archinstall.storage['disk_layouts'] = {archinstall.BlockDevice(disk) : struct for disk, struct in archinstall.arguments['disk_layouts']} + archinstall.storage['disk_layouts'] = {archinstall.BlockDevice(disk) : struct for disk, struct in archinstall.arguments['disk_layouts'].items()} def ask_user_questions(): -- cgit v1.2.3-54-g00ecf From e6549c1edbb63e255a8a6d971953bbbe1ab2d3c5 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 19:17:32 +0200 Subject: Fixing type issue with conversion to multiple disk logic. --- examples/guided.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/guided.py b/examples/guided.py index 10f4c9eb..b3f1b14b 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -112,7 +112,9 @@ def ask_user_questions(): # Ask which harddrives/block-devices we will install to # and convert them into archinstall.BlockDevice() objects. if archinstall.arguments.get('harddrives', None): - archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives'].split(',')] + if type(archinstall.arguments['harddrives']) is str: + archinstall.arguments['harddrives'] = archinstall.arguments['harddrives'].split(',') + archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives']] else: archinstall.arguments['harddrives'] = archinstall.generic_multi_select(archinstall.all_disks(), text="Select one or more harddrives to use and configure (leave blank to skip this step): ", -- cgit v1.2.3-54-g00ecf From 70af00f33dd903e1bc70a996854861038a2d919c Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 19:23:35 +0200 Subject: Tweaked the logic for parsing the --harddrives parameter. --- examples/guided.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index b3f1b14b..b0f6f699 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -113,8 +113,7 @@ def ask_user_questions(): # and convert them into archinstall.BlockDevice() objects. if archinstall.arguments.get('harddrives', None): if type(archinstall.arguments['harddrives']) is str: - archinstall.arguments['harddrives'] = archinstall.arguments['harddrives'].split(',') - archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives']] + archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives'].split(',')] else: archinstall.arguments['harddrives'] = archinstall.generic_multi_select(archinstall.all_disks(), text="Select one or more harddrives to use and configure (leave blank to skip this step): ", -- cgit v1.2.3-54-g00ecf From 9e67ce3f05bb813c997c3c2bc874c4d6ed83c5d6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 20:11:40 +0200 Subject: Making sure the drive paths are in the JSON structure, and not the class object, as it won't work seamlessly to access for instance storage['disk_layouts'][ClassInstance()] if it's not the identical mem copy of the object we're accessing, so strings are better for storage/comparisons. --- archinstall/lib/disk.py | 18 +++++++++--------- archinstall/lib/user_interaction.py | 2 +- examples/guided.py | 16 +++++----------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index a700c2a0..3628a4b0 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -114,13 +114,13 @@ def suggest_single_disk_layout(block_device): MIN_SIZE_TO_ALLOW_HOME_PART = 40 # Gb layout = { - block_device : { + block_device.path : { "wipe" : True, "partitions" : [] } } - layout[block_device]['partitions'].append({ + layout[block_device.path]['partitions'].append({ # Boot "type" : "primary", "start" : "1MiB", @@ -133,7 +133,7 @@ def suggest_single_disk_layout(block_device): "format" : "fat32" } }) - layout[block_device]['partitions'].append({ + layout[block_device.path]['partitions'].append({ # Root "type" : "primary", "start" : "513MiB", @@ -147,7 +147,7 @@ def suggest_single_disk_layout(block_device): }) if block_device.size >= MIN_SIZE_TO_ALLOW_HOME_PART: - layout[block_device]['partitions'].append({ + layout[block_device.path]['partitions'].append({ # Home "type" : "primary", "encrypted" : False, @@ -175,17 +175,17 @@ def suggest_multi_disk_layout(block_devices): log(f"Suggesting multi-disk-layout using {len(block_devices)} disks, where {root_device} will be /root and {home_device} will be /home", level=logging.DEBUG) layout = { - root_device : { + root_device.path : { "wipe" : True, "partitions" : [] }, - home_device : { + home_device.path : { "wipe" : True, "partitions" : [] }, } - layout[root_device]['partitions'].append({ + layout[root_device.path]['partitions'].append({ # Boot "type" : "primary", "start" : "1MiB", @@ -198,7 +198,7 @@ def suggest_multi_disk_layout(block_devices): "format" : "fat32" } }) - layout[root_device]['partitions'].append({ + layout[root_device.path]['partitions'].append({ # Root "type" : "primary", "start" : "513MiB", @@ -211,7 +211,7 @@ def suggest_multi_disk_layout(block_devices): } }) - layout[home_device]['partitions'].append({ + layout[home_device.path]['partitions'].append({ # Home "type" : "primary", "encrypted" : False, diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index b017e41a..6854ccfd 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -751,7 +751,7 @@ def select_individual_blockdevice_usage(block_devices :list): for device in block_devices: layout = manage_new_and_existing_partitions(device) - result[device] = layout + result[device.path] = layout return result diff --git a/examples/guided.py b/examples/guided.py index b0f6f699..b7c75b30 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -58,16 +58,14 @@ def load_config(): if (dl_path := pathlib.Path(archinstall.arguments['disk_layouts'])).exists() and str(dl_path).endswith('.json'): try: with open(dl_path) as fh: - archinstall.arguments['disk_layouts'] = json.load(fh) + archinstall.storage['disk_layouts'] = json.load(fh) except Exception as e: raise ValueError(f"--disk_layouts does not contain a valid JSON format: {e}") else: try: - archinstall.arguments['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts']) + archinstall.storage['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts']) except: raise ValueError("--disk_layouts= needs either a JSON file or a JSON string given with a valid disk layout.") - archinstall.storage['disk_layouts'] = {archinstall.BlockDevice(disk) : struct for disk, struct in archinstall.arguments['disk_layouts'].items()} - def ask_user_questions(): """ @@ -111,15 +109,12 @@ def ask_user_questions(): # Ask which harddrives/block-devices we will install to # and convert them into archinstall.BlockDevice() objects. - if archinstall.arguments.get('harddrives', None): - if type(archinstall.arguments['harddrives']) is str: - archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives'].split(',')] - else: + if archinstall.arguments.get('harddrives', None) is None: archinstall.arguments['harddrives'] = archinstall.generic_multi_select(archinstall.all_disks(), text="Select one or more harddrives to use and configure (leave blank to skip this step): ", allow_empty=True) - if archinstall.arguments.get('harddrives', None): + if archinstall.arguments.get('harddrives', None) is not None and archinstall.storage.get('disk_layouts', None) is None: archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives']) # Get disk encryption password (or skip if blank) @@ -256,8 +251,7 @@ def perform_filesystem_operations(): for drive in archinstall.arguments['harddrives']: with archinstall.Filesystem(drive, mode) as fs: - fs.load_layout(archinstall.storage['disk_layouts'][drive]) - + fs.load_layout(archinstall.storage['disk_layouts'][drive.path]) def perform_installation(mountpoint): """ -- cgit v1.2.3-54-g00ecf From ffc43bc0411c71f84fa1c7e52204c2b20e311429 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 15 Sep 2021 22:17:30 +0200 Subject: Adding linux -headers for nvidia-dkms This should address #585, as I don't see any nvidia-dkms other than when linux-zen and linux-lts is chosen, I chose to put the -headers logic in the same section. If this is needed for vanilla `linux` kernel as well, then move the logic one line up. --- profiles/xorg.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/profiles/xorg.py b/profiles/xorg.py index ce13664d..b8f33068 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -39,6 +39,8 @@ if __name__ == 'xorg': try: if "nvidia" in archinstall.storage.get("gfx_driver_packages", None): if "linux-zen" in archinstall.storage['installation_session'].base_packages or "linux-lts" in archinstall.storage['installation_session'].base_packages: + for kernel in archinstall.storage['installation_session'].kernels: + archinstall.storage['installation_session'].add_additional_packages(f"{kernel}-headers") # Fixes https://github.com/archlinux/archinstall/issues/585 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: -- cgit v1.2.3-54-g00ecf From b4481506ff41ef057643be62f9f0526999f40891 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 17 Sep 2021 17:28:46 +0200 Subject: Added gvfs to fix "trash" in xfce4 https://wiki.archlinux.org/title/Xfce#Trash_icon_not_visible_and_trash_applet_does_not_work --- profiles/xfce4.py | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/xfce4.py b/profiles/xfce4.py index 8dbb04ec..ef0ddf2f 100644 --- a/profiles/xfce4.py +++ b/profiles/xfce4.py @@ -10,6 +10,7 @@ __packages__ = [ "pavucontrol", "lightdm", "lightdm-gtk-greeter", + "gvfs", ] -- cgit v1.2.3-54-g00ecf From e21cf77e77119cc894ab6893a96cfd361106fc15 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 17 Sep 2021 23:52:10 +0200 Subject: Removing /tmp from fstab Since systemd takes care of mounting /tmp as a tmpt, there's no point in having a manual entry in fstab. --- archinstall/lib/installer.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 62dc933d..2aac8510 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -403,9 +403,6 @@ class Installer: self.pacstrap(self.base_packages) self.helper_flags['base-strapped'] = True - with open(f"{self.target}/etc/fstab", "a") as fstab: - fstab.write("\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n") # Redundant \n at the start? who knows? - # TODO: Support locale and timezone # os.remove(f'{self.target}/etc/localtime') # sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime') -- cgit v1.2.3-54-g00ecf From f6ceb8bba64db220ebfc4046bc2fd69da7185327 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 18 Sep 2021 10:37:55 +0200 Subject: Removing hardcoded btrfs for suggested partition layouts. --- archinstall/lib/disk.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 3628a4b0..872d9bfc 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -110,7 +110,11 @@ def select_disk_larger_than_or_close_to(devices, gigabytes, filter_out=None): return min(copy_devices, key=(lambda device : abs(device.size - gigabytes))) -def suggest_single_disk_layout(block_device): +def suggest_single_disk_layout(block_device, default_filesystem=None): + if not default_filesystem: + from .user_interaction import ask_for_main_filesystem_format + default_filesystem = ask_for_main_filesystem_format() + MIN_SIZE_TO_ALLOW_HOME_PART = 40 # Gb layout = { @@ -142,7 +146,7 @@ def suggest_single_disk_layout(block_device): "size" : "100%" if block_device.size < MIN_SIZE_TO_ALLOW_HOME_PART else f"{min(block_device.size, 20)*1024}MiB", "mountpoint" : "/", "filesystem" : { - "format" : "btrfs" + "format" : default_filesystem } }) @@ -156,14 +160,18 @@ def suggest_single_disk_layout(block_device): "size" : "100%", "mountpoint" : "/home", "filesystem" : { - "format" : "btrfs" + "format" : default_filesystem } }) return layout -def suggest_multi_disk_layout(block_devices): +def suggest_multi_disk_layout(block_devices, default_filesystem=None): + if not default_filesystem: + from .user_interaction import ask_for_main_filesystem_format + default_filesystem = ask_for_main_filesystem_format() + MIN_SIZE_TO_ALLOW_HOME_PART = 40 # Gb ARCH_LINUX_INSTALLED_SIZE = 20 # Gb, rough estimate taking in to account user desktops etc. TODO: Catch user packages to detect size? @@ -207,7 +215,7 @@ def suggest_multi_disk_layout(block_devices): "size" : "100%", "mountpoint" : "/", "filesystem" : { - "format" : "btrfs" + "format" : default_filesystem } }) @@ -220,7 +228,7 @@ def suggest_multi_disk_layout(block_devices): "size" : "100%", "mountpoint" : "/home", "filesystem" : { - "format" : "btrfs" + "format" : default_filesystem } }) -- cgit v1.2.3-54-g00ecf From a93225d1de74d871d57451caaf1dfab125aff0ec Mon Sep 17 00:00:00 2001 From: Falieri <90856747+falieri@users.noreply.github.com> Date: Sat, 18 Sep 2021 10:36:42 -0300 Subject: Update xfce4.py add network support to the xfce panel --- profiles/xfce4.py | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/xfce4.py b/profiles/xfce4.py index ef0ddf2f..89c04f7c 100644 --- a/profiles/xfce4.py +++ b/profiles/xfce4.py @@ -11,6 +11,7 @@ __packages__ = [ "lightdm", "lightdm-gtk-greeter", "gvfs", + "network-manager-applet", ] -- cgit v1.2.3-54-g00ecf From ffe38c879acf59da3f9d25ba866608ff6d6db64d Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Sun, 19 Sep 2021 15:49:44 +0300 Subject: general: remove all found white-spaces Also this change adds new line at the end for some scripts --- CONTRIBUTING.md | 3 +-- README.md | 1 - archinstall/lib/disk.py | 2 +- archinstall/lib/plugins.py | 2 +- archinstall/lib/user_interaction.py | 14 +++++++------- examples/guided.py | 4 ++-- setup.cfg | 2 +- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a92cff91..ca4aa9e3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,7 @@ # Contributing to archinstall Any contributions through pull requests are welcome as this project aims to be a community based project to ease some Arch Linux installation steps. -Bear in mind that in the future this repo might be transferred to the official [GitLab repo under Arch Linux](http://gitlab.archlinux.org/archlinux/) - *(if GitLab becomes open to the general public)*. +Bear in mind that in the future this repo might be transferred to the official [GitLab repo under Arch Linux](http://gitlab.archlinux.org/archlinux/) *(if GitLab becomes open to the general public)*. Therefore, guidelines and style changes to the code might come into effect as well as guidelines surrounding bug reporting and discussions. diff --git a/README.md b/README.md index 5c6c9157..c8a23f5a 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,6 @@ with archinstall.Installer('/mnt') as installation: installation.user_create('devel', 'devel') installation.user_set_pw('root', 'airoot') - ``` This installer will perform the following: diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 872d9bfc..5b92e1e1 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -1069,4 +1069,4 @@ def find_partition_by_mountpoint(block_devices, relative_mountpoint :str): for device in block_devices: for partition in block_devices[device]['partitions']: if partition.get('mountpoint', None) == relative_mountpoint: - return partition \ No newline at end of file + return partition diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index 24fbd8ee..dab5d2b0 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -98,4 +98,4 @@ def load_plugin(path :str): # -> module (not sure how to write that in type defi log(err, level=logging.ERROR) log(f"The above error was detected when initiating the plugin: {path}", fg="red", level=logging.ERROR) else: - log(f"Plugin '{path}' is missing a valid entry-point or is corrupt.", fg="yellow", level=logging.WARNING) \ No newline at end of file + log(f"Plugin '{path}' is missing a valid entry-point or is corrupt.", fg="yellow", level=logging.WARNING) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 6854ccfd..4ec265d4 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -575,14 +575,14 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict: # log(f"Selecting which partitions to re-use on {block_device}...", fg="yellow", level=logging.INFO) # partitions = generic_multi_select(block_device.partitions.values(), "Select which partitions to re-use (the rest will be left alone): ", sort=True) # partitions_to_wipe = generic_multi_select(partitions, "Which partitions do you wish to wipe (multiple can be selected): ", sort=True) - + # mountpoints = {} # struct = { # "partitions" : [] # } # for partition in partitions: # mountpoint = input(f"Select a mountpoint (or skip) for {partition}: ").strip() - + # part_struct = {} # if mountpoint: # part_struct['mountpoint'] = mountpoint @@ -590,7 +590,7 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict: # part_struct['boot'] = True # if has_uefi(): # part_struct['ESP'] = True - # elif mountpoint == '/' and + # elif mountpoint == '/' and # if partition.uuid: # part_struct['PARTUUID'] = partition.uuid # if partition in partitions_to_wipe: @@ -632,15 +632,15 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict: if not task: break - + if task == 'Create a new partition': if partition_type == 'gpt': # https://www.gnu.org/software/parted/manual/html_node/mkpart.html # https://www.gnu.org/software/parted/manual/html_node/mklabel.html name = input("Enter a desired name for the partition: ").strip() - + fstype = input("Enter a desired filesystem type for the partition: ").strip() - + start = input(f"Enter the start sector (percentage or block number, default: {block_device.largest_free_space[0]}): ").strip() if not start.strip(): start = block_device.largest_free_space[0] @@ -750,7 +750,7 @@ def select_individual_blockdevice_usage(block_devices :list): for device in block_devices: layout = manage_new_and_existing_partitions(device) - + result[device.path] = layout return result diff --git a/examples/guided.py b/examples/guided.py index b7c75b30..8353b76b 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -66,7 +66,7 @@ def load_config(): archinstall.storage['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts']) except: raise ValueError("--disk_layouts= needs either a JSON file or a JSON string given with a valid disk layout.") - + def ask_user_questions(): """ First, we'll ask the user for a bunch of user input. @@ -371,4 +371,4 @@ if not archinstall.arguments.get('silent'): ask_user_questions() perform_filesystem_operations() -perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt')) \ No newline at end of file +perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt')) diff --git a/setup.cfg b/setup.cfg index e5d79ef3..661c2cf6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,7 +29,7 @@ include = archinstall.* [options.package_data] -archinstall = +archinstall = examples/*.py profiles/*.py profiles/applications/*.py -- cgit v1.2.3-54-g00ecf