ahriman.core.build_tools package
Submodules
ahriman.core.build_tools.package_archive module
- class PackageArchive(root: Path, package: Package, pacman: Pacman, scan_paths: ScanPaths)
Bases:
objecthelper for package archives
- root
path to root filesystem
- Type:
Path
- Parameters:
- static dynamic_needed(binary_path: Path) list[str]
extract dynamic libraries required by the specified file
- Parameters:
binary_path (Path) – path to library, file, etc
- Returns:
libraries which this file linked dynamically. Returns empty set in case if file is not a binary or no dynamic section has been found
- Return type:
list[str]
- static is_elf(content: IO[bytes]) bool
check if the content is actually elf file
- Parameters:
content (IO[bytes]) – content of the file
- Returns:
Truein case if file has elf header andFalseotherwise- Return type:
bool
- depends_on() Dependencies
extract packages and paths which are required for this package
- Returns:
map of the package name to set of paths used by this package
- Return type:
- depends_on_paths() tuple[set[str], set[Path]]
extract dependencies from installation
- Returns:
tuple of dynamically linked libraries and directory paths
- Return type:
tuple[set[str], set[Path]]
- installed_packages() dict[str, FilesystemPackage]
extract list of the installed packages and their content
- Returns:
map of package name to list of directories and files contained by this package
- Return type:
dict[str, FilesystemPackage]
ahriman.core.build_tools.package_version module
- class PackageVersion(package: Package)
Bases:
LazyLoggingpackage version extractor and helper
- Parameters:
package (Package) – package definitions
- actual_version(configuration: Configuration) str
additional method to handle VCS package versions
- Parameters:
configuration (Configuration) – configuration instance
- Returns:
package version if package is not VCS and current version according to VCS otherwise
- Return type:
str
- is_newer_than(timestamp: float | int) bool
check if package was built after the specified timestamp
- Parameters:
timestamp (float | int) – timestamp to check build date against
- Returns:
Truein case if package was built after the specified date andFalseotherwise. In case if build date is not set by any of packages, it returns False- Return type:
bool
- is_outdated(remote: Package, configuration: Configuration, *, calculate_version: bool = True) bool
check if package is out-of-dated
- Parameters:
remote (Package) – package properties from remote source
configuration (Configuration) – configuration instance
calculate_version (bool, optional) – expand version to actual value (by calculating git versions) (Default value = True)
- Returns:
Trueif the package is out-of-dated andFalseotherwise- Return type:
bool
ahriman.core.build_tools.sources module
- class Sources
Bases:
LazyLogginghelper 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]
- GITCONFIG
(class attribute) git config options to suppress annoying hints
- Type:
dict[str, str]
- 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
Noneotherwise- Return type:
str | None
- 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
- 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:
Truein case if there is any remote and false otherwise- Return type:
bool
- 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
- 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)
- 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)
- 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:
Truein case if changes have been committed andFalseotherwise- 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
- fetch_until(sources_dir: Path, *, branch: str | None = None, commit_sha: str | None = None, max_depth: int = 10) str | 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)
max_depth (int, optional) – maximal amount of commits to fetch if
commit_shais set (Default value = 10)
- Returns:
fetched
commit_sha(if set) andNonein case if commit wasn’t found orcommit_shais not set- Return type:
str | None
- git(gitconfig: dict[str, str] | None = None) list[str]
git command prefix
- Parameters:
gitconfig (dict[str, str] | None, optional) – additional git config flags if any (Default value = None)
- Returns:
git command prefix with valid default flags
- Return type:
list[str]
- 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:
Trueif there are uncommitted changes andFalseotherwise- 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
- 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
ahriman.core.build_tools.task module
- class Task(package: Package, configuration: Configuration, architecture: str, paths: RepositoryPaths)
Bases:
LazyLoggingbase 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]
- paths
repository paths instance
- Type:
- uid
uid of the repository owner user
- Type:
int
- Parameters:
package (Package) – package definitions
configuration (Configuration) – configuration instance
architecture (str) – repository architecture
paths (RepositoryPaths) – repository paths instance
- build(sources_dir: Path, *, dry_run: bool = False, **kwargs: str | None) list[Path]
run package build
- Parameters:
sources_dir (Path) – path to where sources are
dry_run (bool, optional) – do not perform build itself (Default value = False)
**kwargs (str | None) – environment variables to be passed to build processes
- Returns:
paths of produced packages
- Return type:
list[Path]
- init(sources_dir: Path, patches: list[PkgbuildPatch], local_version: str | None) str | None
fetch package from git
- Parameters:
sources_dir (Path) – local path to fetch
patches (list[PkgbuildPatch]) – list of patches for the package
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