From 00b0ae7ba439a5a420095175b3bedd52c569db51 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Wed, 19 Apr 2023 20:55:42 +1000 Subject: PyParted and a large rewrite of the underlying partitioning (#1604) * Invert mypy files * Add optional pre-commit hooks * New profile structure * Serialize profiles * Use profile instead of classmethod * Custom profile setup * Separator between back * Support profile import via url * Move profiles module * Refactor files * Remove symlink * Add user to docker group * Update schema description * Handle list services * mypy fixes * mypy fixes * Rename profilesv2 to profiles * flake8 * mypy again * Support selecting DM * Fix mypy * Cleanup * Update greeter setting * Update schema * Revert toml changes * Poc external dependencies * Dependency support * New encryption menu * flake8 * Mypy and flake8 * Unify lsblk command * Update bootloader configuration * Git hooks * Fix import * Pyparted * Remove custom font setting * flake8 * Remove default preview * Manual partitioning menu * Update structure * Disk configuration * Update filesystem * luks2 encryption * Everything works until installation * Btrfsutil * Btrfs handling * Update btrfs * Save encryption config * Fix pipewire issue * Update mypy version * Update all pre-commit * Update package versions * Revert audio/pipewire * Merge master PRs * Add master changes * Merge master changes * Small renaming * Pull master changes * Reset disk enc after disk config change * Generate locals * Update naming * Fix imports * Fix broken sync * Fix pre selection on table menu * Profile menu * Update profile * Fix post_install * Added python-pyparted to PKGBUILD, this requires [testing] to be enabled in order to run makepkg. Package still works via python -m build etc. * Swaped around some setuptools logic in pyproject Since we define `package-data` and `packages` there should be no need for: ``` [tool.setuptools.packages.find] where = ["archinstall", "archinstall.*"] ``` * Removed pyproject collisions. Duplicate definitions. * Made sure pyproject.toml includes languages * Add example and update README * Fix pyproject issues * Generate locale * Refactor imports * Simplify imports * Add profile description and package examples * Align code * Fix mypy * Simplify imports * Fix saving config * Fix wrong luks merge * Refactor installation * Fix cdrom device loading * Fix wrongly merged code * Fix imports and greeter * Don't terminate on partprobe error * Use specific path on partprobe from luks * Update archinstall/lib/disk/device_model.py Co-authored-by: codefiles <11915375+codefiles@users.noreply.github.com> * Update archinstall/lib/disk/device_model.py Co-authored-by: codefiles <11915375+codefiles@users.noreply.github.com> * Update github workflow to test archinstall installation * Update sway merge * Generate locales * Update workflow --------- Co-authored-by: Daniel Girtler Co-authored-by: Anton Hvornum Co-authored-by: Anton Hvornum Co-authored-by: codefiles <11915375+codefiles@users.noreply.github.com> --- archinstall/default_profiles/desktops/bspwm.py | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 archinstall/default_profiles/desktops/bspwm.py (limited to 'archinstall/default_profiles/desktops/bspwm.py') diff --git a/archinstall/default_profiles/desktops/bspwm.py b/archinstall/default_profiles/desktops/bspwm.py new file mode 100644 index 00000000..f3bc982d --- /dev/null +++ b/archinstall/default_profiles/desktops/bspwm.py @@ -0,0 +1,30 @@ +from typing import List, Optional, Any, TYPE_CHECKING + +from archinstall.default_profiles.profile import ProfileType, GreeterType +from archinstall.default_profiles.xorg import XorgProfile + +if TYPE_CHECKING: + _: Any + + +class BspwmProfile(XorgProfile): + def __init__(self): + super().__init__('Bspwm', ProfileType.WindowMgr, description='') + + @property + def packages(self) -> List[str]: + return [ + 'bspwm', + 'sxhkd', + 'dmenu', + 'xdo', + 'rxvt-unicode' + ] + + @property + def default_greeter_type(self) -> Optional[GreeterType]: + return GreeterType.Lightdm + + def preview_text(self) -> Optional[str]: + text = str(_('Environment type: {}')).format(self.profile_type.value) + return text + '\n' + self.packages_text() -- cgit v1.2.3-54-g00ecf From a43344c5ae2249ddb70e535637915b30563c5038 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 30 Jul 2023 00:28:21 +0200 Subject: Adding pack packages to profiles after they were removed (#1956) * Added back xinit for awesome, since it can be used without a greeter, as well as other useful tools we've had in previous releases * Fixing xinitrc for awesome profile * Attempting to grab xorg packages when installing the desktop profile * Spelling error on xorg-server * Fixed sway value error on seat selection --- archinstall/__init__.py | 4 +-- archinstall/default_profiles/desktops/awesome.py | 32 ++++++++++++++++++++++-- archinstall/default_profiles/desktops/bspwm.py | 22 ++++++++++++++++ archinstall/default_profiles/desktops/sway.py | 2 +- archinstall/default_profiles/xorg.py | 8 +++++- archinstall/lib/general.py | 2 +- 6 files changed, 63 insertions(+), 7 deletions(-) (limited to 'archinstall/default_profiles/desktops/bspwm.py') diff --git a/archinstall/__init__.py b/archinstall/__init__.py index cfaecd16..56f0b278 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -145,12 +145,12 @@ def cleanup_empty_args(args: Union[Namespace, Dict]) -> Dict: Takes arguments (dictionary or argparse Namespace) and removes any None values. This ensures clean mergers during dict.update(args) """ - if type(args) == Namespace: + if type(args) is Namespace: args = vars(args) clean_args = {} for key, val in args.items(): - if type(val) == dict: + if isinstance(val, dict): val = cleanup_empty_args(val) if val is not None: diff --git a/archinstall/default_profiles/desktops/awesome.py b/archinstall/default_profiles/desktops/awesome.py index 371e51db..79e0eb71 100644 --- a/archinstall/default_profiles/desktops/awesome.py +++ b/archinstall/default_profiles/desktops/awesome.py @@ -14,9 +14,18 @@ class AwesomeProfile(XorgProfile): @property def packages(self) -> List[str]: - return [ + return super().packages + [ 'awesome', - 'alacritty' + 'alacritty', + 'xorg-xinit', + 'xorg-xrandr', + 'xterm', + 'feh', + 'slock', + 'terminus-font', + 'gnu-free-fonts', + 'ttf-liberation', + 'xsel', ] def preview_text(self) -> Optional[str]: @@ -37,3 +46,22 @@ class AwesomeProfile(XorgProfile): fh.write(awesome_lua) # TODO: Configure the right-click-menu to contain the above packages that were installed. (as a user config) + + # TODO: check if we selected a greeter, + # but for now, awesome is intended to run without one. + with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'r') as xinitrc: + xinitrc_data = xinitrc.read() + + for line in xinitrc_data.split('\n'): + if "twm &" in line: + xinitrc_data = xinitrc_data.replace(line, f"# {line}") + if "xclock" in line: + xinitrc_data = xinitrc_data.replace(line, f"# {line}") + if "xterm" in line: + xinitrc_data = xinitrc_data.replace(line, f"# {line}") + + xinitrc_data += '\n' + xinitrc_data += 'exec awesome\n' + + with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'w') as xinitrc: + xinitrc.write(xinitrc_data) \ No newline at end of file diff --git a/archinstall/default_profiles/desktops/bspwm.py b/archinstall/default_profiles/desktops/bspwm.py index f3bc982d..2a29f41b 100644 --- a/archinstall/default_profiles/desktops/bspwm.py +++ b/archinstall/default_profiles/desktops/bspwm.py @@ -13,6 +13,7 @@ class BspwmProfile(XorgProfile): @property def packages(self) -> List[str]: + # return super().packages + [ return [ 'bspwm', 'sxhkd', @@ -28,3 +29,24 @@ class BspwmProfile(XorgProfile): def preview_text(self) -> Optional[str]: text = str(_('Environment type: {}')).format(self.profile_type.value) return text + '\n' + self.packages_text() + + # The wiki specified xinit, but we already use greeter? + # https://wiki.archlinux.org/title/Bspwm#Starting + # + # # TODO: check if we selected a greeter, else run this: + # with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'r') as xinitrc: + # xinitrc_data = xinitrc.read() + + # for line in xinitrc_data.split('\n'): + # if "twm &" in line: + # xinitrc_data = xinitrc_data.replace(line, f"# {line}") + # if "xclock" in line: + # xinitrc_data = xinitrc_data.replace(line, f"# {line}") + # if "xterm" in line: + # xinitrc_data = xinitrc_data.replace(line, f"# {line}") + + # xinitrc_data += '\n' + # xinitrc_data += 'exec bspwn\n' + + # with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'w') as xinitrc: + # xinitrc.write(xinitrc_data) diff --git a/archinstall/default_profiles/desktops/sway.py b/archinstall/default_profiles/desktops/sway.py index ae814e46..25d74a88 100644 --- a/archinstall/default_profiles/desktops/sway.py +++ b/archinstall/default_profiles/desktops/sway.py @@ -53,7 +53,7 @@ class SwayProfile(XorgProfile): @property def services(self) -> List[str]: if pref := self.custom_settings.get('seat_access', None): - return [pref.value] + return [pref] return [] def _ask_seat_access(self): diff --git a/archinstall/default_profiles/xorg.py b/archinstall/default_profiles/xorg.py index 553421a4..13154818 100644 --- a/archinstall/default_profiles/xorg.py +++ b/archinstall/default_profiles/xorg.py @@ -1,4 +1,4 @@ -from typing import Any, TYPE_CHECKING +from typing import Any, TYPE_CHECKING, List from archinstall.default_profiles.profile import Profile, ProfileType @@ -19,3 +19,9 @@ class XorgProfile(Profile): description=description, support_gfx_driver=True ) + + @property + def packages(self) -> List[str]: + return [ + 'xorg-server' + ] diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 473f85a4..90af25ed 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -211,7 +211,7 @@ class SysCommandWorker: return False def write(self, data: bytes, line_ending :bool = True) -> int: - assert type(data) == bytes # TODO: Maybe we can support str as well and encode it + assert isinstance(data, bytes) # TODO: Maybe we can support str as well and encode it self.make_sure_we_are_executing() -- cgit v1.2.3-54-g00ecf From 08a6d402c4792cae95aec196460dc67aadd86f3c Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Fri, 8 Mar 2024 00:43:51 +1100 Subject: Fix 2215 | Display installed packages for all profile submenus (#2355) * Display all packages to be installed * Display all packages to be installed --- archinstall/default_profiles/desktops/bspwm.py | 25 --------------------- archinstall/default_profiles/profile.py | 31 ++++++++++++++++++-------- archinstall/default_profiles/xorg.py | 5 ++++- archinstall/lib/hardware.py | 12 +++++++++- archinstall/lib/interactions/system_conf.py | 7 +++--- archinstall/lib/menu/menu.py | 4 +++- archinstall/lib/profile/profile_menu.py | 22 ++++++++++++++++-- archinstall/lib/utils/util.py | 8 +++---- 8 files changed, 68 insertions(+), 46 deletions(-) (limited to 'archinstall/default_profiles/desktops/bspwm.py') diff --git a/archinstall/default_profiles/desktops/bspwm.py b/archinstall/default_profiles/desktops/bspwm.py index 2a29f41b..61eeba43 100644 --- a/archinstall/default_profiles/desktops/bspwm.py +++ b/archinstall/default_profiles/desktops/bspwm.py @@ -25,28 +25,3 @@ class BspwmProfile(XorgProfile): @property def default_greeter_type(self) -> Optional[GreeterType]: return GreeterType.Lightdm - - def preview_text(self) -> Optional[str]: - text = str(_('Environment type: {}')).format(self.profile_type.value) - return text + '\n' + self.packages_text() - - # The wiki specified xinit, but we already use greeter? - # https://wiki.archlinux.org/title/Bspwm#Starting - # - # # TODO: check if we selected a greeter, else run this: - # with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'r') as xinitrc: - # xinitrc_data = xinitrc.read() - - # for line in xinitrc_data.split('\n'): - # if "twm &" in line: - # xinitrc_data = xinitrc_data.replace(line, f"# {line}") - # if "xclock" in line: - # xinitrc_data = xinitrc_data.replace(line, f"# {line}") - # if "xterm" in line: - # xinitrc_data = xinitrc_data.replace(line, f"# {line}") - - # xinitrc_data += '\n' - # xinitrc_data += 'exec bspwn\n' - - # with open(f"{install_session.target}/etc/X11/xinit/xinitrc", 'w') as xinitrc: - # xinitrc.write(xinitrc_data) diff --git a/archinstall/default_profiles/profile.py b/archinstall/default_profiles/profile.py index 49a9c19d..4c85b0c7 100644 --- a/archinstall/default_profiles/profile.py +++ b/archinstall/default_profiles/profile.py @@ -178,15 +178,28 @@ class Profile: def preview_text(self) -> Optional[str]: """ - Used for preview text in profiles_bck. If a description is set for a - profile it will automatically display that one in the preview. - If no preview or a different text should be displayed just + Override this method to provide a preview text for the profile """ - if self.description: - return self.description - return None + return self.packages_text() - def packages_text(self) -> str: + def packages_text(self, include_sub_packages: bool = False) -> Optional[str]: header = str(_('Installed packages')) - output = format_cols(self.packages, header) - return output + + text = '' + packages = [] + + if self.packages: + packages = self.packages + + if include_sub_packages: + for p in self.current_selection: + if p.packages: + packages += p.packages + + text += format_cols(sorted(set(packages))) + + if text: + text = f'{header}: \n{text}' + return text + + return None diff --git a/archinstall/default_profiles/xorg.py b/archinstall/default_profiles/xorg.py index c9abf4da..88ba55a6 100644 --- a/archinstall/default_profiles/xorg.py +++ b/archinstall/default_profiles/xorg.py @@ -22,7 +22,10 @@ class XorgProfile(Profile): def preview_text(self) -> Optional[str]: text = str(_('Environment type: {}')).format(self.profile_type.value) - return text + '\n' + self.packages_text() + if packages := self.packages_text(): + text += f'\n{packages}' + + return text @property def packages(self) -> List[str]: diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index efdae430..c8001c19 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -2,12 +2,16 @@ import os from enum import Enum from functools import cached_property from pathlib import Path -from typing import Optional, Dict, List +from typing import Optional, Dict, List, TYPE_CHECKING, Any from .exceptions import SysCallError from .general import SysCommand from .networking import list_interfaces, enrich_iface_types from .output import debug +from .utils.util import format_cols + +if TYPE_CHECKING: + _: Any class CpuVendor(Enum): @@ -73,6 +77,12 @@ class GfxDriver(Enum): case _: return False + def packages_text(self) -> str: + text = str(_('Installed packages')) + ':\n' + pkg_names = [p.value for p in self.gfx_packages()] + text += format_cols(sorted(pkg_names)) + return text + def gfx_packages(self) -> List[GfxPackage]: packages = [GfxPackage.XorgServer, GfxPackage.XorgXinit] diff --git a/archinstall/lib/interactions/system_conf.py b/archinstall/lib/interactions/system_conf.py index aa72748e..35ba5a8b 100644 --- a/archinstall/lib/interactions/system_conf.py +++ b/archinstall/lib/interactions/system_conf.py @@ -103,14 +103,15 @@ def select_driver(options: List[GfxDriver] = [], current_value: Optional[GfxDriv if SysInfo.has_nvidia_graphics(): title += str(_('For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.\n')) - title += str(_('\nSelect a graphics driver or leave blank to install all open-source drivers')) - preset = current_value.value if current_value else None + choice = Menu( title, drivers, preset_values=preset, - default_option=GfxDriver.AllOpenSource.value + default_option=GfxDriver.AllOpenSource.value, + preview_command=lambda x: GfxDriver(x).packages_text(), + preview_size=0.3 ).run() if choice.type_ != MenuSelectionType.Selection: diff --git a/archinstall/lib/menu/menu.py b/archinstall/lib/menu/menu.py index 3bd31b88..f14b855d 100644 --- a/archinstall/lib/menu/menu.py +++ b/archinstall/lib/menu/menu.py @@ -235,7 +235,9 @@ class Menu(TerminalMenu): if preview_command: if self._default_option is not None and self._default_menu_value == selection: selection = self._default_option - return preview_command(selection) + + if res := preview_command(selection): + return res.rstrip('\n') return None diff --git a/archinstall/lib/profile/profile_menu.py b/archinstall/lib/profile/profile_menu.py index d9e47190..aba75a88 100644 --- a/archinstall/lib/profile/profile_menu.py +++ b/archinstall/lib/profile/profile_menu.py @@ -40,6 +40,7 @@ class ProfileMenu(AbstractSubMenu): lambda preset: self._select_gfx_driver(preset), display_func=lambda x: x.value if x else None, dependencies=['profile'], + preview_func=self._preview_gfx, default=self._preset.gfx_driver if self._preset.profile and self._preset.profile.is_graphic_driver_supported() else None, enabled=self._preset.profile.is_graphic_driver_supported() if self._preset.profile else False ) @@ -67,6 +68,7 @@ class ProfileMenu(AbstractSubMenu): def _select_profile(self, preset: Optional[Profile]) -> Optional[Profile]: profile = select_profile(preset) + if profile is not None: if not profile.is_graphic_driver_supported(): self._menu_options['gfx_driver'].set_enabled(False) @@ -105,12 +107,28 @@ class ProfileMenu(AbstractSubMenu): return driver + def _preview_gfx(self) -> Optional[str]: + driver: Optional[GfxDriver] = self._menu_options['gfx_driver'].current_selection + + if driver: + return driver.packages_text() + + return None + def _preview_profile(self) -> Optional[str]: profile: Optional[Profile] = self._menu_options['profile'].current_selection + text = '' if profile: - names = profile.current_selection_names() - return '\n'.join(names) + if (sub_profiles := profile.current_selection) is not None: + text += str(_('Selected profiles: ')) + text += ', '.join([p.name for p in sub_profiles]) + '\n' + + if packages := profile.packages_text(include_sub_packages=True): + text += f'{packages}' + + if text: + return text return None diff --git a/archinstall/lib/utils/util.py b/archinstall/lib/utils/util.py index 8df75ab1..2e42b3cf 100644 --- a/archinstall/lib/utils/util.py +++ b/archinstall/lib/utils/util.py @@ -31,18 +31,18 @@ def is_subpath(first: Path, second: Path): return False -def format_cols(items: List[str], header: Optional[str]) -> str: +def format_cols(items: List[str], header: Optional[str] = None) -> str: if header: text = f'{header}:\n' else: text = '' nr_items = len(items) - if nr_items <= 5: + if nr_items <= 4: col = 1 - elif nr_items <= 10: + elif nr_items <= 8: col = 2 - elif nr_items <= 15: + elif nr_items <= 12: col = 3 else: col = 4 -- cgit v1.2.3-54-g00ecf