From 4b2d6ab9efe849b143e6d35fed6b0a5b045df3af Mon Sep 17 00:00:00 2001 From: actionless Date: Tue, 3 Sep 2024 00:29:29 +0200 Subject: [PATCH] feat(args, alpm): implement support for pacman's --dbpath and --root flags --- maintenance_scripts/mypy_stubs/pycman/config.pyi | 3 +++ pikaur/alpm.py | 7 ++++++- pikaur/args.py | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/maintenance_scripts/mypy_stubs/pycman/config.pyi b/maintenance_scripts/mypy_stubs/pycman/config.pyi index e47103c8a..037b5f771 100644 --- a/maintenance_scripts/mypy_stubs/pycman/config.pyi +++ b/maintenance_scripts/mypy_stubs/pycman/config.pyi @@ -4,8 +4,11 @@ from collections import OrderedDict from pyalpm import Handle from typing_extensions import TypedDict + class PacmanOptions(TypedDict): IgnorePkg: list[str] + RootDir: str + DBPath: str class PacmanConfig: diff --git a/pikaur/alpm.py b/pikaur/alpm.py index 8b50766dc..a5ef59984 100644 --- a/pikaur/alpm.py +++ b/pikaur/alpm.py @@ -27,7 +27,12 @@ class PacmanConfig(PycmanConfig): def __init__(self) -> None: - super().__init__(conf=parse_args().config or "/etc/pacman.conf") + args = parse_args() + super().__init__(conf=args.config or "/etc/pacman.conf") + if args.root: + self.options["RootDir"] = args.root + if args.dbpath: + self.options["DBPath"] = args.dbpath class PyAlpmWrapper: diff --git a/pikaur/args.py b/pikaur/args.py index 19e48047c..636151f06 100644 --- a/pikaur/args.py +++ b/pikaur/args.py @@ -224,7 +224,7 @@ def get_pacman_str_opts(action: str | None = None) -> ArgSchema: return list(set(result)) return [ (None, "color", None, None), - ("b", "dbpath", None, None), # @TODO: pyalpm? + ("b", "dbpath", None, None), ("r", "root", None, None), (None, "arch", None, None), # @TODO (None, "cachedir", None, None), # @TODO @@ -468,6 +468,9 @@ class PikaurArgs(Namespace): config: str | None refresh: int clean: int + dbpath: str | None + root: str | None + aur_clone_concurrency: int | None skip_aur_pull: bool | None positional: list[str]