Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:ARCANGEL0 EVA Package Management Abstraction

From Leeroopedia
Knowledge Sources
Domains System_Administration, Tool_Installation, Cross_Platform
Last Updated 2026-10-29 14:00 GMT

Overview

Abstraction for detecting and operating across heterogeneous Linux package managers — apt-get, pacman, dnf, zypper, apk, yum — with distro-aware preference, ecosystem install methods, and managed installation tracking.

Description

Linux distributions use different package managers (APT for Debian/Ubuntu, Pacman for Arch, DNF for Fedora, etc.). A package management abstraction layer:

  1. Detects the host environment: Reads `/etc/os-release` to identify the distribution and selects the preferred package manager.
  2. Queries package status: Uses distro-appropriate commands (`dpkg-query`, `pacman -Q`, `rpm -q`, `apk info`) to check if a package is installed.
  3. Generates install commands: Produces correct package manager invocations for install/uninstall operations.
  4. Supports ecosystem methods: Falls back to ecosystem installers (Go, Cargo, pipx, gem, git clone, official scripts) when native packages are unavailable.
  5. Tracks managed installs: Records which tools the framework installed and via which method, enabling clean uninstall.

This principle enables the framework to install 165+ security tools across any Linux distribution without hardcoding distro-specific logic into each tool definition.

Usage

Apply this principle when:

  • Building cross-distribution tooling that needs to install or query packages.
  • Supporting multiple install ecosystems (native packages, Go, Cargo, pipx, etc.).
  • Needing to track and reverse managed installations.
  • Detecting which package manager is available on an unknown host.

Theoretical Basis

The detection follows a preference-ordered search:

# Abstract algorithm (NOT real implementation)
def detect_host():
    os_id = parse_os_release()["ID"]
    preferred = DISTRO_PREFERENCES.get(os_id)  # e.g., "ubuntu" -> "apt-get"
    for manager in sort_by_preference(ALL_MANAGERS, preferred):
        if shutil.which(manager):
            return HostEnvironment(os_id, os_name, manager, ...)
    return HostEnvironment(os_id, os_name, "", "Unavailable")

Install method selection tries native packages first, then ecosystem methods:

# Abstract algorithm (NOT real implementation)
def select_method(tool, environment):
    if package_available(environment.manager, tool.packages[environment.manager]):
        return f"system:{environment.manager}:{package}"
    for method in tool.install_methods:
        if method_runtime_available(method):
            return method.id
    raise NoInstallSourceError

Practical Guide

  • Read `/etc/os-release` for distro identification — it's the Linux Standard Base.
  • Order managers by distro preference so the right one is tried first.
  • Generate shell scripts, not direct commands — the operator sees and approves the full script.
  • Report privileged commands separately for operator transparency (sudo requirements).
  • Track managed installs in a JSON registry so uninstall is safe and verified.
  • Verify ownership before uninstalling source-based installs (check a marker file).

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment