tools/mpp-depsolve: make use of dnf's per-user cache

Use dnf's per-user cache when `--dnf-cache` is not given. This speeds up
repeated invocations of `mpp-depsolve` considerably, without having to
specify a cache location.
This commit is contained in:
Lars Karlitski 2020-10-17 19:20:31 +02:00 committed by Tom Gundersen
parent 792b2ac5fc
commit 651c5b5461

View file

@ -78,7 +78,8 @@ def _dnf_repo(conf, desc):
def _dnf_base(repos, module_platform_id, persistdir, cachedir, arch):
base = dnf.Base()
base.conf.cachedir = cachedir
if cachedir:
base.conf.cachedir = cachedir
base.conf.config_file_path = "/dev/null"
base.conf.module_platform_id = module_platform_id
base.conf.persistdir = persistdir
@ -194,10 +195,9 @@ def _main_args(argv):
@contextlib.contextmanager
def _main_state(args):
state = State()
with tempfile.TemporaryDirectory() as dnf_cache:
state.dnf_cache = args.dnf_cache or dnf_cache
yield state
if args.dnf_cache:
state.dnf_cache = args.dnf_cache
yield state
def _main_process(state):