From 4d940736a84e4eaf528e55fedd854ab290f33799 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 29 Jun 2020 20:40:02 +0200 Subject: [PATCH] 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. --- pmb/config/__init__.py | 3 +++ pmb/install/_install.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index 6edd2a1c..2dc40efb 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -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. diff --git a/pmb/install/_install.py b/pmb/install/_install.py index cae81924..b892cb66 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -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: