pmbootstrap init: Fix regexp for int (MR 2086)

This improves handling input in pmbootstrap init.

Various config options in "Additional options" are int, thus whole input
must be checked:

This fixes obvious error:
Jobs [9]: 5e

and less obvious errors:
Extra space size: 600.5
Extra space size: 600m
...
$ pmbootstrap install
[17:28:23] *** (3/4) PREPARE INSTALL BLOCKDEVICE ***
[17:28:23] ERROR: invalid literal for int() with base 10: '600.5'

NOTE: I suppose moving ^ $ to ReadlineTabCompleter.ask() would break
some of already defined regexes.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
This commit is contained in:
Petr Vorel 2021-07-28 18:33:21 +02:00 committed by Oliver Smith
parent db12e987d0
commit ba07c4cf14
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 3 additions and 3 deletions

View File

@ -391,20 +391,20 @@ def ask_for_additional_options(args, cfg):
" How much extra free space do you want to add to the image"
" (in MB)?")
answer = pmb.helpers.cli.ask(args, "Extra space size", None,
args.extra_space, validation_regex="[0-9]+")
args.extra_space, validation_regex="^[0-9]+$")
cfg["pmbootstrap"]["extra_space"] = answer
# Boot size
logging.info("What should be the boot partition size (in MB)?")
answer = pmb.helpers.cli.ask(args, "Boot size", None, args.boot_size,
validation_regex="[1-9][0-9]*")
validation_regex="^[1-9][0-9]*$")
cfg["pmbootstrap"]["boot_size"] = answer
# Parallel job count
logging.info("How many jobs should run parallel on this machine, when"
" compiling?")
answer = pmb.helpers.cli.ask(args, "Jobs", None, args.jobs,
validation_regex="[1-9][0-9]*")
validation_regex="^[1-9][0-9]*$")
cfg["pmbootstrap"]["jobs"] = answer
# Ccache size