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 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'archinstall/lib') 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}") -- cgit v1.2.3-70-g09d2 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(-) (limited to 'archinstall/lib') 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-70-g09d2 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(-) (limited to 'archinstall/lib') 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-70-g09d2 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(-) (limited to 'archinstall/lib') 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-70-g09d2 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(-) (limited to 'archinstall/lib') 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-70-g09d2 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(-) (limited to 'archinstall/lib') 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-70-g09d2 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(-) (limited to 'archinstall/lib') 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-70-g09d2 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(-) (limited to 'archinstall/lib') 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-70-g09d2