pmbootstrap init: ask for work folder before asking for device (#1068)

This fixes #1066, where pmbootstrap crashes with a permission error
when you run it for the first time (no work folder exists) and you
run the boot.img analyzer because you want to start a new device
port.

It also prints a more helpful message if pmbootstrap crashes before
the log file was generated (suggests to use --details-to-stdout).
This commit is contained in:
Oliver Smith 2018-01-02 04:38:28 +00:00 committed by GitHub
parent faca8481d9
commit c403edefe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -65,7 +65,12 @@ def main():
except Exception as e:
logging.info("ERROR: " + str(e))
logging.info("Run 'pmbootstrap log' for details.")
if os.path.exists(args.log):
logging.info("Run 'pmbootstrap log' for details.")
else:
logging.info("Crashed before the log file was created.")
logging.info("Running init again like the following gives more details:")
logging.info(" pmbootstrap --details-to-stdout init")
logging.info("See also: <https://postmarketos.org/troubleshooting>")
logging.debug(traceback.format_exc())
return 1

View File

@ -201,6 +201,9 @@ def ask_for_build_options(args, cfg):
def frontend(args):
cfg = pmb.config.load(args)
# Work folder (needs to be first, so boot.img analyze works: #1066)
cfg["pmbootstrap"]["work"] = args.work = ask_for_work_path(args)
# Device
cfg["pmbootstrap"]["device"], device_exists = ask_for_device(args)
@ -217,11 +220,8 @@ def frontend(args):
cfg["pmbootstrap"]["user"] = pmb.helpers.cli.ask(args, "Username", None,
args.user, False,
"[a-z_][a-z0-9_-]*")
# UI and work folder
# UI and various build options
cfg["pmbootstrap"]["ui"] = ask_for_ui(args)
cfg["pmbootstrap"]["work"] = ask_for_work_path(args)
# Various build options
ask_for_build_options(args, cfg)
# Extra packages to be installed to rootfs