How rpm-software-management/dnf works
Project type and purpose
• This repository implements Dandified YUM 4 (DNF4), a command-line package manager and Python API for RPM-based systems.
• It ties together Python modules (in the dnf/ tree) with native libraries (libsolv, hawkey, librepo, libcomps) to resolve dependencies, retrieve metadata, and drive RPM transactions.
High-level architecture inferred from the file tree and README
• Top-level executables (bin/dnf, bin/dnf-automatic) launch the Python runtime.
• The dnf/cli package parses arguments, dispatches subcommands, handles output.
• The “core engine” (packages like dnf/base.py, dnf/goal.py, dnf/query.py, dnf/transaction.py) implements dependency resolution, transaction building, I/O orchestration.
• Subsystems:
• Configuration subsystem (dnf/conf) reads /etc/dnf/*.conf.
• Repository subsystem (dnf/repo, hawkey/librepo) fetches and caches metadata.
• Dependency solver (dnf/rpm + libsolv/hawkey).
• Comps group handling (libcomps + dnf/comps.py).
• Module support (dnf/module).
• Database & history (dnf/db, SQLite for transaction history).
• Plugin/callback mechanism (dnf/plugin, dnf/callback.py) for extensibility.
• External/native components:
• libsolv/hawkey: dependency solving engine
• librepo: HTTP downloads of RPM and metadata
• libcomps: comps group parsing
• RPM C library: package installation, signature checking
• Persistence & caches:
• RPM database (on-disk)
• DNF metadata cache (~/.cache/dnf)
• SQLite history DB
a. Front-end: CLI layer
• Executables (bin/dnf-2, bin/dnf-3, dnf/cli/main.py)
• Option parser, command dispatcher, shell/completion helpers
b. Core engine
• Dependency graph builder (Goal)
• Query interface (Query, Subject, Selector)
• Transaction manager (Transaction, drpm)
c. Configuration manager
• Reads /etc/dnf/ + user overrides → produces settings object
d. Repository manager
• Uses librepo/hawkey → fetches metadata, exposes solvables
e. Dependency solver
• Calls into libsolv/hawkey via Python bindings in dnf/rpm
f. Comps & modules
• libcomps parser → group/module definitions → fed into the goal
g. Persistence
• SQLite for history (dnf/db)
• RPM database → via C-API bindings in dnf/rpm/connection.py
h. Plugin/callback pipeline
• Hooks at key events (pre-transaction, post-transaction, progress)
i. External services
• Remote repositories (HTTP/HTTPS)
• COPR or custom repos
j. Output/rendering
• Progress bars (dnf/cli/progress.py), formatters, completions
Architectural patterns & design principles
• Layered architecture: CLI → engine → external libs → persistence
• Adapter pattern: Python bindings wrap C/C++ libraries
• Observer/plugin pattern: dnf/plugin, dnf/callback.py
• Modular design: each subsystem in its own package (conf, cli, repo, rpm, module, automatic)
• Single responsibility: clear separation between parsing, solving, downloading, installing
Diagramming recommendations
• CLI → Engine
• Engine → Repo fetcher → Remote repos
• Engine → Solver → libsolv/hawkey
• Engine → Transaction → RPM C library → RPM database
• Engine → History subsystem → SQLite
• Engine → Plugin callbacks
• Python modules (e.g., light blue)
• Native libraries (e.g., orange)
• Rectangles for components/packages
• Clouds for external repositories
• Labels:
• Name each component (e.g., “CLI Dispatcher”, “Dependency Solver”)
• Call out key Python modules and native libs (librepo, libsolv, libcomps)