import getpass
import tempfile
from pathlib import Path
+from typing import Any, Union
# SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
SUDO_PROC = False
print(*args, **kwargs)
-def ensure_pkg_dir_exists(pkg, pkg_state, other_state):
+def ensure_pkg_dir_exists(
+ pkg: str,
+ pkg_state: dict[str, Any],
+ other_state: dict[str, Union[None, str]],
+):
"""Ensures that an AUR-pkg-dir exists, returning False on failure.
If no such directory exists, this script attempts to clone it from the AUR.
return False
-def update_pkg_dir(pkg, pkg_state, other_state):
+def update_pkg_dir(
+ pkg: str,
+ pkg_state: dict[str, Any],
+ other_state: dict[str, Union[None, str]],
+):
"""Updates the pkg by invoking "git pull".
If "git pull" failes, it is retried after invoking "git restore .".
return True, False
-def check_pkg_build(pkg, pkg_state, other_state, editor):
+def check_pkg_build(
+ pkg: str,
+ pkg_state: dict[str, Any],
+ other_state: dict[str, Union[None, str]],
+ editor: str,
+):
"""Opens the PKGBUILD in the editor, then prompts the user for an action.
Returns "ok", "not_ok", "abort", or "force_build"."""
continue
-def check_pkg_version(pkg, pkg_state, repo, force_check_srcinfo, other_state):
+def check_pkg_version(
+ pkg: str,
+ pkg_state: dict[str, Any],
+ repo: str,
+ force_check_srcinfo: bool,
+ other_state: dict[str, Union[None, str]],
+):
"""Gets the installed version and pkg version and checks them.
Returns "fail" (on failure), "install" (pkg is newer), or "done"
)
-def get_srcinfo_version(pkg, other_state):
+def get_srcinfo_version(pkg: str, other_state: dict[str, Union[None, str]]):
"""Parses .SRCINFO for verison information.
Returns (success_bool, pkgepoch, pkgver, pkgrel)
return True, pkgepoch, pkgver, pkgrel
-def get_pkgbuild_version(pkg, force_check_srcinfo, pkg_state, other_state):
+def get_pkgbuild_version(
+ pkg: str,
+ force_check_srcinfo: bool,
+ pkg_state: dict[str, Any],
+ other_state: dict[str, Union[None, str]],
+):
"""Gets the version of the pkg from .SRCINFO or PKGBUILD.
Returns (success, epoch, version, release).
def get_srcinfo_check_result(
- current_epoch,
- current_version,
- pkg,
- force_check_srcinfo,
- pkg_state,
- other_state,
+ current_epoch: Union[str, None],
+ current_version: str,
+ pkg: str,
+ force_check_srcinfo: bool,
+ pkg_state: dict[str, Any],
+ other_state: dict[str, Union[None, str]],
):
"""Checks the version of the pkg against the currently installed version.
return "fail"
-def get_pkg_current_version(pkg, pkg_state, repo):
+def get_pkg_current_version(pkg: str, pkg_state: dict[str, Any], repo: str):
"""Fetches the version info and returns status of fetching and the version.
Returns (status, epoch, version)
sudo_proc.terminate()
-def create_executable_script(dest_filename, script_contents):
+def create_executable_script(dest_filename: str, script_contents: str):
"""Creates a script via use of sudo to be executed later.
This is currently used to set up sccache by placing custom commands in
return True
-def setup_ccache(chroot):
+def setup_ccache(chroot: str):
"""Sets up the chroot for ccache."""
# set up ccache stuff
sys.exit(1)
-def cleanup_ccache(chroot):
+def cleanup_ccache(chroot: str):
"""Unsets up the chroot for ccache."""
# cleanup ccache stuff
sys.exit(1)
-def setup_sccache(chroot):
+def setup_sccache(chroot: str):
"""Sets up sccache for the chroot."""
sccache_script = """#!/usr/bin/env sh
sys.exit(1)
-def cleanup_sccache(chroot):
+def cleanup_sccache(chroot: str):
"""Unsets up sccache for the chroot."""
# cleanup sccache stuff
def update_pkg_list(
- pkgs,
- pkg_state,
- other_state,
- signing_gpg_dir,
- signing_gpg_key_fp,
- signing_gpg_pass,
- no_store,
+ pkgs: list[str],
+ pkg_state: dict[str, Any],
+ other_state: dict[str, Union[None, str]],
+ signing_gpg_dir: str,
+ signing_gpg_key_fp: str,
+ signing_gpg_pass: str,
+ no_store: bool,
):
"""For each package to build: builds it, signs it, and moves it to
"pkg_out_dir"."""
log_print(f'"{pkg}" status: {pkg_state[pkg]["build_status"]}')
-def get_latest_pkg(pkg, cache_dir):
+def get_latest_pkg(pkg: str, cache_dir: str):
"""Gets the latest pkg from the specified "cache_dir" and return its
filename."""
return None
-def confirm_result(pkg, state_result):
+def confirm_result(pkg: str, state_result: str):
"""Prompts the user the action to take for a pkg after checking its
PKGBUILD.
continue
-def print_state_info_and_get_update_list(pkg_state):
+def print_state_info_and_get_update_list(pkg_state: dict[str, Any]):
"""Prints the current "checked" state of all pkgs in the config."""
to_update = []
return to_update
-def test_gpg_passphrase(signing_gpg_dir, signing_key_fp, passphrase):
+def test_gpg_passphrase(
+ signing_gpg_dir: str, signing_key_fp: str, passphrase: str
+):
"""Checks if the given gpg passphrase works with the gpg signing key."""
with tempfile.NamedTemporaryFile() as tempnf:
return True
-def validate_and_verify_paths(other_state):
+def validate_and_verify_paths(other_state: dict[str, Union[None, str]]):
"""Checks and validates/ensures that certain directories exist."""
if not os.path.exists(other_state["chroot"]):