from abc import ABC, abstractmethod from pathlib import Path from typing import List, Optional from linux_updater.models import PackageUpdate, CommandResult, RebootStatus class PackageManager(ABC): @property @abstractmethod def name(self) -> str: """Returns the identifier of the package manager (e.g. 'apt', 'dnf', 'pacman').""" pass @abstractmethod def refresh_repositories(self) -> CommandResult: """Synchronizes repository metadata.""" pass @abstractmethod def check_updates(self) -> List[PackageUpdate]: """Lists available package updates.""" pass @abstractmethod def apply_updates( self, packages: Optional[List[str]] = None, dry_run: bool = False, non_interactive: bool = False, ) -> CommandResult: """Applies package updates.""" pass @abstractmethod def release_upgrade( self, target_release: Optional[str] = None, non_interactive: bool = False, ) -> CommandResult: """Executes a major OS distribution upgrade.""" pass @abstractmethod def clean_cache(self) -> CommandResult: """Cleans downloaded package cache.""" pass @abstractmethod def autoremove(self) -> CommandResult: """Removes unneeded dependency packages.""" pass @abstractmethod def is_reboot_required(self) -> RebootStatus: """Detects whether a system reboot is required.""" pass @abstractmethod def get_lock_files(self) -> List[Path]: """Returns paths of lockfiles used by this manager.""" pass