Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a advanced=bool flag to Profile() class and enabled it on the cosmic-epoch profile #2619

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Torxed marked this conversation as resolved.
Show resolved Hide resolved

@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