From c403edefe49925b97ce733ca66b387f04410dc87 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 2 Jan 2018 04:38:28 +0000 Subject: [PATCH] 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). --- pmb/__init__.py | 7 ++++++- pmb/config/init.py | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pmb/__init__.py b/pmb/__init__.py index ab06488a..ea5e1ce7 100644 --- a/pmb/__init__.py +++ b/pmb/__init__.py @@ -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: ") logging.debug(traceback.format_exc()) return 1 diff --git a/pmb/config/init.py b/pmb/config/init.py index 3a044dad..293e2501 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -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