diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2023-05-11 21:01:53 +0300 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2023-05-11 21:01:53 +0300 |
commit | a2358d60680611d7cbe07068440031c3c6e68f31 (patch) | |
tree | e3ed66c3aa63959ac4505634487260b8842e42a8 /src/pkgcheck/scripts | |
parent | Fix config loading if XDG_CONFIG_HOME is defined (diff) | |
download | pkgcheck-a2358d60680611d7cbe07068440031c3c6e68f31.tar.gz pkgcheck-a2358d60680611d7cbe07068440031c3c6e68f31.tar.bz2 pkgcheck-a2358d60680611d7cbe07068440031c3c6e68f31.zip |
scan: fix unknown checkset during initial config load
The config load is performed in multiple stages:
1. parse `--config` path
2. load bundled config
3. load user & system configs
4. parse cmd args (needed for repo and targets)
5. load repo's config
6. parse full cmd args
The problem is that the checkset is parsed during stage 4, which means
it hasn't loaded the repo's config yet. While a more correct solution
would be to parse only needed args during stage 4, it wasn't simple
since the targets collect everything, including cmd args. So instead
this just patches temporarily to not fail upon unknown checksets.
Resolves: https://github.com/pkgcore/pkgcheck/issues/576
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'src/pkgcheck/scripts')
-rw-r--r-- | src/pkgcheck/scripts/pkgcheck_scan.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pkgcheck/scripts/pkgcheck_scan.py b/src/pkgcheck/scripts/pkgcheck_scan.py index 9abfe2b5..b83f569f 100644 --- a/src/pkgcheck/scripts/pkgcheck_scan.py +++ b/src/pkgcheck/scripts/pkgcheck_scan.py @@ -2,6 +2,7 @@ import argparse import os import shlex from contextlib import ExitStack +from unittest.mock import patch from pkgcore import const as pkgcore_const from pkgcore.repository import errors as repo_errors @@ -370,7 +371,8 @@ def _setup_scan(parser, namespace, args): # have to be parsed twice, will probably require a custom snakeoil # arghparse method. # parse command line args to override config defaults - namespace, _ = parser._parse_known_args(args, namespace) + with patch("pkgcheck.scripts.argparse_actions.ChecksetArgs.__call__", lambda *a, **k: None): + namespace, _ = parser._parse_known_args(args, namespace) # Get the current working directory for repo detection and restriction # creation, fallback to the root dir if it's be removed out from under us. |