From e66560e3801526f3037106f5f032489eb6b8e0c4 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Sat, 24 May 2025 22:12:12 +1000 Subject: [PATCH 1/4] Add btrfs snapshot support --- archinstall/lib/disk/disk_menu.py | 83 ++++++++++++++++++++++++-- archinstall/lib/global_menu.py | 5 ++ archinstall/lib/installer.py | 46 ++++++++++++++ archinstall/lib/models/device_model.py | 65 +++++++++++++++++--- archinstall/scripts/guided.py | 7 +++ archinstall/tui/menu_item.py | 19 +++++- tests/data/test_config.json | 5 ++ tests/test_args.py | 5 +- 8 files changed, 220 insertions(+), 15 deletions(-) diff --git a/archinstall/lib/disk/disk_menu.py b/archinstall/lib/disk/disk_menu.py index a1afa565d8..45e7e5b0fe 100644 --- a/archinstall/lib/disk/disk_menu.py +++ b/archinstall/lib/disk/disk_menu.py @@ -1,9 +1,19 @@ from dataclasses import dataclass from typing import override -from archinstall.lib.models.device_model import DiskLayoutConfiguration, DiskLayoutType, LvmConfiguration +from archinstall.lib.models.device_model import ( + BtrfsOptions, + DiskLayoutConfiguration, + DiskLayoutType, + LvmConfiguration, + SnapshotConfig, + SnapshotType, +) from archinstall.lib.translationhandler import tr +from archinstall.tui.curses_menu import SelectMenu from archinstall.tui.menu_item import MenuItem, MenuItemGroup +from archinstall.tui.result import ResultType +from archinstall.tui.types import Alignment, FrameProperties from ..interactions.disk_conf import select_disk_config, select_lvm_config from ..menu.abstract_menu import AbstractSubMenu @@ -14,16 +24,24 @@ class DiskMenuConfig: disk_config: DiskLayoutConfiguration | None lvm_config: LvmConfiguration | None + btrfs_snapshot_config: SnapshotConfig | None class DiskLayoutConfigurationMenu(AbstractSubMenu[DiskLayoutConfiguration]): def __init__(self, disk_layout_config: DiskLayoutConfiguration | None): if not disk_layout_config: - self._disk_menu_config = DiskMenuConfig(disk_config=None, lvm_config=None) + self._disk_menu_config = DiskMenuConfig( + disk_config=None, + lvm_config=None, + btrfs_snapshot_config=None, + ) else: + snapshot_config = disk_layout_config.btrfs_options.snapshot_config if disk_layout_config.btrfs_options else None + self._disk_menu_config = DiskMenuConfig( disk_config=disk_layout_config, lvm_config=disk_layout_config.lvm_config, + btrfs_snapshot_config=snapshot_config, ) menu_optioons = self._define_menu_options() @@ -52,6 +70,14 @@ def _define_menu_options(self) -> list[MenuItem]: dependencies=[self._check_dep_lvm], key="lvm_config", ), + MenuItem( + text="Btrfs snapshots", + action=self._select_btrfs_snapshots, + value=self._disk_menu_config.btrfs_snapshot_config, + preview_action=self._prev_btrfs_snapshots, + dependencies=[self._check_dep_btrfs], + key="btrfs_snapshot_config", + ), ] @override @@ -60,6 +86,7 @@ def run(self) -> DiskLayoutConfiguration | None: if self._disk_menu_config.disk_config: self._disk_menu_config.disk_config.lvm_config = self._disk_menu_config.lvm_config + self._disk_menu_config.disk_config.btrfs_options = BtrfsOptions(snapshot_config=self._disk_menu_config.btrfs_snapshot_config) return self._disk_menu_config.disk_config return None @@ -72,10 +99,15 @@ def _check_dep_lvm(self) -> bool: return False - def _select_disk_layout_config( - self, - preset: DiskLayoutConfiguration | None, - ) -> DiskLayoutConfiguration | None: + def _check_dep_btrfs(self) -> bool: + disk_layout_conf: DiskLayoutConfiguration | None = self._menu_item_group.find_by_key("disk_config").value + + if disk_layout_conf: + return disk_layout_conf.is_default_btrfs() + + return False + + def _select_disk_layout_config(self, preset: DiskLayoutConfiguration | None) -> DiskLayoutConfiguration | None: disk_config = select_disk_config(preset) if disk_config != preset: @@ -91,6 +123,38 @@ def _select_lvm_config(self, preset: LvmConfiguration | None) -> LvmConfiguratio return preset + def _select_btrfs_snapshots(self, preset: SnapshotConfig | None) -> SnapshotConfig | None: + snapshot_type = preset.snapshot_type if preset else None + + group = MenuItemGroup.from_enum( + SnapshotType, + sort_items=True, + preset=snapshot_type, + ) + + result = SelectMenu[SnapshotType]( + group, + allow_reset=True, + allow_skip=True, + frame=FrameProperties.min(tr("Snapshot type")), + alignment=Alignment.CENTER, + ).run() + + snapshot_type: SnapshotType | None = None + + match result.type_: + case ResultType.Skip: + return preset + case ResultType.Reset: + return None + case ResultType.Selection: + snapshot_type = result.get_value() + + if not snapshot_type: + return None + + return SnapshotConfig(snapshot_type=snapshot_type) + def _prev_disk_layouts(self, item: MenuItem) -> str | None: if not item.value: return None @@ -146,3 +210,10 @@ def _prev_lvm_config(self, item: MenuItem) -> str | None: return output return None + + def _prev_btrfs_snapshots(self, item: MenuItem) -> str | None: + if not item.value: + return None + + snapshot_config: SnapshotConfig = item.value + return tr("Snapshot type: {}").format(snapshot_config.snapshot_type.value) diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py index b22e4b646f..35da351a5d 100644 --- a/archinstall/lib/global_menu.py +++ b/archinstall/lib/global_menu.py @@ -335,6 +335,11 @@ def _prev_disk_config(self, item: MenuItem) -> str | None: if disk_layout_conf.lvm_config: output += "{}: {}".format(tr("LVM configuration type"), disk_layout_conf.lvm_config.config_type.display_msg()) + if disk_layout_conf.btrfs_options: + btrfs_options = disk_layout_conf.btrfs_options + if btrfs_options.snapshot_config: + output += tr("Btrfs snapshot type: {}").format(btrfs_options.snapshot_config.snapshot_type.value) + return output return None diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index f3059f3f07..743396b906 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -25,6 +25,7 @@ PartitionModification, SectorSize, Size, + SnapshotType, SubvolumeModification, Unit, ) @@ -909,6 +910,51 @@ def minimal_installation( if hasattr(plugin, "on_install"): plugin.on_install(self) + def setup_btrfs_snapshot( + self, + snapshot_type: SnapshotType, + bootloader: Bootloader | None = None, + ) -> None: + if snapshot_type == SnapshotType.Snapper: + debug("Setting up Btrfs snapper") + self.pacman.strap("snapper") + + snapper: dict[str, str] = { + "root": "/", + "home": "/home", + } + + for config_name, mountpoint in snapper.items(): + command = [ + "arch-chroot", + str(self.target), + "snapper", + "--no-dbus", + "-c", + config_name, + "create-config", + mountpoint, + ] + + try: + SysCommand(command, peek_output=True) + except SysCallError as err: + raise DiskError(f"Could not setup Btrfs snapper: {err}") + + self.enable_service("snapper-timeline.timer") + self.enable_service("snapper-cleanup.timer") + elif snapshot_type == SnapshotType.Timeshift: + debug("Setting up Btrfs timeshift") + + self.pacman.strap("cronie") + self.pacman.strap("timeshift") + + self.enable_service("cronie.service") + + if bootloader and bootloader == Bootloader.Grub: + self.pacman.strap("grub-btrfs") + self.enable_service("grub-btrfs.service") + def setup_swap(self, kind: str = "zram") -> None: if kind == "zram": info("Setting up swap on zram") diff --git a/archinstall/lib/models/device_model.py b/archinstall/lib/models/device_model.py index a271f92b88..047d481ee7 100644 --- a/archinstall/lib/models/device_model.py +++ b/archinstall/lib/models/device_model.py @@ -47,6 +47,7 @@ class DiskLayoutConfiguration: config_type: DiskLayoutType device_modifications: list[DeviceModification] = field(default_factory=list) lvm_config: LvmConfiguration | None = None + btrfs_options: BtrfsOptions | None = None # used for pre-mounted config mountpoint: Path | None = None @@ -66,6 +67,9 @@ def json(self) -> _DiskLayoutConfigurationSerialization: if self.lvm_config: config["lvm_config"] = self.lvm_config.json() + if self.btrfs_options: + config["btrfs_options"] = self.btrfs_options.json() + return config @classmethod @@ -174,8 +178,22 @@ def parse_arg(cls, disk_config: _DiskLayoutConfigurationSerialization) -> DiskLa if (lvm_arg := disk_config.get("lvm_config", None)) is not None: config.lvm_config = LvmConfiguration.parse_arg(lvm_arg, config) + if config.is_default_btrfs(): + if (btrfs_arg := disk_config.get("btrfs_options", None)) is not None: + config.btrfs_options = BtrfsOptions.parse_arg(btrfs_arg) + return config + def is_default_btrfs(self) -> bool: + if self.config_type == DiskLayoutType.Default: + for mod in self.device_modifications: + for part in mod.partitions: + if part.is_create_or_modify(): + if part.fs_type == FilesystemType.Btrfs: + return True + + return False + class PartitionTable(Enum): GPT = "gpt" @@ -1309,13 +1327,46 @@ def get_root_volume(self) -> LvmVolume | None: return None -# def get_lv_crypt_uuid(self, lv: LvmVolume, encryption: EncryptionType) -> str: -# """ -# Find the LUKS superblock UUID for the device that -# contains the given logical volume -# """ -# for vg in self.vol_groups: -# if vg.contains_lv(lv): +class _BtrfsOptionsSerialization(TypedDict): + snapshot_config: _SnapshotConfigSerialization + + +class _SnapshotConfigSerialization(TypedDict): + enabled: bool + + +class SnapshotType(Enum): + Snapper = "Snapper" + Timeshift = "Timeshift" + + +@dataclass +class SnapshotConfig: + snapshot_type: SnapshotType + + def json(self) -> _SnapshotConfigSerialization: + return {"type": self.snapshot_type.value} + + @staticmethod + def parse_args(args: _SnapshotConfigSerialization) -> SnapshotConfig | None: + return SnapshotConfig(SnapshotType(args["type"])) + + +@dataclass +class BtrfsOptions: + snapshot_config: SnapshotConfig | None + + def json(self) -> _BtrfsOptionsSerialization: + return {"snapshot_config": self.snapshot_config.json() if self.snapshot_config else None} + + @staticmethod + def parse_arg(arg: _BtrfsOptionsSerialization) -> BtrfsOptions | None: + snapshot_args = arg.get("snapshot_config") + if snapshot_args: + snapshot_config = SnapshotConfig.parse_args(snapshot_args) + return BtrfsOptions(snapshot_config) + + return None class _DeviceModificationSerialization(TypedDict): diff --git a/archinstall/scripts/guided.py b/archinstall/scripts/guided.py index 2066169feb..990a31e3de 100644 --- a/archinstall/scripts/guided.py +++ b/archinstall/scripts/guided.py @@ -141,6 +141,13 @@ def perform_installation(mountpoint: Path) -> None: if servies := config.services: installation.enable_service(servies) + if disk_config.is_default_btrfs(): + btrfs_options = disk_config.btrfs_options + snapshot_config = btrfs_options.snapshot_config if btrfs_options else None + snapshot_type = snapshot_config.snapshot_type if snapshot_config else None + if snapshot_type: + installation.setup_btrfs_snapshot(snapshot_type, config.bootloader) + # If the user provided custom commands to be run post-installation, execute them now. if cc := config.custom_commands: run_custom_user_commands(cc, installation) diff --git a/archinstall/tui/menu_item.py b/archinstall/tui/menu_item.py index 77844c3d79..916268cb2b 100644 --- a/archinstall/tui/menu_item.py +++ b/archinstall/tui/menu_item.py @@ -2,13 +2,16 @@ from collections.abc import Callable from dataclasses import dataclass, field +from enum import Enum from functools import cached_property -from typing import Any, ClassVar +from typing import Any, ClassVar, TypeVar from archinstall.lib.translationhandler import tr from ..lib.utils.unicode import unicode_ljust +E = TypeVar("E", bound=Enum) + @dataclass class MenuItem: @@ -119,6 +122,20 @@ def yes_no() -> "MenuItemGroup": sort_items=True, ) + @staticmethod + def from_enum( + enum_cls: E, + sort_items: bool = False, + preset: E | None = None, + ) -> "MenuItemGroup": + items = [MenuItem(elem.value, value=elem) for elem in enum_cls] + group = MenuItemGroup(items, sort_items=False) + + if E is not None: + group.set_selected_by_value(preset) + + return group + def set_preview_for_all(self, action: Callable[[Any], str | None]) -> None: for item in self.items: item.preview_action = action diff --git a/tests/data/test_config.json b/tests/data/test_config.json index cdfd51b8a1..70c5c5c333 100644 --- a/tests/data/test_config.json +++ b/tests/data/test_config.json @@ -10,6 +10,11 @@ ], "disk_config": { "config_type": "default_layout", + "btrfs_options": { + "snapshot_config": { + "type": "Snapper" + } + }, "device_modifications": [ { "device": "/dev/sda", diff --git a/tests/test_args.py b/tests/test_args.py index 3467bd006e..fd3e695bec 100644 --- a/tests/test_args.py +++ b/tests/test_args.py @@ -8,7 +8,7 @@ from archinstall.lib.hardware import GfxDriver from archinstall.lib.models.audio_configuration import Audio, AudioConfiguration from archinstall.lib.models.bootloader import Bootloader -from archinstall.lib.models.device_model import DiskLayoutConfiguration, DiskLayoutType +from archinstall.lib.models.device_model import BtrfsOptions, DiskLayoutConfiguration, DiskLayoutType, SnapshotConfig, SnapshotType from archinstall.lib.models.locale import LocaleConfiguration from archinstall.lib.models.mirrors import CustomRepository, CustomServer, MirrorConfiguration, MirrorRegion, SignCheck, SignOption from archinstall.lib.models.network_configuration import NetworkConfiguration, Nic, NicType @@ -138,6 +138,9 @@ def test_config_file_parsing( device_modifications=[], lvm_config=None, mountpoint=None, + btrfs_options=BtrfsOptions( + snapshot_config=SnapshotConfig(SnapshotType.Snapper), + ), ), profile_config=ProfileConfiguration( profile=profile_handler.parse_profile_config( From 80a127e36ff3e1ab352e057f1fc551a7ac57f6e0 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Sat, 24 May 2025 22:20:58 +1000 Subject: [PATCH 2/4] Update --- archinstall/lib/disk/disk_menu.py | 4 ++-- archinstall/lib/models/device_model.py | 5 +++-- archinstall/tui/menu_item.py | 10 ++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/archinstall/lib/disk/disk_menu.py b/archinstall/lib/disk/disk_menu.py index 45e7e5b0fe..fcfdcd503f 100644 --- a/archinstall/lib/disk/disk_menu.py +++ b/archinstall/lib/disk/disk_menu.py @@ -124,12 +124,12 @@ def _select_lvm_config(self, preset: LvmConfiguration | None) -> LvmConfiguratio return preset def _select_btrfs_snapshots(self, preset: SnapshotConfig | None) -> SnapshotConfig | None: - snapshot_type = preset.snapshot_type if preset else None + preset_type = preset.snapshot_type if preset else None group = MenuItemGroup.from_enum( SnapshotType, sort_items=True, - preset=snapshot_type, + preset=preset_type, ) result = SelectMenu[SnapshotType]( diff --git a/archinstall/lib/models/device_model.py b/archinstall/lib/models/device_model.py index 047d481ee7..297dd598ee 100644 --- a/archinstall/lib/models/device_model.py +++ b/archinstall/lib/models/device_model.py @@ -40,6 +40,7 @@ class _DiskLayoutConfigurationSerialization(TypedDict): device_modifications: NotRequired[list[_DeviceModificationSerialization]] lvm_config: NotRequired[_LvmConfigurationSerialization] mountpoint: NotRequired[str] + btrfs_options: NotRequired[_BtrfsOptionsSerialization] @dataclass @@ -1328,11 +1329,11 @@ def get_root_volume(self) -> LvmVolume | None: class _BtrfsOptionsSerialization(TypedDict): - snapshot_config: _SnapshotConfigSerialization + snapshot_config: _SnapshotConfigSerialization | None class _SnapshotConfigSerialization(TypedDict): - enabled: bool + type: str class SnapshotType(Enum): diff --git a/archinstall/tui/menu_item.py b/archinstall/tui/menu_item.py index 916268cb2b..3cd9845f85 100644 --- a/archinstall/tui/menu_item.py +++ b/archinstall/tui/menu_item.py @@ -4,14 +4,12 @@ from dataclasses import dataclass, field from enum import Enum from functools import cached_property -from typing import Any, ClassVar, TypeVar +from typing import Any, ClassVar from archinstall.lib.translationhandler import tr from ..lib.utils.unicode import unicode_ljust -E = TypeVar("E", bound=Enum) - @dataclass class MenuItem: @@ -124,14 +122,14 @@ def yes_no() -> "MenuItemGroup": @staticmethod def from_enum( - enum_cls: E, + enum_cls: type[Enum], sort_items: bool = False, - preset: E | None = None, + preset: Enum | None = None, ) -> "MenuItemGroup": items = [MenuItem(elem.value, value=elem) for elem in enum_cls] group = MenuItemGroup(items, sort_items=False) - if E is not None: + if preset is not None: group.set_selected_by_value(preset) return group From f8c979f77d3c58ddac1d941972330f38c40c92b5 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Sat, 24 May 2025 22:43:14 +1000 Subject: [PATCH 3/4] Update --- tests/conftest.py | 5 + tests/data/test_config_btrfs.json | 180 ++++++++++++++++++++++++++++++ tests/test_args.py | 40 ++++++- 3 files changed, 222 insertions(+), 3 deletions(-) create mode 100644 tests/data/test_config_btrfs.json diff --git a/tests/conftest.py b/tests/conftest.py index 2f5a18e079..6e94f06cda 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,6 +8,11 @@ def config_fixture() -> Path: return Path(__file__).parent / 'data' / 'test_config.json' +@pytest.fixture(scope='session') +def btrfs_config_fixture() -> Path: + return Path(__file__).parent / 'data' / 'test_config_btrfs.json' + + @pytest.fixture(scope='session') def creds_fixture() -> Path: return Path(__file__).parent / 'data' / 'test_creds.json' diff --git a/tests/data/test_config_btrfs.json b/tests/data/test_config_btrfs.json new file mode 100644 index 0000000000..66f2639bd6 --- /dev/null +++ b/tests/data/test_config_btrfs.json @@ -0,0 +1,180 @@ +{ + "archinstall-language": "English", + "audio_config": { + "audio": "pipewire" + }, + "bootloader": "Systemd-boot", + "services": [ + "service_1", + "service_2" + ], + "disk_config": { + "btrfs_options": { + "snapshot_config": { + "type": "Timeshift" + } + }, + "config_type": "default_layout", + "device_modifications": [ + { + "device": "/dev/loop0", + "partitions": [ + { + "btrfs": [], + "dev_path": null, + "flags": [ + "boot", + "esp" + ], + "fs_type": "fat32", + "mount_options": [], + "mountpoint": "/boot", + "obj_id": "d2fa4a62-8793-463c-8db2-a5616a1afbd3", + "size": { + "sector_size": { + "unit": "B", + "value": 512 + }, + "unit": "GiB", + "value": 1 + }, + "start": { + "sector_size": { + "unit": "B", + "value": 512 + }, + "unit": "MiB", + "value": 1 + }, + "status": "create", + "type": "primary" + }, + { + "btrfs": [ + { + "mountpoint": "/", + "name": "@" + }, + { + "mountpoint": "/home", + "name": "@home" + }, + { + "mountpoint": "/var/log", + "name": "@log" + }, + { + "mountpoint": "/var/cache/pacman/pkg", + "name": "@pkg" + } + ], + "dev_path": null, + "flags": [], + "fs_type": "btrfs", + "mount_options": [ + "compress=zstd" + ], + "mountpoint": null, + "obj_id": "2fdfd496-7546-44f4-bd60-6430866ba341", + "size": { + "sector_size": { + "unit": "B", + "value": 512 + }, + "unit": "B", + "value": 63348670464 + }, + "start": { + "sector_size": { + "unit": "B", + "value": 512 + }, + "unit": "B", + "value": 1074790400 + }, + "status": "create", + "type": "primary" + } + ], + "wipe": true + } + ] + }, + "hostname": "archy", + "kernels": [ + "linux-zen" + ], + "locale_config": { + "kb_layout": "us", + "sys_enc": "UTF-8", + "sys_lang": "en_US" + }, + "mirror_config": { + "custom_servers": [ + { + "url": "https://mymirror.com/$repo/os/$arch" + } + ], + "mirror_regions": { + "Australia": [ + "http://archlinux.mirror.digitalpacific.com.au/$repo/os/$arch" + ] + }, + "optional_repositories": [ + "testing" + ], + "custom_repositories": [ + { + "name": "myrepo", + "url": "https://myrepo.com/$repo/os/$arch", + "sign_check": "Required", + "sign_option": "TrustAll" + } + ] + }, + "network_config": { + "type": "manual", + "nics": [ + { + "iface": "eno1", + "ip": "192.168.1.15/24", + "dhcp": true, + "gateway": "192.168.1.1", + "dns": [ + "192.168.1.1", + "9.9.9.9" + ] + } + ] + }, + "ntp": true, + "packages": [ + "firefox" + ], + "parallel_downloads": 66, + "profile_config": { + "gfx_driver": "All open-source", + "greeter": "lightdm-gtk-greeter", + "profile": { + "custom_settings": { + "Hyprland": { + "seat_access": "polkit" + }, + "Sway": { + "seat_access": "seatd" + } + }, + "details": [ + "Sway", + "Hyprland" + ], + "main": "Desktop" + } + }, + "custom_commands": [ + "echo 'Hello, World!'" + ], + "swap": false, + "timezone": "UTC", + "version": "3.0.2" +} diff --git a/tests/test_args.py b/tests/test_args.py index 8dc5d30b3c..4eeb14460a 100644 --- a/tests/test_args.py +++ b/tests/test_args.py @@ -138,9 +138,6 @@ def test_config_file_parsing( device_modifications=[], lvm_config=None, mountpoint=None, - btrfs_options=BtrfsOptions( - snapshot_config=SnapshotConfig(SnapshotType.Snapper), - ), ), profile_config=ProfileConfiguration( profile=profile_handler.parse_profile_config( @@ -221,6 +218,43 @@ def test_config_file_parsing( ) +def test_btrfs_config_file_parsing( + monkeypatch: MonkeyPatch, + config_fixture: Path, + btrfs_config_fixture: Path, +) -> None: + monkeypatch.setattr( + 'sys.argv', + [ + 'archinstall', + '--config', + str(btrfs_config_fixture), + ], + ) + + handler = ArchConfigHandler() + arch_config = handler.config + + # the version is retrieved dynamically from an installed archinstall package + # as there is no version present in the test environment we'll set it manually + arch_config.version = '3.0.2' + + # TODO: Use the real values from the test fixture instead of clearing out the entries + arch_config.disk_config.device_modifications = [] # type: ignore[union-attr] + + assert arch_config.disk_config == DiskLayoutConfiguration( + config_type=DiskLayoutType.Default, + device_modifications=[], + lvm_config=None, + mountpoint=None, + btrfs_options=BtrfsOptions( + snapshot_config=SnapshotConfig( + SnapshotType.Timeshift, + ), + ), + ) + + def test_deprecated_mirror_config_parsing( monkeypatch: MonkeyPatch, deprecated_mirror_config: Path, From 16971f30fa8d50cdafc34cb0d0d6103f430d98ab Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Sun, 25 May 2025 17:10:54 +1000 Subject: [PATCH 4/4] Update --- tests/data/test_config_btrfs.json | 180 ------------------------------ tests/test_args.py | 39 +------ 2 files changed, 1 insertion(+), 218 deletions(-) delete mode 100644 tests/data/test_config_btrfs.json diff --git a/tests/data/test_config_btrfs.json b/tests/data/test_config_btrfs.json deleted file mode 100644 index 66f2639bd6..0000000000 --- a/tests/data/test_config_btrfs.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "archinstall-language": "English", - "audio_config": { - "audio": "pipewire" - }, - "bootloader": "Systemd-boot", - "services": [ - "service_1", - "service_2" - ], - "disk_config": { - "btrfs_options": { - "snapshot_config": { - "type": "Timeshift" - } - }, - "config_type": "default_layout", - "device_modifications": [ - { - "device": "/dev/loop0", - "partitions": [ - { - "btrfs": [], - "dev_path": null, - "flags": [ - "boot", - "esp" - ], - "fs_type": "fat32", - "mount_options": [], - "mountpoint": "/boot", - "obj_id": "d2fa4a62-8793-463c-8db2-a5616a1afbd3", - "size": { - "sector_size": { - "unit": "B", - "value": 512 - }, - "unit": "GiB", - "value": 1 - }, - "start": { - "sector_size": { - "unit": "B", - "value": 512 - }, - "unit": "MiB", - "value": 1 - }, - "status": "create", - "type": "primary" - }, - { - "btrfs": [ - { - "mountpoint": "/", - "name": "@" - }, - { - "mountpoint": "/home", - "name": "@home" - }, - { - "mountpoint": "/var/log", - "name": "@log" - }, - { - "mountpoint": "/var/cache/pacman/pkg", - "name": "@pkg" - } - ], - "dev_path": null, - "flags": [], - "fs_type": "btrfs", - "mount_options": [ - "compress=zstd" - ], - "mountpoint": null, - "obj_id": "2fdfd496-7546-44f4-bd60-6430866ba341", - "size": { - "sector_size": { - "unit": "B", - "value": 512 - }, - "unit": "B", - "value": 63348670464 - }, - "start": { - "sector_size": { - "unit": "B", - "value": 512 - }, - "unit": "B", - "value": 1074790400 - }, - "status": "create", - "type": "primary" - } - ], - "wipe": true - } - ] - }, - "hostname": "archy", - "kernels": [ - "linux-zen" - ], - "locale_config": { - "kb_layout": "us", - "sys_enc": "UTF-8", - "sys_lang": "en_US" - }, - "mirror_config": { - "custom_servers": [ - { - "url": "https://mymirror.com/$repo/os/$arch" - } - ], - "mirror_regions": { - "Australia": [ - "http://archlinux.mirror.digitalpacific.com.au/$repo/os/$arch" - ] - }, - "optional_repositories": [ - "testing" - ], - "custom_repositories": [ - { - "name": "myrepo", - "url": "https://myrepo.com/$repo/os/$arch", - "sign_check": "Required", - "sign_option": "TrustAll" - } - ] - }, - "network_config": { - "type": "manual", - "nics": [ - { - "iface": "eno1", - "ip": "192.168.1.15/24", - "dhcp": true, - "gateway": "192.168.1.1", - "dns": [ - "192.168.1.1", - "9.9.9.9" - ] - } - ] - }, - "ntp": true, - "packages": [ - "firefox" - ], - "parallel_downloads": 66, - "profile_config": { - "gfx_driver": "All open-source", - "greeter": "lightdm-gtk-greeter", - "profile": { - "custom_settings": { - "Hyprland": { - "seat_access": "polkit" - }, - "Sway": { - "seat_access": "seatd" - } - }, - "details": [ - "Sway", - "Hyprland" - ], - "main": "Desktop" - } - }, - "custom_commands": [ - "echo 'Hello, World!'" - ], - "swap": false, - "timezone": "UTC", - "version": "3.0.2" -} diff --git a/tests/test_args.py b/tests/test_args.py index 4eeb14460a..e6308925e9 100644 --- a/tests/test_args.py +++ b/tests/test_args.py @@ -8,7 +8,7 @@ from archinstall.lib.hardware import GfxDriver from archinstall.lib.models.audio_configuration import Audio, AudioConfiguration from archinstall.lib.models.bootloader import Bootloader -from archinstall.lib.models.device_model import BtrfsOptions, DiskLayoutConfiguration, DiskLayoutType, SnapshotConfig, SnapshotType +from archinstall.lib.models.device_model import DiskLayoutConfiguration, DiskLayoutType from archinstall.lib.models.locale import LocaleConfiguration from archinstall.lib.models.mirrors import CustomRepository, CustomServer, MirrorConfiguration, MirrorRegion, SignCheck, SignOption from archinstall.lib.models.network_configuration import NetworkConfiguration, Nic, NicType @@ -218,43 +218,6 @@ def test_config_file_parsing( ) -def test_btrfs_config_file_parsing( - monkeypatch: MonkeyPatch, - config_fixture: Path, - btrfs_config_fixture: Path, -) -> None: - monkeypatch.setattr( - 'sys.argv', - [ - 'archinstall', - '--config', - str(btrfs_config_fixture), - ], - ) - - handler = ArchConfigHandler() - arch_config = handler.config - - # the version is retrieved dynamically from an installed archinstall package - # as there is no version present in the test environment we'll set it manually - arch_config.version = '3.0.2' - - # TODO: Use the real values from the test fixture instead of clearing out the entries - arch_config.disk_config.device_modifications = [] # type: ignore[union-attr] - - assert arch_config.disk_config == DiskLayoutConfiguration( - config_type=DiskLayoutType.Default, - device_modifications=[], - lvm_config=None, - mountpoint=None, - btrfs_options=BtrfsOptions( - snapshot_config=SnapshotConfig( - SnapshotType.Timeshift, - ), - ), - ) - - def test_deprecated_mirror_config_parsing( monkeypatch: MonkeyPatch, deprecated_mirror_config: Path,