ahriman.core.alpm package
Subpackages
Submodules
ahriman.core.alpm.pacman module
- class Pacman(repository_id: RepositoryId, configuration: Configuration, *, refresh_database: PacmanSynchronization)
Bases:
LazyLoggingalpm wrapper
- configuration
configuration instance
- Type:
- refresh_database
synchronize local cache to remote
- Type:
- repository_id
repository unique identifier
- Type:
- repository_paths
repository paths instance
- Type:
- Parameters:
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
refresh_database (PacmanSynchronization) – synchronize local cache to remote
- 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]) dict[str, set[str]]
extract list of known packages from the databases
- Parameters:
packages (Iterable[str]) – filter by package names
- Returns:
map of package name to its list of files
- Return type:
dict[str, set[str]]
- package(package_name: str) Iterator[pyalpm.Package]
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]
- provided_by(package_name: str) Iterator[pyalpm.Package]
search through databases and emit packages which provides the
package_name- Parameters:
package_name (str) – package name to search
- Yields:
Package – list of packages which were returned by the query
- 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:
SyncHttpClientimplementation 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:
- sync_files_database
sync files database
- Type:
bool
- Parameters:
database (DB) – pyalpm database object
configuration (Configuration) – configuration instance
- static 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:
Truein 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)- Raises:
PacmanError – on operation error (invalid scheme or incomplete configuration)
- 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.pkgbuild_parser module
- class PkgbuildParser(stream: IO[str])
Bases:
shlexsimple pkgbuild reader implementation in pure python, because others suck.
What is it:
Simple PKGBUILD parser written in python.
No shell execution, so it is free from random shell attacks.
Able to parse simple constructions (assignments, comments, functions, arrays).
What it is not:
Fully functional shell parser.
Shell executor.
No parameter expansion.
For more details what does it support, please, consult with the test cases.
Examples
This class is heavily based on
shlexparser, but instead of strings operates with theahriman.models.pkgbuild_patch.PkgbuildPatchobjects. The main way to use it is to callparse()function and collect parsed objects, e.g.:>>> parser = PkgbuildParser(StringIO("input string")) >>> for patch in parser.parse(): >>> print(f"{patch.key} = {patch.value}")
It doesn’t store the state of the fields (but operates with the
shlexparser state), so no shell post-processing is performed (e.g. variable substitution).- Parameters:
stream (IO[str]) – input stream containing PKGBUILD content
- parse() Iterator[PkgbuildPatch]
parse source stream and yield parsed entries
- Yields:
PkgbuildPatch – extracted a PKGBUILD node
- class PkgbuildToken(*values)
Bases:
StrEnumwell-known tokens dictionary
- ArrayEnds
array ends token
- Type:
- ArrayStarts
array starts token
- Type:
- Comma
comma token
- Type:
- Comment
comment token
- Type:
- FunctionDeclaration
function declaration token
- Type:
- FunctionEnds
function ends token
- Type:
- FunctionStarts
function starts token
- Type:
- NewLine
new line token
- Type:
ahriman.core.alpm.repo module
- class Repo(name: str, paths: RepositoryPaths, sign_args: list[str], root: Path | None = None)
Bases:
LazyLoggingrepo-add and repo-remove wrapper
- name
repository name
- Type:
str
- root
repository root
- Type:
Path
- 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
- 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
root (Path | None, optional) – repository root. If none set, the default will be used (Default value = None)
- 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_name: str, filename: Path) None
remove package from repository
- Parameters:
package_name (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