From 3eb6ed90365270c18e2a746ae0e849421c1805d1 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Fri, 17 Nov 2023 13:55:49 +0800 Subject: refactor: Remove utils from repository Signed-off-by: KunoiSayami --- utils/update-db.py | 71 ------------------------------------------------------ 1 file changed, 71 deletions(-) delete mode 100755 utils/update-db.py (limited to 'utils/update-db.py') diff --git a/utils/update-db.py b/utils/update-db.py deleted file mode 100755 index 3e318f5..0000000 --- a/utils/update-db.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -import argparse -import asyncio -import logging -import os -import pathlib -import shutil - - -logger = logging.getLogger() -logger.setLevel(logging.DEBUG) - - -async def add_package(dest: pathlib.Path, pkg_name: str, key: str) -> None: - # logger.debug("%s %s %s", dest, pkg_name, key) - await ( - await asyncio.create_subprocess_exec( - "/usr/bin/repo-add", - str(dest), - pkg_name, - "-s", - "-v", - "-R", - "-k", - key, - stdout=None, - ) - ).wait() - - -async def kill_gpg_agnet() -> None: - await (await asyncio.create_subprocess_exec("/usr/bin/gpg-connect-agent", 'killagent', '/bye')).wait() - - -async def main(remote_dest: str, repo_base_name: str, sign_key: str) -> None: - cwd = pathlib.Path(os.getcwd()).resolve() - remote_dest = pathlib.Path(remote_dest).resolve() - database_dest = cwd.joinpath(repo_base_name).resolve() - - for file in os.listdir(str(remote_dest)): - logger.debug("Copy file: %s", file) - shutil.copy(str(remote_dest.joinpath(file).joinpath()), str(cwd)) - - for file in os.listdir(str(remote_dest)): - if ".pkg.tar.zst" in file and not file.endswith(".sig"): - await add_package(database_dest, file, sign_key) - - await kill_gpg_agnet() - - -if __name__ == "__main__": - parser = argparse.ArgumentParser("update-db.py") - parser.add_argument("cwd") - parser.add_argument("basename") - parser.add_argument("sign_key") - - args_ = parser.parse_args() - - try: - import coloredlogs - - coloredlogs.install( - logging.DEBUG, - fmt="%(asctime)s - %(levelname)s - %(funcName)s - %(lineno)d - %(message)s", - ) - except ModuleNotFoundError: - logging.basicConfig( - level=logging.DEBUG, - format="%(asctime)s - %(levelname)s - %(funcName)s - %(lineno)d - %(message)s", - ) - asyncio.run(main(args_.cwd, args_.basename, args_.sign_key)) -- cgit v1.3.1