Skip to content

system_info

appimage_updater.core.system_info

System information detection for Linux architecture and distribution compatibility.

This module provides comprehensive Linux system detection including architecture, distribution, and supported package formats to enable intelligent asset filtering and compatibility scoring. AppImage Updater is Linux-only.

SystemDetector() cached

Detects system information for compatibility checking.

Source code in src/appimage_updater/core/system_info.py
def __init__(self) -> None:
    """Initialize system detector."""
    self._system_info: SystemInfo | None = None

get_system_info()

Get cached system information.

Source code in src/appimage_updater/core/system_info.py
def get_system_info(self) -> SystemInfo:
    """Get cached system information."""
    if self._system_info is None:
        self._system_info = self._detect_system_info()
    return self._system_info

SystemInfo(platform, architecture, architecture_aliases, machine, supported_formats, distribution=None, distribution_family=None, distribution_version=None, distribution_version_numeric=None) dataclass

Comprehensive system information.

architecture instance-attribute

architecture_aliases instance-attribute

distribution = None class-attribute instance-attribute

distribution_family = None class-attribute instance-attribute

distribution_version = None class-attribute instance-attribute

distribution_version_numeric = None class-attribute instance-attribute

machine instance-attribute

platform instance-attribute

supported_formats instance-attribute

get_system_info()

Get system information (cached).

Source code in src/appimage_updater/core/system_info.py
def get_system_info() -> SystemInfo:
    """Get system information (cached)."""
    return SystemDetector().get_system_info()

is_compatible_architecture(asset_arch, system_arch=None)

Check if an asset architecture is compatible with the system.

Parameters:

Name Type Description Default
asset_arch str

Architecture found in asset filename

required
system_arch str | None

System architecture (uses detected if None)

None

Returns:

Name Type Description
bool

Tuple of (is_compatible, compatibility_score)

Score float

100=exact, 80=compatible, 0=incompatible

Source code in src/appimage_updater/core/system_info.py
def is_compatible_architecture(asset_arch: str, system_arch: str | None = None) -> tuple[bool, float]:
    """Check if an asset architecture is compatible with the system.

    Args:
        asset_arch: Architecture found in asset filename
        system_arch: System architecture (uses detected if None)

    Returns:
        Tuple of (is_compatible, compatibility_score)
        Score: 100=exact, 80=compatible, 0=incompatible
    """
    if system_arch is None:
        system_info = get_system_info()
        system_arch = system_info.architecture
        arch_aliases = system_info.architecture_aliases
    else:
        # Create temporary aliases for provided system_arch
        arch_mapping = {
            "x86_64": {"x86_64", "amd64", "x64"},
            "arm64": {"arm64", "aarch64"},
            "armv7": {"armv7", "armv7l", "armhf"},
            "i686": {"i386", "i686", "x86"},
        }
        arch_aliases = arch_mapping.get(system_arch, {system_arch})

    asset_arch_lower = asset_arch.lower()

    # Exact match
    if asset_arch_lower == system_arch.lower():
        return True, 100.0

    # Alias match
    if asset_arch_lower in {alias.lower() for alias in arch_aliases}:
        return True, 80.0

    # No match
    return False, 0.0

is_compatible_platform(asset_platform, system_platform=None)

Check if an asset platform is compatible with Linux.

Parameters:

Name Type Description Default
asset_platform str

Platform found in asset filename

required
system_platform str | None

System platform (should be 'linux')

None

Returns:

Name Type Description
bool

Tuple of (is_compatible, compatibility_score)

Score float

100=exact, 0=incompatible

Source code in src/appimage_updater/core/system_info.py
def is_compatible_platform(asset_platform: str, system_platform: str | None = None) -> tuple[bool, float]:
    """Check if an asset platform is compatible with Linux.

    Args:
        asset_platform: Platform found in asset filename
        system_platform: System platform (should be 'linux')

    Returns:
        Tuple of (is_compatible, compatibility_score)
        Score: 100=exact, 0=incompatible
    """
    if system_platform is None:
        system_info = get_system_info()
        system_platform = system_info.platform

    # Only Linux platform is supported
    if system_platform != "linux":
        raise RuntimeError(f"AppImage Updater only supports Linux. System platform: {system_platform}")

    # Platform compatibility - only Linux assets are compatible
    is_compatible = asset_platform.lower() == "linux"
    return is_compatible, (100.0 if is_compatible else 0.0)

is_supported_format(file_extension, system_platform=None)

Check if a file format is supported on Linux.

Parameters:

Name Type Description Default
file_extension str

File extension (e.g., '.deb', '.AppImage')

required
system_platform str | None

System platform (should be 'linux')

None

Returns:

Name Type Description
bool

Tuple of (is_supported, preference_score)

Score float

100=preferred, 80=supported, 0=unsupported

Source code in src/appimage_updater/core/system_info.py
def is_supported_format(file_extension: str, system_platform: str | None = None) -> tuple[bool, float]:
    """Check if a file format is supported on Linux.

    Args:
        file_extension: File extension (e.g., '.deb', '.AppImage')
        system_platform: System platform (should be 'linux')

    Returns:
        Tuple of (is_supported, preference_score)
        Score: 100=preferred, 80=supported, 0=unsupported
    """
    if system_platform is None:
        system_info = get_system_info()
        supported_formats = system_info.supported_formats
    else:
        # Only Linux is supported
        if system_platform != "linux":
            raise RuntimeError(f"AppImage Updater only supports Linux. Platform: {system_platform}")
        # Create temporary supported formats for Linux
        detector: SystemDetector = SystemDetector()
        supported_formats = detector._detect_supported_formats(system_platform)

    # Case-insensitive format checking
    file_extension_lower = file_extension.lower()
    supported_formats_lower = {fmt.lower() for fmt in supported_formats}

    if file_extension_lower not in supported_formats_lower:
        return False, 0.0

    # Format preferences for Linux (case-insensitive keys)
    linux_preferences = {
        ".appimage": 70.0,  # Preferred for AppImage Updater
        ".deb": 65.0,  # Native package format for Debian-based
        ".rpm": 65.0,  # Native package format for RPM-based
        ".tar.gz": 50.0,  # Generic archive
        ".tar.xz": 50.0,  # Generic archive
        ".zip": 45.0,  # Generic archive
    }

    score = linux_preferences.get(file_extension_lower, 50.0)  # Default supported score
    return True, score