ahriman.core.alpm package

Subpackages

Submodules

ahriman.core.alpm.pacman module

class Pacman(repository_id: RepositoryId, configuration: Configuration, *, refresh_database: PacmanSynchronization)

Bases: LazyLogging

alpm wrapper

configuration

configuration instance

Type:

Configuration

refresh_database

synchronize local cache to remote

Type:

PacmanSynchronization

repository_id

repository unique identifier

Type:

RepositoryId

repository_path

repository paths instance

Type:

RepositoryPaths

default constructor

Parameters:
database_copy(handle: pyalpm.Handle, database: pyalpm.DB, pacman_root: Path, *, use_ahriman_cache: bool) None

copy database from the operating system root to the ahriman local home

Parameters:
  • handle (Handle) – pacman handle which will be used for database copying

  • database (DB) – pacman database instance to be copied

  • pacman_root (Path) – operating system pacman root

  • use_ahriman_cache (bool) – use local ahriman cache instead of system one

database_init(handle: pyalpm.Handle, repository: str, architecture: str) pyalpm.DB

create database instance from pacman handler and set its properties

Parameters:
  • handle (Handle) – pacman handle which will be used for database initializing

  • repository (str) – pacman repository name (e.g. core)

  • architecture (str) – repository architecture

Returns:

loaded pacman database instance

Return type:

DB

database_sync(handle: pyalpm.Handle, *, force: bool) None

sync local database

Parameters:
  • handle (Handle) – pacman handle which will be used for database sync

  • force (bool) – force database synchronization (same as pacman -Syy)

files(packages: Iterable[str] | None = None) dict[str, set[Path]]

extract list of known packages from the databases

Parameters:

packages (Iterable[str] | None, optional) – filter by package names (Default value = None)

Returns:

map of package name to its list of files

Return type:

dict[str, set[Path]]

package(package_name: str) Generator[pyalpm.Package, None, None]

retrieve list of the packages from the repository by name

Parameters:

package_name (str) – package name to search

Yields:

Package – list of packages which were returned by the query

packages() set[str]

get list of packages known for alpm

Returns:

list of package names

Return type:

set[str]

property handle: pyalpm.Handle

pyalpm handle

Returns:

generated pyalpm handle instance

Return type:

Handle

ahriman.core.alpm.pacman_database module

class PacmanDatabase(database: pyalpm.DB, configuration: Configuration)

Bases: SyncHttpClient

implementation for database sync, because pyalpm is not always enough

LAST_MODIFIED_HEADER

last modified header name

Type:

str

database

pyalpm database object

Type:

DB

repository_paths

repository paths instance

Type:

RepositoryPaths

sync_files_database

sync files database

Type:

bool

default constructor

Parameters:
  • database (DB) – pyalpm database object

  • configuration (Configuration) – configuration instance

copy(remote_path: Path, local_path: Path) None

copy local database file

Parameters:
  • remote_path (Path) – path to source (remote) file

  • local_path (Path) – path to locally stored file

download(url: str, local_path: Path) None

download remote file and store it to local path with the correct last modified headers

Parameters:
  • url (str) – remote url to request file

  • local_path (Path) – path to locally stored file

Raises:

PacmanError – in case if no last-modified header was found

is_outdated(url: str, local_path: Path) bool

check if local file is outdated

Parameters:
  • url (str) – remote url to request last modified header

  • local_path (Path) – path to locally stored file

Returns:

True in case if remote file is newer than local file

Return type:

bool

Raises:

PacmanError – in case if no last-modified header was found

sync(*, force: bool) None

sync packages and files databases

Parameters:

force (bool) – force database synchronization (same as pacman -Syy)

sync_files(*, force: bool) None

sync files by using http request

Parameters:

force (bool) – force database synchronization (same as pacman -Syy)

sync_packages(*, force: bool) None

sync packages by using built-in pyalpm methods

Parameters:

force (bool) – force database synchronization (same as pacman -Syy)

ahriman.core.alpm.repo module

class Repo(name: str, paths: RepositoryPaths, sign_args: list[str])

Bases: LazyLogging

repo-add and repo-remove wrapper

name

repository name

Type:

str

paths

repository paths instance

Type:

RepositoryPaths

sign_args

additional args which have to be used to sign repository archive

Type:

list[str]

uid

uid of the repository owner user

Type:

int

default constructor

Parameters:
  • name (str) – repository name

  • paths (RepositoryPaths) – repository paths instance

  • sign_args (list[str]) – additional args which have to be used to sign repository archive

add(path: Path) None

add new package to repository

Parameters:

path (Path) – path to archive to add

init() None

create empty repository database. It just calls add with empty arguments

remove(package: str, filename: Path) None

remove package from repository

Parameters:
  • package (str) – package name to remove

  • filename (Path) – package filename to remove

property repo_path: Path

get full path to the repository database

Returns:

path to repository database

Return type:

Path

Module contents