Skip to content

Commit

Permalink
Added a advanced=bool flag to Profile() class and enabled it on the c…
Browse files Browse the repository at this point in the history
…osmic-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
  • Loading branch information
Torxed authored Aug 22, 2024
1 parent 00eeae0 commit 6d0cf26
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion archinstall/default_profiles/desktops/cosmic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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]:
Expand Down
28 changes: 21 additions & 7 deletions archinstall/default_profiles/profile.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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()
Expand All @@ -51,12 +56,14 @@ def __init__(
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
Expand Down Expand Up @@ -93,6 +100,13 @@ def default_greeter_type(self) -> Optional[GreeterType]:
"""
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
Expand Down Expand Up @@ -138,16 +152,16 @@ def is_top_level_profile(self) -> bool:
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
Expand Down
4 changes: 3 additions & 1 deletion archinstall/default_profiles/xorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ def __init__(
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]:
Expand Down
4 changes: 3 additions & 1 deletion archinstall/lib/profile/profiles_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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
Expand Down Expand Up @@ -194,6 +194,8 @@ def install_greeter(self, install_session: 'Installer', greeter: GreeterType):
case GreeterType.Ly:
packages = ['ly']
service = ['ly']
case GreeterType.CosmicSession:
packages = ['cosmic-greeter']

if packages:
install_session.add_additional_packages(packages)
Expand Down

0 comments on commit 6d0cf26

Please sign in to comment.