Skip to content
Snippets Groups Projects
Unverified Commit 70dc8552 authored by Casey's avatar Casey :recycle: Committed by Oliver Smith
Browse files

config: init: dont clobber config (MR 2470)


When pmbootstrap starts up, it loads the config file (or uses the
defaults) and then merged some arguments (e.g. --work) into it. However
in config.init.frontend() we were creating yet another new Config, but
it's too late to merge args in at this point...

Rework this slightly to fix that major oversight and remove the totally
unnecessary hack of calling pmb.config.load() again.

This fixes calling pmbootstrap init with --work

Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
parent 500b0908
Branches
Tags
No related merge requests found
......@@ -83,7 +83,7 @@ def ask_for_username(default_user: str) -> str:
return ret
def ask_for_work_path(args: PmbArgs) -> tuple[Path, bool]:
def ask_for_work_path(default: Path | None) -> tuple[Path, bool]:
"""Ask for the work path, until we can create it (when it does not exist) and write into it.
:returns: (path, exists)
......@@ -98,9 +98,7 @@ def ask_for_work_path(args: PmbArgs) -> tuple[Path, bool]:
)
while True:
try:
work = os.path.expanduser(
pmb.helpers.cli.ask("Work path", None, get_context().config.work, False)
)
work = os.path.expanduser(pmb.helpers.cli.ask("Work path", None, default, False))
work = os.path.realpath(work)
exists = os.path.exists(work)
......@@ -697,11 +695,9 @@ def frontend(args: PmbArgs) -> None:
require_programs()
# 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 = get_context().config
config.work, work_exists = ask_for_work_path(args)
config.work, work_exists = ask_for_work_path(config.work)
# If the work dir is not the default, reset aports and make
# it relative to the work dir
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment