internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: archlinux/archinstall

Issue:
[master] log directory not created in time when running with pre-made configs
![screenshot](https://github.com/archlinux/archinstall/assets/861439/6c5be46f-459f-43fd-9092-9e8d56b9d72e)



Discussion:
simple `mkdir -p /var/log/archinstall` before running is a workaround.
Is that not what is happening with the below code?

https://github.com/archlinux/archinstall/blob/768cb158437ff1056976cbb7842bebfebd959a46/archinstall/__init__.py#L53

https://github.com/archlinux/archinstall/blob/768cb158437ff1056976cbb7842bebfebd959a46/archinstall/lib/output.py#L138-L148

I think this might be the same race condition I warned about here https://github.com/archlinux/archinstall/pull/1831#issuecomment-1556255857 just with the directory existing rather than permissions.
The error here isn't the actual log problem that is just the result of the upper error which is the actual problem `Can't have partition outside disk`

But then yes, the logging will break because the setup of the logging hasn't actually happened. 
We should probably move the first log instance + creation to the very start of archinstall when we log the sysinfo.

The disk thing was a separate issue that I'm working on while experimenting with `/boot` being two partitions. Got the sectors wrong ^^

Resolving patch:
diff --git a/archinstall/__init__.py b/archinstall/__init__.py
--- a/archinstall/__init__.py
+++ b/archinstall/__init__.py
@@ -20,10 +20,7 @@
 
 from .lib.hardware import SysInfo, AVAILABLE_GFX_DRIVERS
 from .lib.installer import Installer, accessibility_tools_in_use
-from .lib.output import (
-	FormattedOutput, log, error,
-	check_log_permissions, debug, warn, info
-)
+from .lib.output import FormattedOutput, log, error, debug, warn, info
 from .lib.storage import storage
 from .lib.global_menu import GlobalMenu
 from .lib.boot import Boot
@@ -50,8 +47,6 @@
 # project to mark strings as translatable with _('translate me')
 DeferredTranslation.install()
 
-check_log_permissions()
-
 # Log various information about hardware before starting the installation. This might assist in troubleshooting
 debug(f"Hardware model detected: {SysInfo.sys_vendor()} {SysInfo.product_name()}; UEFI mode: {SysInfo.has_uefi()}")
 debug(f"Processor model detected: {SysInfo.cpu_model()}")
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -135,7 +135,7 @@ def log(message: str, level: int = logging.DEBUG) -> None:
 		log_adapter.log(level, message)
 
 
-def check_log_permissions():
+def _check_log_permissions():
 	filename = storage.get('LOG_FILE', None)
 	log_dir = storage.get('LOG_PATH', Path('./'))
 
@@ -292,6 +292,10 @@ def log(
 	reset: bool = False,
 	font: List[Font] = []
 ):
+	# leave this check here as we need to setup the logging
+	# right from the beginning when the modules are loaded
+	_check_log_permissions()
+
 	text = orig_string = ' '.join([str(x) for x in msgs])
 
 	# Attempt to colorize the output if supported


Test patch:
Repository: archlinux/archinstall

Issue:
Boot loader disk encryption conditional always fails
The screenshot below shows the warning that is displayed on boot of an installed system using systemd-boot and root encryption.

![image](https://github.com/archlinux/archinstall/assets/11915375/abc0ec94-ed5c-40e8-9579-08caf6e0c77a)

The options line of the systemd-boot entry is:

```
options root=PARTUUID=7e2b6859-82f1-41c5-828c-4f05fef09596 rw rootfstype=ext4
```

What is intended by the code and would also resolve the warning is:

```
options cryptdevice=PARTUUID=7e2b6859-82f1-41c5-828c-4f05fef09596:luksdev root=/dev/mapper/luksdev rw rootfstype=ext4
```

The intended options line is not produced because the following conditional always returns false.

https://github.com/archlinux/archinstall/blob/1af21c3e9582f3bf88f03ae2d45761b8b4ba3b64/archinstall/lib/installer.py#L800

This conditional does not work because a `PartitionModification.fs_type` is not considered valid if it is `FilesystemType.Crypto_luks` and encrypted partitions are tracked by the `Installer._disk_encryption.partitions` list rather than the `PartitionModification.fs_type` anyway.

https://github.com/archlinux/archinstall/blob/1af21c3e9582f3bf88f03ae2d45761b8b4ba3b64/archinstall/lib/disk/device_handler.py#L244-L257


Discussion:

Resolving patch:
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -797,7 +797,7 @@ def _add_systemd_bootloader(
 
 		options_entry = []
 
-		if root_partition.safe_fs_type.is_crypto():
+		if root_partition in self._disk_encryption.partitions:
 			# TODO: We need to detect if the encrypted device is a whole disk encryption,
 			#       or simply a partition encryption. Right now we assume it's a partition (and we always have)
 			debug('Root partition is an encrypted device, identifying by PARTUUID: {root_partition.partuuid}')
@@ -858,7 +858,7 @@ def _add_grub_bootloader(
 
 		_file = "/etc/default/grub"
 
-		if root_partition.safe_fs_type.is_crypto():
+		if root_partition in self._disk_encryption.partitions:
 			debug(f"Using UUID {root_partition.uuid} as encrypted root identifier")
 
 			cmd_line_linux = f"sed -i 's/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"cryptdevice=UUID={root_partition.uuid}:cryptlvm rootfstype={root_partition.safe_fs_type.value}\"/'"
@@ -1049,7 +1049,7 @@ def _add_efistub_bootloader(
 			# blkid doesn't trigger on loopback devices really well,
 			# so we'll use the old manual method until we get that sorted out.
 
-			if root_partition.safe_fs_type.is_crypto():
+			if root_partition in self._disk_encryption.partitions:
 				# TODO: We need to detect if the encrypted device is a whole disk encryption,
 				#       or simply a partition encryption. Right now we assume it's a partition (and we always have)
 				debug(f'Identifying root partition by PARTUUID: {root_partition.partuuid}')


Test patch:
Repository: archlinux/archinstall

Issue:
[master] awesome (desktops in general?) don't install packages?
It appears when choosing awesome, install is called: https://github.com/archlinux/archinstall/blob/7326d51161bf6fd7f1c683cf1d7ce09338efe4b7/archinstall/default_profiles/desktops/awesome.py#L23-L24

And super being `XorgProfile`: https://github.com/archlinux/archinstall/blob/7326d51161bf6fd7f1c683cf1d7ce09338efe4b7/archinstall/default_profiles/xorg.py#L1-L21

That class does not have an install so it calls `Profile.install()` which contains: https://github.com/archlinux/archinstall/blob/7326d51161bf6fd7f1c683cf1d7ce09338efe4b7/archinstall/default_profiles/profile.py#L101-L104
Which is just a placeholder?

![screenshot](https://github.com/archlinux/archinstall/assets/861439/cb60a03a-1307-491a-851c-b419544a8b2b)

I haven't ran through all the profiles yet, but have we overlooked something here?
What happened to all the packages per profile when we moved them to the dataclass structure? :)

I obviously missed something in a PR some where hehe


Discussion:
@svartkanin you might have more insight into the new workflow? did I miss something?
@Torxed the packages are installed by the desktop profile https://github.com/archlinux/archinstall/blob/master/archinstall/default_profiles/desktop.py#L77

It installs the desktop packages and then all selected desktop profiles' pavkages

Resolving patch:
diff --git a/archinstall/default_profiles/desktops/awesome.py b/archinstall/default_profiles/desktops/awesome.py
--- a/archinstall/default_profiles/desktops/awesome.py
+++ b/archinstall/default_profiles/desktops/awesome.py
@@ -14,7 +14,10 @@ def __init__(self):
 
 	@property
 	def packages(self) -> List[str]:
-		return ['alacritty']
+		return [
+			'awesome',
+			'alacritty'
+		]
 
 	def preview_text(self) -> Optional[str]:
 		text = str(_('Environment type: {}')).format(self.profile_type.value)


Test patch:
Repository: archlinux/archinstall

Issue:
Wrong debug messages in `_add_efistub_bootloader()`
The debug messages for the following conditional are inverse of their correct locations.

https://github.com/archlinux/archinstall/blob/2cc0d64619671fbc91a5f3a090c7c239be1d8a84/archinstall/lib/installer.py#L1073-L1080

Since it is a debug message it does not break anything but it is wrong and can misinform the user.


Discussion:

Resolving patch:
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -1073,10 +1073,10 @@ def _add_efistub_bootloader(
 			if root_partition in self._disk_encryption.partitions:
 				# TODO: We need to detect if the encrypted device is a whole disk encryption,
 				#       or simply a partition encryption. Right now we assume it's a partition (and we always have)
-				debug(f'Identifying root partition by PARTUUID: {root_partition.partuuid}')
+				debug(f'Root partition is an encrypted device identifying by PARTUUID: {root_partition.partuuid}')
 				kernel_parameters.append(f'cryptdevice=PARTUUID={root_partition.partuuid}:luksdev root=/dev/mapper/luksdev rw rootfstype={root_partition.safe_fs_type.value} {" ".join(self._kernel_params)}')
 			else:
-				debug(f'Root partition is an encrypted device identifying by PARTUUID: {root_partition.partuuid}')
+				debug(f'Identifying root partition by PARTUUID: {root_partition.partuuid}')
 				kernel_parameters.append(f'root=PARTUUID={root_partition.partuuid} rw rootfstype={root_partition.safe_fs_type.value} {" ".join(self._kernel_params)}')
 
 			parent_dev_path = disk.device_handler.get_parent_device_path(boot_partition.safe_dev_path)


Test patch:
Repository: archlinux/archinstall

Issue:
Redundant profile menu
Selecting the Profile option in the menu leads to a menu with the option Profile. Below is a screenshot of the menu described.

![image](https://github.com/archlinux/archinstall/assets/11915375/e2fac7f7-2ee9-4e49-a7e2-a9d4fe09fafc)


Discussion:
Yep indeed that's a bit of a waste
@codefiles I just had a look at this and it's actually not a redundant selection. 
If you go into the `Profile -> Profile` and lets say select `Desktop -> KDE` then this selection will enable more options such as GFX driver and greeter

![image](https://github.com/archlinux/archinstall/assets/19396770/bd4d3003-c641-4557-a21e-ad7fd526a497)


Maybe renaming the second `Profile` would help here? I'm open for suggestions 
Yea this one confused me too a bit heh.
If it's a selection menu, maybe `Profile` -> `Select Profile`?
What about `Profile -> Type`?
Yepp that works!

Resolving patch:
diff --git a/archinstall/lib/profile/profile_menu.py b/archinstall/lib/profile/profile_menu.py
--- a/archinstall/lib/profile/profile_menu.py
+++ b/archinstall/lib/profile/profile_menu.py
@@ -27,7 +27,7 @@ def __init__(
 
 	def setup_selection_menu_options(self):
 		self._menu_options['profile'] = Selector(
-			_('Profile'),
+			_('Type'),
 			lambda x: self._select_profile(x),
 			display_func=lambda x: x.name if x else None,
 			preview_func=self._preview_profile,


Test patch:
Repository: archlinux/archinstall

Issue:
Allow assign mount point without wiping partition
Hello, 
This was an option in previous version of archinstall - to mount a partition without the need to format it - for example, separate `/home` partition that has data from previous install. In this version this is not available, or maybe I am missing something?! There is an option "mark/unmark" partition for formating, but its one way only, you can't toggle it. Only after you "mark" partition for formating, there is new menu with "assign mount point"...


Discussion:
This would be awesome, I dont think formatting my ssd 10 times is good for it. (Realizing a misconfiguration or the script failing)
I think this is a regression, I'll have a look at it

Resolving patch:
diff --git a/archinstall/lib/disk/partitioning_menu.py b/archinstall/lib/disk/partitioning_menu.py
--- a/archinstall/lib/disk/partitioning_menu.py
+++ b/archinstall/lib/disk/partitioning_menu.py
@@ -61,14 +61,13 @@ def filter_options(self, selection: PartitionModification, options: List[str]) -
 		if not selection.exists():
 			not_filter += [self._actions['mark_formatting']]
 		else:
-			# only allow these options if the existing partition
+			# only allow options if the existing partition
 			# was marked as formatting, otherwise we run into issues where
 			# 1. select a new fs -> potentially mark as wipe now
 			# 2. Switch back to old filesystem -> should unmark wipe now, but
 			#     how do we know it was the original one?
 			not_filter += [
 				self._actions['set_filesystem'],
-				self._actions['assign_mountpoint'],
 				self._actions['mark_bootable'],
 				self._actions['btrfs_mark_compressed'],
 				self._actions['btrfs_set_subvolumes']


Test patch:
Repository: archlinux/archinstall

Issue:
Localizations revert to defaults on entry of "Locales" menu
If localizations are changed from the defaults they will revert back to the defaults upon entry of the _Locales_ menu.


Discussion:

Resolving patch:
diff --git a/archinstall/lib/locale/locale_menu.py b/archinstall/lib/locale/locale_menu.py
--- a/archinstall/lib/locale/locale_menu.py
+++ b/archinstall/lib/locale/locale_menu.py
@@ -52,9 +52,9 @@ class LocaleMenu(AbstractSubMenu):
 	def __init__(
 		self,
 		data_store: Dict[str, Any],
-		locele_conf: LocaleConfiguration
+		locale_conf: LocaleConfiguration
 	):
-		self._preset = locele_conf
+		self._preset = locale_conf
 		super().__init__(data_store=data_store)
 
 	def setup_selection_menu_options(self):
@@ -62,19 +62,19 @@ def setup_selection_menu_options(self):
 			Selector(
 				_('Keyboard layout'),
 				lambda preset: self._select_kb_layout(preset),
-				default='us',
+				default=self._preset.kb_layout,
 				enabled=True)
 		self._menu_options['sys-language'] = \
 			Selector(
 				_('Locale language'),
 				lambda preset: select_locale_lang(preset),
-				default='en_US',
+				default=self._preset.sys_lang,
 				enabled=True)
 		self._menu_options['sys-encoding'] = \
 			Selector(
 				_('Locale encoding'),
 				lambda preset: select_locale_enc(preset),
-				default='UTF-8',
+				default=self._preset.sys_enc,
 				enabled=True)
 
 	def run(self, allow_reset: bool = True) -> LocaleConfiguration:


Test patch:
Repository: archlinux/archinstall

Issue:
I3wm at the bottom of the list in the desktops
list is no longer alphabetical

![image](https://github.com/archlinux/archinstall/assets/10594806/136235a6-ef61-40e4-b349-530b6a12a569)

Could you put i3 after hyprland?


Discussion:
To be fair it is alphabetical, it's just that the "i" in "i3" is lowercase that's why it comes after all the other uppercase ones 
well consider changing it
please

Resolving patch:
diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py
--- a/archinstall/lib/profile/profiles_handler.py
+++ b/archinstall/lib/profile/profiles_handler.py
@@ -371,6 +371,7 @@ def select_profile(
 		Helper function to perform a profile selection
 		"""
 		options = {p.name: p for p in selectable_profiles}
+		options = dict((k, v) for k, v in sorted(options.items(), key=lambda x: x[0].upper()))
 
 		warning = str(_('Are you sure you want to reset this setting?'))
 
@@ -388,7 +389,7 @@ def select_profile(
 			allow_reset=allow_reset,
 			allow_reset_warning_msg=warning,
 			multi=multi,
-			sort=True,
+			sort=False,
 			preview_command=self.preview_text,
 			preview_size=0.5
 		).run()


Test patch:
Repository: archlinux/archinstall

Issue:
Sway does not appear to be a profile
> Cannot import <module 'sway' from '/root/archinstall/archinstall/default_profiles/desktops/sway.py'>, it does not appear to be a Profile class

Noted in #2072 *(log: https://pastebin.com/ddnFkxzR line 3310)*

Not sure if it's relevant as I haven't investigated, just noting down here for later.


Discussion:
This enum is triggering that message.

https://github.com/archlinux/archinstall/blob/3e2999bc2752c76e666d916bdb80608ad74528bf/archinstall/default_profiles/desktops/sway.py#L13-L15

When `_load_profile_class()` is called on the Sway profile `module.__dict__.items()` will contain the enum. Then the line `cls_ = v()` will raise an exception with the enum.

https://github.com/archlinux/archinstall/blob/3e2999bc2752c76e666d916bdb80608ad74528bf/archinstall/lib/profile/profiles_handler.py#L272-L286

Maybe adding the code below to the function following the line with the `module.__dict__.items()` for loop (including the EnumType import)?

```python
if isinstance(v, EnumType):
	continue
```

That works. Thoughts?
Thanks for deep diving on this one.
I think the fix is good enough! It's hard to avoid it in any other way to be honest.
Adding the specific exclusion for `EnumType` will solve this particular case but if in the future other constructs will get added to profile modules it will break again

Maybe something like this 

```
import inspect
bases = inspect.getmro(v)

if Profile in bases:
    cls_ = v()
    if isinstance(cls_, Profile):
        profiles.append(cls_)

```
Yea, it was just good enough for the case. I like your approach more.

Resolving patch:
diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py
--- a/archinstall/lib/profile/profiles_handler.py
+++ b/archinstall/lib/profile/profiles_handler.py
@@ -2,6 +2,7 @@
 
 import importlib.util
 import sys
+import inspect
 from collections import Counter
 from functools import cached_property
 from pathlib import Path
@@ -276,12 +277,15 @@ def _load_profile_class(self, module: ModuleType) -> List[Profile]:
 		profiles = []
 		for k, v in module.__dict__.items():
 			if isinstance(v, type) and v.__module__ == module.__name__:
-				try:
-					cls_ = v()
-					if isinstance(cls_, Profile):
-						profiles.append(cls_)
-				except Exception:
-					debug(f'Cannot import {module}, it does not appear to be a Profile class')
+				bases = inspect.getmro(v)
+
+				if Profile in bases:
+					try:
+						cls_ = v()
+						if isinstance(cls_, Profile):
+							profiles.append(cls_)
+					except Exception:
+						debug(f'Cannot import {module}, it does not appear to be a Profile class')
 
 		return profiles
 


Test patch:
Repository: archlinux/archinstall

Issue:
i am encountering fstrim error
from everything i can read the testing repo causes this issue or a dirty drive and with a completely clean drive and not selecting testing i still hit this error


Discussion:
Would you mind sharing the log please under /var/log/archinstall
i ended up just installing manually 
@svartkanin, we might as well remove the function that enables fstrim. It has been enabled in the kernel since 6.4.11 IIRC. Refer to #1837.

Resolving patch:
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -587,6 +587,7 @@ def minimal_installation(
 		hostname: str = 'archinstall',
 		locale_config: LocaleConfiguration = LocaleConfiguration.default()
 	):
+		_disable_fstrim = False
 		for mod in self._disk_config.device_modifications:
 			for part in mod.partitions:
 				if part.fs_type is not None:
@@ -597,6 +598,10 @@ def minimal_installation(
 					if (binary := part.fs_type.installation_binary) is not None:
 						self._binaries.append(binary)
 
+					# https://github.com/archlinux/archinstall/issues/1837
+					if part.fs_type.fs_type_mount == 'btrfs':
+						_disable_fstrim = True
+
 					# There is not yet an fsck tool for NTFS. If it's being used for the root filesystem, the hook should be removed.
 					if part.fs_type.fs_type_mount == 'ntfs3' and part.mountpoint == self.target:
 						if 'fsck' in self._hooks:
@@ -651,7 +656,10 @@ def minimal_installation(
 		# periodic TRIM by default.
 		#
 		# https://github.com/archlinux/archinstall/issues/880
-		self.enable_periodic_trim()
+		# https://github.com/archlinux/archinstall/issues/1837
+		# https://github.com/archlinux/archinstall/issues/1841
+		if not _disable_fstrim:
+			self.enable_periodic_trim()
 
 		# TODO: Support locale and timezone
 		# os.remove(f'{self.target}/etc/localtime')


Test patch:
Repository: archlinux/archinstall

Issue:
MBR single partition disk configuration fails on `grub-mkconfig`
During installation of a MBR single partition disk configuration `grub-mkconfig` fails with the following message logged:

```
Could not configure GRUB: ['/usr/bin/arch-chroot', '/mnt/archinstall', 'grub-mkconfig', '-o', '//grub/grub.cfg'] exited with abnormal exit code [1]: /usr/bin/grub-mkconfig: line 270: //grub/grub.cfg.new: No such file or directory
```

The path seen in the command `//grub/grub.cfg` is incorrect and should be `/boot/grub/grub.cfg`.

https://github.com/archlinux/archinstall/blob/7a9a934ae38324f11d7d3be580a3ec329a73f96f/archinstall/lib/installer.py#L938-L941

The boot partition and root partition are the same in this configuration with the mount point of `/`. The key detail is that the boot directory will be located at `/boot` and not `/`.


Discussion:

Resolving patch:
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -889,6 +889,13 @@ def _add_grub_bootloader(
 
 		info(f"GRUB boot partition: {boot_partition.dev_path}")
 
+		if boot_partition == root_partition and root_partition.mountpoint:
+			boot_dir = root_partition.mountpoint / 'boot'
+		elif boot_partition.mountpoint:
+			boot_dir = boot_partition.mountpoint
+		else:
+			raise ValueError('Could not detect boot directory')
+
 		command = [
 			'/usr/bin/arch-chroot',
 			str(self.target),
@@ -904,7 +911,7 @@ def _add_grub_bootloader(
 			add_options = [
 				'--target=x86_64-efi',
 				f'--efi-directory={efi_partition.mountpoint}',
-				f'--boot-directory={boot_partition.mountpoint if boot_partition else "/boot"}',
+				f'--boot-directory={boot_dir}',
 				'--bootloader-id=GRUB',
 				'--removable'
 			]
@@ -937,7 +944,7 @@ def _add_grub_bootloader(
 		try:
 			SysCommand(
 				f'/usr/bin/arch-chroot {self.target} '
-				f'grub-mkconfig -o {boot_partition.mountpoint if boot_partition else "/boot"}/grub/grub.cfg'
+				f'grub-mkconfig -o {boot_dir}/grub/grub.cfg'
 			)
 		except SysCallError as err:
 			raise DiskError(f"Could not configure GRUB: {err}")


Test patch: