~postmarketos/pmbootstrap

e223fd03eb408e292aa065109b705692e376a008 — Oliver Smith 10 months ago ddc5c59
install: throw error if boot_size is too small

Make sure the user has at least 256 MiB set as their installation size,
refuse to start the installation otherwise. The default was changed in
2021, 03e9fb05 ("pmb.config.init.boot_size: set to 256 MiB (MR 2037)").

If the user ran "pmbootstrap init" before that commit, the pmbootstrap
config will have the old default set. It is very annoying when you do an
installation with it and only realize it when you run into errors, e.g.
while upgrading. I had that when testing the upgrade to the v23.12
release and also adjusted postmarketos-release-upgrade to warn if the
boot partition is smaller than expected.

Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20231208222714.4601-1-ollieparanoid@postmarketos.org%3E
1 files changed, 15 insertions(+), 0 deletions(-)

M pmb/install/_install.py
M pmb/install/_install.py => pmb/install/_install.py +15 -0
@@ 5,6 5,7 @@ import os
import re
import glob
import shlex
import sys

import pmb.chroot
import pmb.chroot.apk


@@ 621,6 622,19 @@ def write_cgpt_kpart(args, layout, suffix):
        args, ["dd", f"if={filename}", f"of=/dev/installp{layout['kernel']}"])


def sanity_check_boot_size(args):
    default = pmb.config.defaults["boot_size"]
    if int(args.boot_size) >= int(default):
        return
    logging.error("ERROR: your pmbootstrap has a small boot_size of"
                  f" {args.boot_size} configured, probably because the config"
                  " has been created with an old version.")
    logging.error("This can lead to problems later on, we recommend setting it"
                  f" to {default} MiB.")
    logging.error(f"Run 'pmbootstrap config boot_size {default}' and try again.")
    sys.exit(1)


def sanity_check_disk(args):
    device = args.disk
    device_name = os.path.basename(device)


@@ 1154,6 1168,7 @@ def create_device_rootfs(args, step, steps):

def install(args):
    # Sanity checks
    sanity_check_boot_size(args)
    if not args.android_recovery_zip and args.disk:
        sanity_check_disk(args)
        sanity_check_disk_size(args)