ahriman.application.application package

Subpackages

Submodules

ahriman.application.application.application module

class Application(repository_id: RepositoryId, configuration: Configuration, *, report: bool, refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled)

Bases: ApplicationPackages, ApplicationRepository

base application class

Examples

This class groups ahriman.core.repository.repository.Repository methods into specific method which process all supposed actions caused by underlying action. E.g.:

>>> from ahriman.core.configuration import Configuration
>>> from ahriman.models.package_source import PackageSource
>>> from ahriman.models.repository_id import RepositoryId
>>>
>>> configuration = Configuration()
>>> application = Application(RepositoryId("x86_64", "x86_64"), configuration, report=True)
>>> # add packages to build queue
>>> application.add(["ahriman"], PackageSource.AUR)
>>>
>>> # check for updates
>>> updates = application.updates([], aur=True, local=True, manual=True, vcs=True)
>>> # updates for specified packages
>>> application.update(updates)

In case if specific actions or their order are required, the direct access to ahriman.core.repository.repository.Repository must be used instead.

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • report (bool) – force enable or disable reporting

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

on_result(result: Result) None

generate report and sync to remote server

Parameters:

result (Result) – build result

on_start() None

run triggers on start of the application

on_stop() None

run triggers on stop of the application. Note, however, that in most cases this method should not be called directly as it will be called after on_start action

print_updates(packages: list[Package], *, log_fn: Callable[[str], None]) None

print list of packages to be built. This method will build dependency tree and print updates accordingly

Parameters:
  • packages (list[Package]) – package list to be printed

  • log_fn (Callable[[str], None]) – logger function to log updates

with_dependencies(packages: list[Package], *, process_dependencies: bool) list[Package]

add missing dependencies to list of packages. This will extract known packages, check dependencies of the supplied packages and add packages which are not presented in the list of known packages.

Parameters:
  • packages (list[Package]) – list of source packages of which dependencies have to be processed

  • process_dependencies (bool) – if no set, dependencies will not be processed

Returns:

updated packages list. Packager for dependencies will be copied from original package

Return type:

list[Package]

Examples

In the most cases, in order to avoid build failure, it is required to add missing packages, which can be done by calling:

>>> application = ...
>>> packages = application.with_dependencies(packages, process_dependencies=True)
>>> application.print_updates(packages, log_fn=print)

ahriman.application.application.application_packages module

class ApplicationPackages(repository_id: RepositoryId, configuration: Configuration, *, report: bool, refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled)

Bases: ApplicationProperties

package control class

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • report (bool) – force enable or disable reporting

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

add(names: Iterable[str], source: PackageSource, username: str | None = None) None

add packages for the next build

Parameters:
  • names (Iterable[str]) – list of package bases to add

  • source (PackageSource) – package source to add

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

on_result(result: Result) None

generate report and sync to remote server

Parameters:

result (Result) – build result

Raises:

NotImplementedError – not implemented method

remove(names: Iterable[str]) Result

remove packages from repository

Parameters:

names (Iterable[str]) – list of packages (either base or name) to remove

Returns:

removal result

Return type:

Result

ahriman.application.application.application_properties module

class ApplicationProperties(repository_id: RepositoryId, configuration: Configuration, *, report: bool, refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled)

Bases: LazyLogging

application base properties class

configuration

configuration instance

Type:

Configuration

database

database instance

Type:

SQLite

repository

repository instance

Type:

Repository

repository_id

repository unique identifier

Type:

RepositoryId

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • report (bool) – force enable or disable reporting

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

property architecture: str

repository architecture for backward compatibility

Returns:

repository architecture

Return type:

str

ahriman.application.application.application_repository module

class ApplicationRepository(repository_id: RepositoryId, configuration: Configuration, *, report: bool, refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled)

Bases: ApplicationProperties

repository control class

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • report (bool) – force enable or disable reporting

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

changes(packages: Iterable[Package]) None

generate and update package changes

Parameters:

packages (Iterable[Package]) – list of packages to retrieve changes

clean(*, cache: bool, chroot: bool, manual: bool, packages: bool, pacman: bool) None

run all clean methods. Warning: some functions might not be available for non-root user

Parameters:
  • cache (bool) – clear directory with package caches

  • chroot (bool) – clear build chroot

  • manual (bool) – clear directory with manually added packages’ bases

  • packages (bool) – clear directory with built packages

  • pacman (bool) – clear directory with pacman databases

on_result(result: Result) None

generate report and sync to remote server

Parameters:

result (Result) – build result

Raises:

NotImplementedError – not implemented method

sign(packages: Iterable[str]) None

sign packages and repository

Parameters:

packages (Iterable[str]) – only sign specified packages

unknown() list[str]

get packages which were not found in AUR

Returns:

unknown package archive list

Return type:

list[str]

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

run package updates. This method will separate update in the several steps:

  1. Check already built packages.

  2. Construct builder instance.

  3. Delegate build process to the builder instance (either remote or local).

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

  • 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:

update result

Return type:

Result

updates(filter_packages: Iterable[str], *, aur: bool, local: bool, manual: bool, vcs: bool) list[Package]

get list of packages to run update process

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

  • aur (bool) – enable or disable checking for AUR updates

  • local (bool) – enable or disable checking of local packages for updates

  • manual (bool) – include or exclude manual updates

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

Returns:

list of out-of-dated packages

Return type:

list[Package]

ahriman.application.application.updates_iterator module

class FixedUpdatesIterator(application: Application, interval: int)

Bases: UpdatesIterator

implementation of the UpdatesIterator which always emits empty list, which is the same as update all

default constructor

Parameters:
  • application (Application) – application instance

  • interval (int) – predefined interval for updates

select_packages() tuple[list[str] | None, int]

select next packages partition for updates

Returns:

packages partition for updates if any and total amount of partitions.

Return type:

tuple[list[str] | None, int]

class UpdatesIterator(application: Application, interval: int)

Bases: Iterator[list[str] | None]

class-helper for iteration over packages to check for updates. It yields list of packages which were not yet updated

application

application instance

Type:

Application

interval

predefined interval for updates. The updates will be split into chunks in the way in which all packages will be updated in the specified interval

Type:

int

updated_packages

list of packages which have been already updated

Type:

set[str]

Examples

Typical usage of this class is something like:

>>> application = ...
>>> iterator = UpdatesIterator(application, None)
>>>
>>> for updates in iterator:
>>>     print(updates)

default constructor

Parameters:
  • application (Application) – application instance

  • interval (int) – predefined interval for updates

select_packages() tuple[list[str] | None, int]

select next packages partition for updates

Returns:

packages partition for updates if any and total amount of partitions.

Return type:

tuple[list[str] | None, int]

Module contents