From 01b53b0b4953ece65fded6164f044ab40e6e3acd Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Sat, 13 Jul 2024 18:44:10 +0200 Subject: [PATCH] config: init: set aports when non-default work dir is picked (MR 2366) If you init and set a custom work dir it will not be relative to pmaports anymore. Detect this and reset config.aports to be relative to the new workdir. Fixes #2406 Signed-off-by: Caleb Connolly --- pmb/config/init.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pmb/config/init.py b/pmb/config/init.py index 3ce8221e..a80f5562 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -672,8 +672,16 @@ def frontend(args: PmbArgs): # Work folder (needs to be first, so we can create chroots early) config = pmb.config.load(args.config) + # Update context to point to new config + get_context().config = config + config.work, work_exists = ask_for_work_path(args) + # If the work dir is not the default, reset aports and make + # it relative to the work dir + if not config.aports[0].is_relative_to(config.work): + config.aports = [config.work / "cache_git/pmaports"] + # Update args and save config (so chroots and 'pmbootstrap log' work) # pmb.helpers.args.update_work(args, config.work) pmb.config.save(args.config, config)