ahriman.core.build_tools package

Submodules

ahriman.core.build_tools.sources module

class Sources

Bases: LazyLogging

helper to download package sources (PKGBUILD etc…) and perform some operations with git

DEFAULT_BRANCH

(class attribute) default branch to process git repositories. Must be used only for local stored repositories, use RemoteSource descriptor instead for real packages

Type:

str

DEFAULT_COMMIT_AUTHOR

(class attribute) default commit author to be used if none set

Type:

tuple[str, str]

add(sources_dir: Path, *pattern: str, intent_to_add: bool = False) None

track found files via git

Parameters:
  • sources_dir (Path) – local path to git repository

  • *pattern (str) – glob patterns

  • intent_to_add (bool, optional) – record only the fact that it will be added later, acts as –intent-to-add git flag (Default value = False)

static changes(source_dir: Path, last_commit_sha: str | None) str | None

extract changes from the last known commit if available

Parameters:
  • source_dir (Path) – local path to directory with source files

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

Returns:

changes from the last commit if available or None otherwise

Return type:

str | None

commit(sources_dir: Path, message: str | None = None, commit_author: tuple[str, str] | None = None) bool

commit changes

Parameters:
  • sources_dir (Path) – local path to git repository

  • message (str | None, optional) – optional commit message if any. If none set, message will be generated according to the current timestamp (Default value = None)

  • commit_author (tuple[str, str] | None, optional) – optional commit author if any (Default value = None)

Returns:

True in case if changes have been committed and False otherwise

Return type:

bool

diff(sources_dir: Path, sha: str | None = None) str

generate diff from the current version and write it to the output file

Parameters:
  • sources_dir (Path) – local path to git repository

  • sha (str | None, optional) – optional commit sha to calculate diff (Default value = None)

Returns:

patch as plain string

Return type:

str

static extend_architectures(sources_dir: Path, architecture: str) list[PkgbuildPatch]

extend existing PKGBUILD with repository architecture

Parameters:
  • sources_dir (Path) – local path to directory with source files

  • architecture (str) – repository architecture

Returns:

generated patch for PKGBUILD architectures if required

Return type:

list[PkgbuildPatch]

static fetch(sources_dir: Path, remote: RemoteSource) str | None

either clone repository or update it to origin/remote.branch

Parameters:
  • sources_dir (Path) – local path to fetch

  • remote (RemoteSource) – remote target (from where to fetch)

Returns:

current commit sha if available

Return type:

str | None

fetch_until(sources_dir: Path, *, branch: str | None = None, commit_sha: str | None = None) None

fetch repository until commit sha

Parameters:
  • sources_dir (Path) – local path to git repository

  • branch (str | None, optional) – use specified branch (Default value = None)

  • commit_sha (str | None, optional) – commit hash to fetch. If none set, only one will be fetched (Default value = None)

has_changes(sources_dir: Path) bool

check if there are changes in current git tree

Parameters:

sources_dir (Path) – local path to git repository

Returns:

True if there are uncommitted changes and False otherwise

Return type:

bool

static has_remotes(sources_dir: Path) bool

check if there are remotes for the repository

Parameters:

sources_dir (Path) – local path to git repository

Returns:

True in case if there is any remote and false otherwise

Return type:

bool

head(sources_dir: Path, ref_name: str = 'HEAD') str

extract HEAD reference for the current git repository

Parameters:
  • sources_dir (Path) – local path to git repository

  • ref_name (str, optional) – reference name (Default value = “HEAD”)

Returns:

HEAD commit hash

Return type:

str

static init(sources_dir: Path) None

create empty git repository at the specified path

Parameters:

sources_dir (Path) – local path to sources

static load(sources_dir: Path, package: Package, patches: list[PkgbuildPatch], paths: RepositoryPaths) str | None

fetch sources from remote and apply patches

Parameters:
  • sources_dir (Path) – local path to fetch

  • package (Package) – package definitions

  • patches (list[PkgbuildPatch]) – optional patch to be applied

  • paths (RepositoryPaths) – repository paths instance

Returns:

current commit sha if available

Return type:

str | None

move(pkgbuild_dir: Path, sources_dir: Path) None

move content from pkgbuild_dir to sources_dir

Parameters:
  • pkgbuild_dir (Path) – path to directory with pkgbuild from which need to move

  • sources_dir (Path) – path to target directory

patch_apply(sources_dir: Path, patch: PkgbuildPatch) None

apply patches if any

Parameters:
  • sources_dir (Path) – local path to directory with git sources

  • patch (PkgbuildPatch) – patch to be applied

static patch_create(sources_dir: Path, *pattern: str) str

create patch set for the specified local path

Parameters:
  • sources_dir (Path) – local path to git repository

  • *pattern (str) – glob patterns

Returns:

patch as plain text

Return type:

str

static push(sources_dir: Path, remote: RemoteSource, *pattern: str, commit_author: tuple[str, str] | None = None) None

commit selected changes and push files to the remote repository

Parameters:
  • sources_dir (Path) – local path to git repository

  • remote (RemoteSource) – remote target, branch and url

  • *pattern (str) – glob patterns

  • commit_author (tuple[str, str] | None, optional) – commit author if any (Default value = None)

ahriman.core.build_tools.task module

class Task(package: Package, configuration: Configuration, architecture: str, paths: RepositoryPaths)

Bases: LazyLogging

base package build task

archbuild_flags

command flags for archbuild command

Type:

list[str]

architecture

repository architecture

Type:

str

build_command

build command

Type:

str

include_debug_packages

whether to include debug packages or not

Type:

bool

makechrootpkg_flags

command flags for makechrootpkg command

Type:

list[str]

makepkg_flags

command flags for makepkg command

Type:

list[str]

package

package definitions

Type:

Package

paths

repository paths instance

Type:

RepositoryPaths

uid

uid of the repository owner user

Type:

int

default constructor

Parameters:
  • package (Package) – package definitions

  • configuration (Configuration) – configuration instance

  • architecture (str) – repository architecture

  • paths (RepositoryPaths) – repository paths instance

build(sources_dir: Path, **kwargs: str | None) list[Path]

run package build

Parameters:
  • sources_dir (Path) – path to where sources are

  • **kwargs (str | None) – environment variables to be passed to build processes

Returns:

paths of produced packages

Return type:

list[Path]

init(sources_dir: Path, database: SQLite, local_version: str | None) str | None

fetch package from git

Parameters:
  • sources_dir (Path) – local path to fetch

  • database (SQLite) – database instance

  • local_version (str | None) – local version of the package. If set and equal to current version, it will automatically bump pkgrel

Returns:

current commit sha if available

Return type:

str | None

Module contents