Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/profile
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/profile')
-rw-r--r--archinstall/lib/profile/profiles_handler.py66
1 files changed, 32 insertions, 34 deletions
diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py
index 4e7c3d2b..74c21824 100644
--- a/archinstall/lib/profile/profiles_handler.py
+++ b/archinstall/lib/profile/profiles_handler.py
@@ -98,14 +98,19 @@ class ProfileHandler:
profile = self.get_profile_by_name(main) if main else None
valid: List[Profile] = []
+ details: List[str] = profile_config.get('details', [])
+ if details:
+ valid = []
+ invalid = []
- if details := profile_config.get('details', []):
- resolved = {detail: self.get_profile_by_name(detail) for detail in details if detail}
- valid = [p for p in resolved.values() if p is not None]
- invalid = ', '.join([k for k, v in resolved.items() if v is None])
+ for detail in filter(None, details):
+ if profile := self.get_profile_by_name(detail):
+ valid.append(profile)
+ else:
+ invalid.append(detail)
if invalid:
- info(f'No profile definition found: {invalid}')
+ info('No profile definition found: {}'.format(', '.join(invalid)))
custom_settings = profile_config.get('custom_settings', {})
for profile in valid:
@@ -123,14 +128,12 @@ class ProfileHandler:
"""
List of all available default_profiles
"""
- if self._profiles is None:
- self._profiles = self._find_available_profiles()
+ self._profiles = self._profiles or self._find_available_profiles()
return self._profiles
@cached_property
def _local_mac_addresses(self) -> List[str]:
- ifaces = list_interfaces()
- return list(ifaces.keys())
+ return list(list_interfaces())
def add_custom_profiles(self, profiles: Union[TProfile, List[TProfile]]):
if not isinstance(profiles, list):
@@ -190,25 +193,20 @@ class ProfileHandler:
def install_gfx_driver(self, install_session: 'Installer', driver: Optional[GfxDriver]):
try:
- driver_pkgs = driver.packages() if driver else []
- pkg_names = [p.value for p in driver_pkgs]
- additional_pkg = ' '.join(['xorg-server', 'xorg-xinit'] + pkg_names)
if driver is not None:
- # Find the intersection between the set of known nvidia drivers
- # and the selected driver packages. Since valid intesections can
- # only have one element or none, we iterate and try to take the
- # first element.
- if driver_pkg := next(iter({GfxPackage.Nvidia, GfxPackage.NvidiaOpen} & set(driver_pkgs)), None):
- if any(kernel in install_session.base_packages for kernel in ("linux-lts", "linux-zen")):
- for kernel in install_session.kernels:
- # Fixes https://github.com/archlinux/archinstall/issues/585
- install_session.add_additional_packages(f"{kernel}-headers")
+ driver_pkgs = driver.packages()
+ pkg_names = [p.value for p in driver_pkgs]
+ for driver_pkg in {GfxPackage.Nvidia, GfxPackage.NvidiaOpen} & set(driver_pkgs):
+ for kernel in {"linux-lts", "linux-zen"} & set(install_session.kernels):
+ # Fixes https://github.com/archlinux/archinstall/issues/585
+ install_session.add_additional_packages(f"{kernel}-headers")
# I've had kernel regen fail if it wasn't installed before nvidia-dkms
- install_session.add_additional_packages(['dkms', 'xorg-server', 'xorg-xinit', f'{driver_pkg}-dkms'])
- return
- elif 'amdgpu' in driver_pkgs:
+ install_session.add_additional_packages(['dkms', 'xorg-server', 'xorg-xinit', f'{driver_pkg.value}-dkms'])
+ # Return after first driver match, since it is impossible to use both simultaneously.
+ return
+ if 'amdgpu' in driver_pkgs:
# The order of these two are important if amdgpu is installed #808
if 'amdgpu' in install_session.modules:
install_session.modules.remove('amdgpu')
@@ -218,23 +216,24 @@ class ProfileHandler:
install_session.modules.remove('radeon')
install_session.modules.append('radeon')
- install_session.add_additional_packages(additional_pkg)
+ install_session.add_additional_packages(pkg_names)
except Exception as err:
warn(f"Could not handle nvidia and linuz-zen specific situations during xorg installation: {err}")
# Prep didn't run, so there's no driver to install
- install_session.add_additional_packages(['xorg-server', 'xorg-xinit'])
+ install_session.add_additional_packages(['xorg-server', 'xorg-xinit'])
def install_profile_config(self, install_session: 'Installer', profile_config: ProfileConfiguration):
profile = profile_config.profile
- if profile:
- profile.install(install_session)
+ if not profile:
+ return
- if profile and profile_config.gfx_driver:
- if profile.is_xorg_type_profile() or profile.is_desktop_type_profile():
- self.install_gfx_driver(install_session, profile_config.gfx_driver)
+ profile.install(install_session)
- if profile and profile_config.greeter:
+ if profile_config.gfx_driver and (profile.is_xorg_type_profile() or profile.is_desktop_type_profile()):
+ self.install_gfx_driver(install_session, profile_config.gfx_driver)
+
+ if profile_config.greeter:
self.install_greeter(install_session, profile_config.greeter)
def _import_profile_from_url(self, url: str):
@@ -312,8 +311,7 @@ class ProfileHandler:
debug(f'Importing profile: {file}')
try:
- spec = importlib.util.spec_from_file_location(name, file)
- if spec is not None:
+ if spec := importlib.util.spec_from_file_location(name, file):
imported = importlib.util.module_from_spec(spec)
if spec.loader is not None:
spec.loader.exec_module(imported)