import typing from . import pkgcomposer, sources _key_global = "@global" _key_version = "version" _key_description = "description" _key_on_pack = "on_pack" _key_arch_any = "arch_any" _current_pkgname: str = _key_global _pkginfo: dict[str, dict[str, typing.Any]] = { _key_global: {}, } _supported_arch: typing.Callable[[str], bool] = lambda x: True _on_build: typing.Callable[[], None] | None = None _blocked_hooks: list[str] = [] def package(s: str): global _current_pkgname _current_pkgname = s _pkginfo[s] = _pkginfo[_key_global].copy() def version(s: str): _pkginfo[_current_pkgname][_key_version] = s def description(s: str): _pkginfo[_current_pkgname][_key_description] = s def arch_any(): _pkginfo[_current_pkgname][_key_arch_any] = True def supported_arch(s: list[str] | typing.Callable[[str], bool]): global _supported_arch if isinstance(s, list): _supported_arch = lambda arch: arch in s else: _supported_arch = s def on_build(func: typing.Callable[[], None]): global _on_build _on_build = func def on_pack(func: typing.Callable[[pkgcomposer.PkgComposer], None]): _pkginfo[_current_pkgname][_key_on_pack] = func def block_hook(hook: str): _blocked_hooks.append(hook) def source_url(url: str): sources.source_url(url) def source_git(url: str, branch: str | None = None): sources.source_git(url, branch)