ahriman.core.repository package

Submodules

ahriman.core.repository.cleaner module

class Cleaner(repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool, refresh_pacman_database: PacmanSynchronization)

Bases: RepositoryProperties

trait to clean common repository objects

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • database (SQLite) – database instance

  • report (bool) – force enable or disable reporting

  • refresh_pacman_database (PacmanSynchronization) – pacman database synchronization level

clear_cache() None

clear cache directory

clear_chroot() None

clear cache directory. Warning: this method is architecture independent and will clear every chroot

clear_packages() None

clear directory with built packages (NOT repository itself)

clear_pacman() None

clear directory with pacman databases

clear_queue() None

clear packages which were queued for the update

packages_built() list[Path]

get list of files in built packages directory

Returns:

list of filenames from the directory

Return type:

list[Path]

Raises:

NotImplementedError – not implemented method

ahriman.core.repository.event_logger module

class EventLogger

Bases: object

wrapper for logging events

reporter

build status reporter instance

Type:

Client

event(package_base: str, event: EventType, message: str | None = None) None

log single event. For timed events use context manager in_event() instead

Parameters:
  • package_base (str) – package base name

  • event (EventType) – event type to be logged on success action

  • message (str | None, optional) – optional message describing the action (Default value = None)

Examples

This method must be used as simple wrapper for ahriman.core.status.Client methods, e.g.:

>>> do_something()
>>> self.event(package_base, EventType.PackageUpdated)
in_event(package_base: str, event: EventType, message: str | None = None, failure: EventType | None = None) Iterator[None]

perform action in package context and log event with time elapsed

Parameters:
  • package_base (str) – package base name

  • event (EventType) – event type to be logged on success action

  • message (str | None, optional) – optional message describing the action (Default value = None)

  • failure (EventType | None, optional) – event type to be logged on exception (Default value = None)

Examples

This method must be used to perform action in context with time measurement:

>>> with self.in_event(package_base, EventType.PackageUpdated):
>>>     do_something()

Additional parameter failure can be set in order to emit an event on exception occurred. If none set (default), then no event will be recorded on exception

ahriman.core.repository.executor module

class Executor(repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool, refresh_pacman_database: PacmanSynchronization)

Bases: PackageInfo, Cleaner

trait for common repository update processes

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • database (SQLite) – database instance

  • report (bool) – force enable or disable reporting

  • refresh_pacman_database (PacmanSynchronization) – pacman database synchronization level

process_build(updates: Iterable[Package], packagers: Packagers | None = None, *, bump_pkgrel: bool = False) Result

build packages

Parameters:
  • updates (Iterable[Package]) – list of packages properties to build

  • packagers (Packagers | None, optional) – optional override of username for build process (Default value = None)

  • bump_pkgrel (bool, optional) – bump pkgrel in case of local version conflict (Default value = False)

Returns:

build result

Return type:

Result

process_remove(packages: Iterable[str]) Result

remove packages from list

Parameters:

packages (Iterable[str]) – list of package names or bases to remove

Returns:

remove result

Return type:

Result

process_update(packages: Iterable[Path], packagers: Packagers | None = None) Result

sign packages, add them to repository and update repository database

Parameters:
  • packages (Iterable[Path]) – list of filenames to run

  • packagers (Packagers | None, optional) – optional override of username for build process (Default value = None)

Returns:

path to repository database

Return type:

Result

ahriman.core.repository.explorer module

class Explorer

Bases: object

helper to read filesystem and find created repositories

static repositories_extract(configuration: Configuration, repository: str | None = None, architecture: str | None = None) list[RepositoryId]

get known architectures

Parameters:
  • configuration (Configuration) – configuration instance

  • repository (str | None, optional) – predefined repository name if available (Default value = None)

  • architecture (str | None, optional) – predefined repository architecture if available (Default value = None)

Returns:

list of repository names and architectures for which tree is created

Return type:

list[RepositoryId]

ahriman.core.repository.package_info module

class PackageInfo(repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool, refresh_pacman_database: PacmanSynchronization)

Bases: RepositoryProperties

handler for the package information

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • database (SQLite) – database instance

  • report (bool) – force enable or disable reporting

  • refresh_pacman_database (PacmanSynchronization) – pacman database synchronization level

full_depends(package: Package, packages: Iterable[Package]) list[str]

generate full dependencies list including transitive dependencies

Parameters:
  • package (Package) – package to check dependencies for

  • packages (Iterable[Package]) – repository package list

Returns:

all dependencies of the package

Return type:

list[str]

load_archives(packages: Iterable[Path]) list[Package]

load packages from list of archives

Parameters:

packages (Iterable[Path]) – paths to package archives

Returns:

list of read packages

Return type:

list[Package]

package_changes(package: Package, last_commit_sha: str | None) Changes

extract package change for the package since last commit if available

Parameters:
  • package (Package) – package properties

  • last_commit_sha (str | None) – last known commit hash

Returns:

changes if available

Return type:

Changes

packages(filter_packages: Iterable[str] | None = None) list[Package]

generate list of repository packages

Parameters:

filter_packages (Iterable[str] | None, optional) – filter packages list by specified only

Returns:

list of packages properties

Return type:

list[Package]

packages_built() list[Path]

get list of files in built packages directory

Returns:

list of filenames from the directory

Return type:

list[Path]

packages_depend_on(packages: list[Package], depends_on: Iterable[str] | None) list[Package]

extract list of packages which depends on specified package

Parameters:
  • packages (list[Package]) – list of packages to be filtered

  • depends_on (Iterable[str] | None) – dependencies of the packages

Returns:

list of repository packages which depend on specified packages

Return type:

list[Package]

ahriman.core.repository.repository module

class Repository(repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool, refresh_pacman_database: PacmanSynchronization)

Bases: Executor, UpdateHandler

base repository control class

Examples

This class along with traits provides access to local repository actions, e.g. remove packages, update packages, sync local repository to remote, generate report, etc.:

>>> from ahriman.core.configuration import Configuration
>>> from ahriman.core.database import SQLite
>>>
>>> configuration = Configuration()
>>> database = SQLite.load(configuration)
>>> repository = Repository.load(RepositoryId("x86_64", "x86_64"), configuration, database, report=True)
>>> known_packages = repository.packages()
>>>
>>> build_result = repository.process_build(known_packages)
>>> built_packages = repository.packages_built()
>>> update_result = repository.process_update(built_packages)
>>>
>>> repository.triggers.on_result(update_result, repository.packages())
Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • database (SQLite) – database instance

  • report (bool) – force enable or disable reporting

  • refresh_pacman_database (PacmanSynchronization) – pacman database synchronization level

classmethod load(repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool, refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled) Self

load instance from argument list

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • database (SQLite) – database instance

  • report (bool) – force enable or disable reporting

  • refresh_pacman_database (PacmanSynchronization, optional) – pacman database synchronization level (Default value = PacmanSynchronization.Disabled)

Returns:

fully loaded repository class instance

Return type:

Self

ahriman.core.repository.repository_properties module

class RepositoryProperties(repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool, refresh_pacman_database: PacmanSynchronization)

Bases: EventLogger, LazyLogging

repository internal objects holder

configuration

configuration instance

Type:

Configuration

database

database instance

Type:

SQLite

ignore_list

package bases which will be ignored during auto updates

Type:

list[str]

pacman

alpm wrapper instance

Type:

Pacman

paths

repository paths instance

Type:

RepositoryPaths

repo

repo commands wrapper instance

Type:

Repo

reporter

build status reporter instance

Type:

Client

repository_id

repository unique identifier

Type:

RepositoryId

scan_paths

scan paths for the implicit dependencies

Type:

ScanPaths

sign

GPG wrapper instance

Type:

GPG

triggers

triggers holder

Type:

TriggerLoader

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • database (SQLite) – database instance

  • report (bool) – force enable or disable reporting

  • refresh_pacman_database (PacmanSynchronization) – pacman database synchronization level

packager(packagers: Packagers, package_base: str) User

extract packager from configuration having username

Parameters:
  • packagers (Packagers) – packagers override holder

  • package_base (str) – package base to lookup

Returns:

user found in database if any and empty object otherwise

Return type:

User | None

property architecture: str

repository architecture for backward compatibility

Returns:

repository architecture

Return type:

str

property name: str

repository name for backward compatibility

Returns:

repository name

Return type:

str

ahriman.core.repository.update_handler module

class UpdateHandler(repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool, refresh_pacman_database: PacmanSynchronization)

Bases: PackageInfo, Cleaner

trait to get package update list

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • database (SQLite) – database instance

  • report (bool) – force enable or disable reporting

  • refresh_pacman_database (PacmanSynchronization) – pacman database synchronization level

updates_aur(filter_packages: Iterable[str], *, vcs: bool) list[Package]

check AUR for updates

Parameters:
  • filter_packages (Iterable[str]) – do not check every package just specified in the list

  • vcs (bool) – enable or disable checking of VCS packages

Returns:

list of packages which are out-of-dated

Return type:

list[Package]

updates_dependencies(filter_packages: Iterable[str]) list[Package]

check packages which are required to be rebuilt based on dynamic dependencies (e.g. linking, modules paths, etc.)

Parameters:

filter_packages (Iterable[str]) – do not check every package just specified in the list

Returns:

list of packages for which there is breaking linking

Return type:

list[Package]

updates_local(*, vcs: bool) list[Package]

check local packages for updates

Parameters:

vcs (bool) – enable or disable checking of VCS packages

Returns:

list of local packages which are out-of-dated

Return type:

list[Package]

updates_manual() list[Package]

check for packages for which manual update has been requested

Returns:

list of packages which are out-of-dated

Return type:

list[Package]

Module contents