From 6d0cf26eba907ce5c49f5ea7a3825101089cc5db Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 22 Aug 2024 08:28:16 +0200 Subject: [PATCH] Added a advanced=bool flag to Profile() class and enabled it on the cosmic-epoch profile (#2619) * Added a advanced=True flag to Profile() class, to be able to hide certain profiles behind --advanced * Removed debugging sleep * Made sure cosmic-greeter was hidden behind --advanced, and cleaned up --advanced checks on Profile() * storage['arguments'] is not defined during code-init, falling back to sys.argv for cosmic-greeter check --- .../default_profiles/desktops/cosmic.py | 2 +- archinstall/default_profiles/profile.py | 28 ++++++++++++++----- archinstall/default_profiles/xorg.py | 4 ++- archinstall/lib/profile/profiles_handler.py | 4 ++- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/archinstall/default_profiles/desktops/cosmic.py b/archinstall/default_profiles/desktops/cosmic.py index d9273db8..39d43702 100644 --- a/archinstall/default_profiles/desktops/cosmic.py +++ b/archinstall/default_profiles/desktops/cosmic.py @@ -8,7 +8,7 @@ if TYPE_CHECKING: class CosmicProfile(XorgProfile): def __init__(self): - super().__init__('cosmic-epoch', ProfileType.DesktopEnv, description='') + super().__init__('cosmic-epoch', ProfileType.DesktopEnv, description='', advanced=True) @property def packages(self) -> List[str]: diff --git a/archinstall/default_profiles/profile.py b/archinstall/default_profiles/profile.py index 9fa25584..fea8b21b 100644 --- a/archinstall/default_profiles/profile.py +++ b/archinstall/default_profiles/profile.py @@ -1,12 +1,14 @@ from __future__ import annotations +import sys from enum import Enum, auto from typing import List, Optional, Any, Dict, TYPE_CHECKING -from archinstall.lib.utils.util import format_cols +from ..lib.utils.util import format_cols +from ..lib.storage import storage if TYPE_CHECKING: - from archinstall.lib.installer import Installer + from ..lib.installer import Installer _: Any @@ -33,7 +35,10 @@ class GreeterType(Enum): Sddm = 'sddm' Gdm = 'gdm' Ly = 'ly' - CosmicSession = "cosmic-greeter" + + # .. todo:: Remove when we un-hide cosmic behind --advanced + if '--advanced' in sys.argv: + CosmicSession = "cosmic-greeter" class SelectResult(Enum): NewSelection = auto() @@ -51,12 +56,14 @@ class Profile: packages: List[str] = [], services: List[str] = [], support_gfx_driver: bool = False, - support_greeter: bool = False + support_greeter: bool = False, + advanced: bool = False ): self.name = name self.description = description self.profile_type = profile_type self.custom_settings: Dict[str, Any] = {} + self.advanced = advanced self._support_gfx_driver = support_gfx_driver self._support_greeter = support_greeter @@ -93,6 +100,13 @@ class Profile: """ return None + def _advanced_check(self): + """ + Used to control if the Profile() should be visible or not in different contexts. + Returns True if --advanced is given on a Profile(advanced=True) instance. + """ + return self.advanced is False or storage['arguments'].get('advanced', False) is True + def install(self, install_session: 'Installer'): """ Performs installation steps when this profile was selected @@ -138,16 +152,16 @@ class Profile: return self.profile_type in top_levels def is_desktop_profile(self) -> bool: - return self.profile_type == ProfileType.Desktop + return self.profile_type == ProfileType.Desktop if self._advanced_check() else False def is_server_type_profile(self) -> bool: return self.profile_type == ProfileType.ServerType def is_desktop_type_profile(self) -> bool: - return self.profile_type == ProfileType.DesktopEnv or self.profile_type == ProfileType.WindowMgr + return (self.profile_type == ProfileType.DesktopEnv or self.profile_type == ProfileType.WindowMgr) if self._advanced_check() else False def is_xorg_type_profile(self) -> bool: - return self.profile_type == ProfileType.Xorg + return self.profile_type == ProfileType.Xorg if self._advanced_check() else False def is_tailored(self) -> bool: return self.profile_type == ProfileType.Tailored diff --git a/archinstall/default_profiles/xorg.py b/archinstall/default_profiles/xorg.py index 88ba55a6..176b4ae5 100644 --- a/archinstall/default_profiles/xorg.py +++ b/archinstall/default_profiles/xorg.py @@ -12,12 +12,14 @@ class XorgProfile(Profile): name: str = 'Xorg', profile_type: ProfileType = ProfileType.Xorg, description: str = str(_('Installs a minimal system as well as xorg and graphics drivers.')), + advanced: bool = False ): super().__init__( name, profile_type, description=description, - support_gfx_driver=True + support_gfx_driver=True, + advanced=advanced ) def preview_text(self) -> Optional[str]: diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py index 77483f5d..3dac80eb 100644 --- a/archinstall/lib/profile/profiles_handler.py +++ b/archinstall/lib/profile/profiles_handler.py @@ -10,7 +10,7 @@ from tempfile import NamedTemporaryFile from types import ModuleType from typing import List, TYPE_CHECKING, Any, Optional, Dict, Union -from archinstall.default_profiles.profile import Profile, GreeterType +from ...default_profiles.profile import Profile, GreeterType from .profile_model import ProfileConfiguration from ..hardware import GfxDriver from ..menu import MenuSelectionType, Menu, MenuSelection @@ -194,6 +194,8 @@ class ProfileHandler: case GreeterType.Ly: packages = ['ly'] service = ['ly'] + case GreeterType.CosmicSession: + packages = ['cosmic-greeter'] if packages: install_session.add_additional_packages(packages)