Skip to content

replace hard coded distro-name checks with platform capability detect #26

Description

@VectorSophie

Summary

replace distribution-name-specific behavior with a platform capability abstraction.

LUD currently contains logic that identifies distributions using checks such as Ubuntu vs Pop!_OS and otherwise falls back to Unknown.

other actions implicitly assume particular components such as:

  • APT
  • GRUB
  • update-grub
  • kernelstub
  • systemd
  • GNOME/gsettings
  • Debian package formats

makes behavior depend on distro names even when the actual requirement is a particular package manager, boot configuration system, init system, desktop environment or system capability.

So what

introduce a platform abstraction that detects the facilities available on the host and allows actions to declare what they require.

example:

Platform
├── package manager
│   ├── apt
│   ├── dnf
│   ├── pacman
│   └── unsupported
├── boot configuration
│   ├── grub
│   ├── kernelstub
│   ├── systemd-boot
│   └── unsupported
├── init
│   ├── systemd
│   └── unsupported
├── desktop/settings
│   ├── GNOME
│   ├── KDE
│   └── other
└── audio/session stack
    ├── PipeWire
    ├── PulseAudio
    └── unknown

actions could check a capability instead of a distro name.

example:

instead of:

if distribution == "Ubuntu":
    ...

behavior should resemble:

if platform.has("glib-compile-schemas"):
    ...

or:

platform.package_manager.install(...)

similar, kernel command-line changes should target a detected boot configuration backend instead of assuming /etc/default/grub.

Proposal

Platform detect

centralized object/module responsible for determining:

  • OS metadata
  • package manager
  • boot configuration backend
  • init/service manager
  • relevant desktop configuration backend
  • available helper commands

Package BE

initial implementation:

AptBackend

future implementations may be:

PacmanBackend
DnfBackend

Boot BE

possible interface:

get_kernel_parameters()
add_kernel_parameters(...)
remove_kernel_parameters(...)
apply()

initial implementations could do:

  • GRUB
  • kernelstub

with systemd-boot added independently later.

Why

project is already being used beyond environment inherited from System76.

capability model would:

  • reduce distro-specific branching
  • prevent inappropriate commands on unsupported distributions
  • make support for additional distributions incremental
  • simplify testing
  • make --plan output more accurate
  • make hardware actions less coupled to Ubuntu/Pop!_OS assumptions

Tests

platform detect should use fixtures/mocks rather than depending on the CI host.

tests should cover representative environments such as:

  • Ubuntu + APT + GRUB
  • Pop!_OS + APT + kernelstub
  • Debian + APT + GRUB
  • non-Debian system with unsupported package backend
  • system without supported boot configuration

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions