install --ondev: add ondev_min_version

Put a minimum version check for postmarketos-ondev in the pmbootstrap
install code and verify it before starting the installation. This avoids
using incompatible versions, similar to the pmaports.cfg version check
we already have. Set the minimum required version to 0.2.0.
This commit is contained in:
Oliver Smith 2020-06-29 20:40:02 +02:00
parent a6bcc2ba83
commit 4d940736a8
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 17 additions and 0 deletions

View File

@ -31,6 +31,9 @@ pmaports_min_version = "7"
# see migrate_work_folder()).
work_version = 5
# Minimum required version of postmarketos-ondev (pmbootstrap install --ondev)
ondev_min_version = "0.2.0"
# Programs that pmbootstrap expects to be available from the host system. Keep
# in sync with README.md, and try to keep the list as small as possible. The
# idea is to run almost everything in Alpine chroots.

View File

@ -382,6 +382,18 @@ def sanity_check_sdcard(device):
raise RuntimeError("{} is read-only, is the sdcard locked?".format(device))
def sanity_check_ondev_version(args):
arch = args.deviceinfo["arch"]
package = pmb.helpers.package.get(args, "postmarketos-ondev", arch)
ver_pkg = package["version"].split("-r")[0]
ver_min = pmb.config.ondev_min_version
if pmb.parse.version.compare(ver_pkg, ver_min) == -1:
raise RuntimeError("This version of pmbootstrap requires"
f" postmarketos-ondev version {ver_min} or"
" higher. The postmarketos-ondev found in pmaports"
f" / in the binary packages has version {ver_pkg}.")
def install_system_image(args, size_reserve, suffix, root_label="pmOS_root",
step=3, steps=5, split=False, sdcard=None):
"""
@ -566,6 +578,8 @@ def install(args):
# Sanity checks
if not args.android_recovery_zip and args.sdcard:
sanity_check_sdcard(args.sdcard)
if args.on_device_installer:
sanity_check_ondev_version(args)
# Number of steps for the different installation methods.
if args.no_image: