Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/disk.py44
-rw-r--r--archinstall/lib/installer.py22
-rw-r--r--archinstall/lib/plugins.py2
-rw-r--r--archinstall/lib/user_interaction.py16
4 files changed, 47 insertions, 37 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index 33f598bf..36f19ee8 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -110,17 +110,21 @@ 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 = {
- 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 +137,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",
@@ -142,12 +146,12 @@ 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
}
})
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,
@@ -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?
@@ -175,17 +183,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 +206,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",
@@ -207,11 +215,11 @@ def suggest_multi_disk_layout(block_devices):
"size" : "100%",
"mountpoint" : "/",
"filesystem" : {
- "format" : "btrfs"
+ "format" : default_filesystem
}
})
- layout[home_device]['partitions'].append({
+ layout[home_device.path]['partitions'].append({
# Home
"type" : "primary",
"encrypted" : False,
@@ -220,7 +228,7 @@ def suggest_multi_disk_layout(block_devices):
"size" : "100%",
"mountpoint" : "/home",
"filesystem" : {
- "format" : "btrfs"
+ "format" : default_filesystem
}
})
@@ -931,7 +939,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):
@@ -1069,4 +1079,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/installer.py b/archinstall/lib/installer.py
index 3efb0499..2aac8510 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 {self.target} {" ".join(packages)} --noconfirm', 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)
@@ -401,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')
@@ -429,7 +428,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 +534,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/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 ca8fb6f6..be74f9b9 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]
@@ -753,8 +753,8 @@ 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