This commit introduces a large-scale structural refactor of the pkgmgr
codebase. All functionality has been moved from the previous flat
top-level layout into three clearly separated namespaces:
• pkgmgr.actions – high-level operations invoked by the CLI
• pkgmgr.core – pure logic, helpers, repository utilities,
versioning, git helpers, config IO, and
command resolution
• pkgmgr.cli – parser, dispatch, context, and command
handlers
Key improvements:
- Moved all “branch”, “release”, “changelog”, repo-management
actions, installer pipelines, and proxy execution logic into
pkgmgr.actions.<domain>.
- Reworked installer structure under
pkgmgr.actions.repository.install.installers
including OS-package installers, Nix, Python, and Makefile.
- Consolidated all low-level functionality under pkgmgr.core:
• git helpers → core/git
• config load/save → core/config
• repository helpers → core/repository
• versioning & semver → core/version
• command helpers (alias, resolve, run, ink) → core/command
- Replaced pkgmgr.cli_core with pkgmgr.cli and updated all imports.
- Added minimal __init__.py files for clean package exposure.
- Updated all E2E, integration, and unit tests with new module paths.
- Fixed patch targets so mocks point to the new structure.
- Ensured backward compatibility at the CLI boundary (pkgmgr entry point unchanged).
This refactor produces a cleaner, layered architecture:
- `core` = logic
- `actions` = orchestrated behaviour
- `cli` = user interface
Reference: ChatGPT-assisted refactor discussion
https://chatgpt.com/share/6938221c-e24c-800f-8317-7732cedf39b9
70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Base interface for all installer components in the pkgmgr installation pipeline.
|
|
"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Set
|
|
|
|
from pkgmgr.actions.repository.install.context import RepoContext
|
|
from pkgmgr.actions.repository.install.capabilities import CAPABILITY_MATCHERS
|
|
|
|
|
|
class BaseInstaller(ABC):
|
|
"""
|
|
A single step in the installation pipeline for a repository.
|
|
|
|
Implementations should be small and focused on one technology or manifest
|
|
type (e.g. PKGBUILD, Nix, Python, Makefile, etc.).
|
|
"""
|
|
|
|
#: Logical layer name for this installer.
|
|
# Examples: "nix", "python", "makefile".
|
|
# This is used by capability matchers to decide which patterns to
|
|
# search for in the repository.
|
|
layer: str | None = None
|
|
|
|
def discover_capabilities(self, ctx: RepoContext) -> Set[str]:
|
|
"""
|
|
Determine which logical capabilities this installer will provide
|
|
for this specific repository instance.
|
|
|
|
This method delegates to the global capability matchers, which
|
|
inspect build/configuration files (flake.nix, pyproject.toml,
|
|
Makefile, etc.) and decide, via string matching, whether a given
|
|
capability is actually provided by this layer.
|
|
"""
|
|
caps: Set[str] = set()
|
|
if not self.layer:
|
|
return caps
|
|
|
|
for matcher in CAPABILITY_MATCHERS:
|
|
if matcher.applies_to_layer(self.layer) and matcher.is_provided(ctx, self.layer):
|
|
caps.add(matcher.name)
|
|
|
|
return caps
|
|
|
|
@abstractmethod
|
|
def supports(self, ctx: RepoContext) -> bool:
|
|
"""
|
|
Return True if this installer should run for the given repository
|
|
context. This is typically based on file existence or platform checks.
|
|
|
|
Implementations must never swallow critical errors silently; if a
|
|
configuration is broken, they should raise SystemExit.
|
|
"""
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def run(self, ctx: RepoContext) -> None:
|
|
"""
|
|
Execute the installer logic for the given repository context.
|
|
|
|
Implementations are allowed to raise SystemExit (for example via
|
|
run_command()) on errors. Such failures are considered fatal for
|
|
the installation pipeline.
|
|
"""
|
|
raise NotImplementedError
|