Files
linux-updater/linux_updater/managers/base.py
T
soda64 8bec4ed932
Build and Publish Release / Build Packages and Publish (push) Successful in 27s
feat: release v2.0.0 with tab completion, package filtering, db health checks, flatpak and logrotate
2026-10-03 08:31:00 +02:00

77 lines
2.2 KiB
Python

from abc import ABC, abstractmethod
from pathlib import Path
from typing import List, Optional, Tuple
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,
exclude: Optional[List[str]] = None,
security_only: bool = False,
) -> List[PackageUpdate]:
"""Lists available package updates."""
pass
@abstractmethod
def apply_updates(
self,
packages: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
security_only: bool = False,
dry_run: bool = False,
non_interactive: bool = False,
) -> CommandResult:
"""Applies package updates."""
pass
@abstractmethod
def release_upgrade(
self,
target_release: Optional[str] = None,
dry_run: bool = False,
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
def verify_db_consistency(self) -> "Tuple[bool, str]":
"""Checks whether the package manager database has broken/interrupted transactions."""
return True, "Package database is consistent."
def repair_db(self) -> CommandResult:
"""Attempts automated repair of interrupted/broken package transactions."""
return CommandResult(0, "No repair needed.", "", True)