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 <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-07-13 18:44:10 +02:00
parent 2ce06e9791
commit 01b53b0b49
No known key found for this signature in database
GPG key ID: 0583312B195F64B6

View file

@ -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)