mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-13 03:19:47 +03:00
pmb.config.init: prompt for pmaports path (MR 2502)
Allows easily using an existing checkout. The default path remains the same. Fixes: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2506 [ci:skip-build]: already built successfully in CI
This commit is contained in:
parent
aed6c7f61e
commit
c2bcc81589
1 changed files with 41 additions and 0 deletions
|
@ -150,6 +150,45 @@ def ask_for_work_path(default: Path | None) -> tuple[Path, bool]:
|
|||
)
|
||||
|
||||
|
||||
def ask_for_pmaports_path(default: Path) -> Path:
|
||||
"""Ask for a path for pmaports, until it can either be created or already exists.
|
||||
|
||||
:returns: full path to the directory, with a leading ~ expanded.
|
||||
"""
|
||||
logging.info("Location of the 'pmaports' path, containing package definitions.")
|
||||
while True:
|
||||
try:
|
||||
raw = os.path.expanduser(
|
||||
pmb.helpers.cli.ask(
|
||||
"pmaports path",
|
||||
None,
|
||||
str(default),
|
||||
False,
|
||||
)
|
||||
)
|
||||
path = Path(raw).resolve()
|
||||
|
||||
if path.is_relative_to(pmb.config.pmb_src):
|
||||
logging.error(
|
||||
"ERROR: The pmaports path must not be inside the"
|
||||
" pmbootstrap path. Please specify another location."
|
||||
)
|
||||
continue
|
||||
|
||||
if not path.exists():
|
||||
try:
|
||||
path.parent.mkdir(0o700, parents=True, exist_ok=True)
|
||||
except Exception as e:
|
||||
logging.error("ERROR: Could not create parent directories: %s", str(e))
|
||||
continue
|
||||
|
||||
return path
|
||||
except OSError:
|
||||
logging.fatal(
|
||||
"ERROR: Could not create this folder, or write inside it! Please try again."
|
||||
)
|
||||
|
||||
|
||||
def ask_for_channel(config: Config) -> str:
|
||||
"""Ask for the postmarketOS release channel.
|
||||
The channel dictates, which pmaports branch pmbootstrap will check out,
|
||||
|
@ -714,6 +753,8 @@ def frontend(args: PmbArgs) -> None:
|
|||
if using_default_pmaports:
|
||||
config.aports = [config.work / "cache_git/pmaports"]
|
||||
|
||||
config.aports[-1] = ask_for_pmaports_path(config.aports[-1])
|
||||
|
||||
# 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue